Make Python versions known statically#382
Conversation
Type checkers are unable to interpret `sys.version_info` aliases and generate unions between Python version branches. If either branch depends on packages which are not installed the union might be reduced to an unknown or any type.
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #382 +/- ##
==========================================
- Coverage 95.81% 95.80% -0.02%
==========================================
Files 26 26
Lines 2128 2122 -6
==========================================
- Hits 2039 2033 -6
Misses 89 89
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
I'm willing to take this, but what's the benefit? I don't type check the insides of cattrs since it's very meta-programmy. Will users of Pyright have a better time with these changes? |
|
The benefit is that type checkers (Pyright and presumably MyPy) will be able to correctly resolve the types of some of cattrs' public classes (e.g. As an aside, even though the library's internals aren't worth type checking, public types could still be verified for correctness/completeness with |
|
Thanks! |
Type checkers are unable to interpret
sys.version_infoaliases and generate unions between Python version branches. If either branch depends on packages which are not installed the union might be reduced to an unknown or any type.Follow-up from #379 (Pyright would merge the two branches).