Skip to content

Commit

Permalink
Update pyrightconfig.json settings
Browse files Browse the repository at this point in the history
We've revised the pyrightconfig.json settings in light of recent
developments.

The key question we have in mind is: How do we find the right balance
between type checking strictness and useful error messages?

The goal is to use type hints to make code clearer but not overuse them
to the point where they obscure the logic of the code itself.

Always remember you read code a lot more often than you write it.
Therefore you should optimize for ease of reading.

To this end we improved the typing of another codebase by tightening up
the checks but not making them too tight.

The main changes was to change the `typeCheckingMode` to "standard" [1].

This adds a few more checks over "basic" type checking mode, but not as
many as "strict". However some of the checks in "strict" are still useful
like:
- reportMissingParameterType
- reportPropertyTypeMismatch
- reportUnnecessaryComparison

These have been explicitly set to "error" in the pyrightconfig.json,
otherwise they would be set to "none" (in "standard" mode) and we
wouldn't see these errors.

Any settings that default to "error" in "standard' type checking mode
have been removed from the pyrightconfig.json file as they aren't
necessary.

[1] https://github.com/microsoft/pyright/blob/main/docs/configuration.md
  • Loading branch information
webventurer committed Sep 21, 2024
1 parent 6f1fd87 commit 5d38db0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"reportGeneralTypeIssues": "none",
"reportArgumentType": "none",
"reportAttributeAccessIssue": "none",
"reportIndexIssue": "none",
"reportIncompatibleMethodOverride": "error",
"reportMissingParameterType": "none",
"reportMissingTypeStubs": "none",
"typeCheckingMode": "basic",
"venv": ".venv",
"venvPath": ".",
"reportMissingParameterType": "error",
"reportPropertyTypeMismatch": "error",
"reportUnnecessaryComparison": "error",
"typeCheckingMode": "standard",
"include": [
"."
],
"extraPaths": [
"./mylib"
]
],
"venv": ".venv",
"venvPath": "."
}

0 comments on commit 5d38db0

Please sign in to comment.