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 support for type checking with upcomming Numpy 1.20 release. #2499

Merged
merged 35 commits into from
Jan 4, 2021

Conversation

jenshnielsen
Copy link
Collaborator

@jenshnielsen jenshnielsen commented Dec 7, 2020

Checked locally with numpy 1.20 rc1

  • Some numpy types are now generic so give them an explicit Any. Use types in strings to support older numpy versions
  • np.int, np.float and np.complex which are aliases for the build in python types are deprecated.
  • Use the dtype constructor explicitly when needed
  • Various fixes for interaction between the python types and numpy types

EDIT:
while this does run with older versions of numpy it does not type check. Not sure what the best solution is.
We can add ignores to those lines or just wait until numpy 1.20 is officially released. Or we could disable the non explicit generics for now.

Copy link
Contributor

@astafan8 astafan8 left a comment

Choose a reason for hiding this comment

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

while this does run with older versions of numpy it does not type check

you mean that it doesn't typecheck with "old verions of numpy" (and the current version of stubs)? then it sounds like the best thing to do is to wait for 1.20 to be released, merge this PR immediately then, and never worry about 1.19 and before ever again.

qcodes/dataset/sqlite/database.py Outdated Show resolved Hide resolved
qcodes/dataset/sqlite/queries.py Outdated Show resolved Hide resolved
qcodes/tests/helpers/test_json_encoder.py Outdated Show resolved Hide resolved
qcodes/tests/validators/test_complex.py Outdated Show resolved Hide resolved
qcodes/utils/types.py Outdated Show resolved Hide resolved
@jenshnielsen
Copy link
Collaborator Author

@astafan8 I realized that we can just get this passing with older numpy versions by removing the stubs. I think this is ready for review but I would like to merge #2569 first so we ensure that this does not break any older numpy versions

@codecov
Copy link

codecov bot commented Dec 30, 2020

Codecov Report

Merging #2499 (e8d3fa1) into master (52d7e69) will decrease coverage by 0.01%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #2499      +/-   ##
==========================================
- Coverage   63.62%   63.60%   -0.02%     
==========================================
  Files         198      198              
  Lines       25913    25929      +16     
==========================================
+ Hits        16486    16493       +7     
- Misses       9427     9436       +9     

@astafan8
Copy link
Contributor

astafan8 commented Jan 4, 2021

@jenshnielsen ok, good! is it worth waiting until the stubs start matching the types of numpy 1.20? or is the issue somewhere else? I guess since the stubs are not an official released project (right?), we'd better just stick to numpy 1.20 since it's the latest nunmpy that will alweays be installed when we run mypy in CI?

@jenshnielsen
Copy link
Collaborator Author

@astafan8 The stubs are deprecated and will never be updated. The types in numpy 1.20 are the official source of truth

@jenshnielsen jenshnielsen merged commit 9517c19 into microsoft:master Jan 4, 2021
@jenshnielsen jenshnielsen deleted the numpy_120 branch January 4, 2021 13:20
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.

None yet

2 participants