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 type annotations #740

Closed
wants to merge 17 commits into from
Closed

Add type annotations #740

wants to merge 17 commits into from

Conversation

isac322
Copy link
Contributor

@isac322 isac322 commented Dec 17, 2019

Pull Request Checklist

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

Description of Changes

Added type annotations to all non test codes.

Used python stub file format to annotate for compatibility with Python 2.

mypy -p arrow -2 --strict and mypy -p arrow --strict both returns Success: no issues found in 10 source files (mypy: 0.750)

Did not test with pyre and pytype because they both can not handle python 3.8 code.

@codecov-io
Copy link

codecov-io commented Dec 17, 2019

Codecov Report

Merging #740 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #740   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           9      9           
  Lines        1678   1678           
  Branches      283    283           
=====================================
  Hits         1678   1678

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 5395fbb...3e17ca8. Read the comment docs.

@jadchaar
Copy link
Member

Hi @isac322, thanks for putting in the time and effort to work on this. Adding type annotations to Arrow has been on my mind for a while.

That said, I have a couple of comments: I worry that adding the interface (.pyi) files may become unmaintainable as future contributors contribute to Arrow since type annotations are pretty new to Python and not many people may be familiar with them. I think it might be better to take an inline approach as shown here so that users are more enticed to update them when they change code. The only problem with this is that Python 3.5+ is required unless we take the commenting approach specified here.

That begs the question: should we wait until Arrow drops Python 2 support before adding the Python 3.5+ style type annotations, especially considering that Python 2 is approaching EOL in a few weeks (#739). Or should we go ahead with the commenting approach to maintain backward compatibility with Python 2.

I do agree though that adding type annotations is a great step for Arrow and will help reduce future bugs.

Once again, thanks for the solid work, I just wanted to start a discussion about the changes.

@systemcatch systemcatch changed the title Add type anntations Add type annotations Dec 18, 2019
@jadchaar
Copy link
Member

jadchaar commented Jan 2, 2020

Hi @isac322, just wanted to check in on this PR. @systemcatch and I discussed these changes and we decided that it is best to integrate type annotations once Arrow has officially dropped support for Python 2.7 since this will allow us to include more maintainable, inline type annotations.

Since Python 2.7 reached EOL today, we plan on dropping Python 2 support from Arrow in a future v0.16.0 release. We would love to integrate inline type annotations for that release and we were wondering if you would be able to help with that.

Let us know! Thanks!

@isac322
Copy link
Contributor Author

isac322 commented Jan 6, 2020

Hi @jadchaar, first of all, I'm sorry for the delay and thank you for the discussion. Because my company still uses Python 2 and 3 both, personally, it would be good if type annotation stored in separate files 😅.
But since Python 2 is officially dropped, I agree with your decision and I think I can help with the integration.
Please mention me on this PR after dropping Python 2, so I can annotate type on function and local variable too.
Thanks!

@systemcatch
Copy link
Collaborator

Let's close this for now and once python 2 support is dropped we can move towards inline type checking.

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.

4 participants