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

Refactor types to check with pyright #4894

Merged
merged 89 commits into from
Jan 4, 2023

Conversation

jenshnielsen
Copy link
Collaborator

Over Christmas I spent a bit of time experimenting with getting types to check with pyright in addition to mypy
This is mainly motivated by having typechecking inline in vscode
There are a number of differences.

  • Pyright is somewhat less flexible if a parameter defined within a branch and later used within another branch with the same condition.
  • Pyright does not allow inline operations such as - (minus) on numpy arrays unless the dtype is known (could be string etc)
  • pyright is less flexible with type narrowing when unknown types are used
  • pyright checks code even if the function is not typed at all, so exlude a bunch of stuff that is not typed
  • pyright has a way of generation stubs automatically so I have generated stubs to check agains for some of our packages

@codecov
Copy link

codecov bot commented Jan 2, 2023

Codecov Report

Merging #4894 (d115000) into master (56b8a0c) will decrease coverage by 0.91%.
The diff coverage is 58.94%.

@@            Coverage Diff             @@
##           master    #4894      +/-   ##
==========================================
- Coverage   68.32%   67.40%   -0.92%     
==========================================
  Files         340      340              
  Lines       32157    32236      +79     
==========================================
- Hits        21970    21729     -241     
- Misses      10187    10507     +320     

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.

looks nice! some of the found things are indeed well-found bugs!

qcodes/station.py Show resolved Hide resolved
qcodes/validators/validators.py Outdated Show resolved Hide resolved
@jenshnielsen
Copy link
Collaborator Author

Ipython became typed in #4897 so those stubs should be removed

@jenshnielsen jenshnielsen force-pushed the pyright_1 branch 2 times, most recently from c3e5476 to eb4f9d1 Compare January 3, 2023 15:21
@jenshnielsen jenshnielsen changed the title [WIP] Refactor types to check with pyright Refactor types to check with pyright Jan 4, 2023
docs/changes/newsfragments/4894.breaking Outdated Show resolved Hide resolved
@jenshnielsen jenshnielsen enabled auto-merge January 4, 2023 11:28
@jenshnielsen jenshnielsen merged commit c026526 into microsoft:master Jan 4, 2023
@jenshnielsen jenshnielsen deleted the pyright_1 branch January 4, 2023 12:48
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.

2 participants