-
Notifications
You must be signed in to change notification settings - Fork 128
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
Configure Pyright #1246
Configure Pyright #1246
Conversation
8c19b75
to
2a74460
Compare
67b16d2
to
3469831
Compare
(1 year later - I must have missed this at the time) I think this is a great direction to go in. My not-extensive understanding of type checking in python indicates pyright is preferred over mypy. It seems strange to me to use both typecheckers in the same project, but this seems to be rather common in python. |
3469831
to
fda57c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the direction of this PR from trying to address all violations to just setting up Pyright and ignoring violations explicitly. This reflects similar work done in nextstrain/nextstrain.org#778.
Here's commits from the old direction: 9e8c9e0...3469831 and new direction: fda57c5
2205fe0
to
062fb9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; concur with James that we should add pyright as an explicit dev-dep.
Add the necessary configuration including rule exceptions to make the linter run without error on the code as-is. This means the check is mostly useless except to prevent any violations of rules that aren't currently violated, but it allows for incremental adoption of rules rather than needing to address all violations at once. List of exceptions determined using command: npx pyright --outputjson \ | jq --raw-output '.generalDiagnostics.[] | .rule' \ | sort -u Invocation via pytest mirrors that of mypy. Both were ported from existing setup in Nextstrain CLI.¹ ¹ <https://github.com/nextstrain/cli/blob/14a392eaf40f779a7ef9431bbe0a116e93d98580/doc/development.md?plain=1#L143>
I'm unsure why these don't show up locally on the same Pyright version. They were flagged by CI so I'm adding them to the list from the previous commit.
062fb9b
to
e5ced1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to go, yeah?
Description of proposed changes
Add the necessary configuration including rule exceptions to make the linter run without error on the code as-is. This means the check is mostly useless except to prevent any violations of rules that aren't currently violated, but it allows for incremental adoption of rules rather than needing to address all violations at once.
List of exceptions determined using command:
Pyright supports some checks and type inference that Mypy does not¹.
¹ https://github.com/microsoft/pyright/blob/1.1.316/docs/mypy-comparison.md
Checklist
Add a message in CHANGES.md summarizing the changes in this PR that are end user focused. Keep headers and formatting consistent with the rest of the file.no functional changes