Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add py.typed export per PEP 561 #925

Merged
merged 1 commit into from
Feb 27, 2021
Merged

Add py.typed export per PEP 561 #925

merged 1 commit into from
Feb 27, 2021

Conversation

maroux
Copy link
Contributor

@maroux maroux commented Feb 26, 2021

Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

Description of Changes

Add py.typed file and export type annotations per PEP 561 so that type testing tools like mypy can actually verify types when using arrow.

No new test added for this change and I don't think there's any documentation necessary but let me know if something needs to be added.

So that type testing tools like mypy can actually use type annotations
@maroux maroux mentioned this pull request Feb 26, 2021
5 tasks
@codecov
Copy link

codecov bot commented Feb 26, 2021

Codecov Report

Merging #925 (7e6374f) into master (5248407) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #925   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         1896      1896           
  Branches       311       311           
=========================================
  Hits          1896      1896           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5248407...9b56687. Read the comment docs.

setup.py Show resolved Hide resolved
Copy link
Member

@jadchaar jadchaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I had a quick question @maroux. If PEP 561 is Python 3.7+ compatible, will mypy not detect the typings in Python 3.6?

@maroux
Copy link
Contributor Author

maroux commented Feb 26, 2021

@jadchaar possible? At least for mypy, it looks like it supports py.typed even for py3.6:

○ → cat a.py
import arrow


if __name__ == "__main__":
    print(arrow.get(object()))


○ → python --version
Python 3.6.11


○ → mypy a.py
a.py:5: error: No overload variant of "get" matches argument type "object"
a.py:5: note: Possible overload variant:
a.py:5: note:     def get(Union[Arrow, datetime, date, struct_time, tzinfo, int, float, str, Tuple[int, int, int]], *, locale: str = ..., tzinfo: Union[tzinfo, str, None] = ..., normalize_whitespace: bool = ...) -> Arrow
a.py:5: note:     <3 more non-matching overloads not shown>
Found 1 error in 1 file (checked 1 source file)

I think for PEPs that don't add features to python core, the python-version isn't a requirement, but I could be wrong.

@jadchaar
Copy link
Member

@isac322 you might be more familiar with PEP 561 for type annotations. Think this is good to merge?

@isac322
Copy link
Contributor

isac322 commented Feb 27, 2021

@jadchaar Yep I forgot to add this 😅

@jadchaar
Copy link
Member

@jadchaar Yep I forgot to add this 😅

All good, just wanted to make sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants