Description
This is the sequel to #11201. It's awesome to see most of the things in that issue fixed.
Type System Features
- PEP 695 Support for PEP 695 #15238
- PEP 702 Add support for PEP 702 (
@deprecated
) #16111 - PEP 675 Support PEP 675 (LiteralString) #12554
- PEP 696 Support PEP 696 – Type defaults for TypeVarLikes #14851
Behaviour changes
-
Ternary unions Use union instead of join for unifying types #12056We should use unions in some places we currently join, see Use union instead of join for unifying types #12056 (comment)
Update: We now use unions in more places, including ternary expressions. Feel free to investigate this more though!
-
Always narrow types Types not added to binder on initial assignment #2008 (comment) (proposal 3)
Users find it surprising because it seems obvious that mypy should know the variable is of the narrower type. There was a big discussion in typing-sig and all the type checkers agreed this behaviour was probably the best. The change is very easy, but exposes bugs in binder
-
Default value of generic parameters Unable to specify a default value for a generic parameter #3737 (comment)
It's totally reasonable to want to have generic parameters with defaults, we should error at call sites in case of badness
-
Support narrowing Literal Narrowing types to
Literal
usingin
syntax #12535It's hard to really use Literal types without a good way to narrow them. We should also narrow on
==
. I think last time I tried this it exposed bugs in binder -
Support property setters with broader types What to do about setters of a different type than their property? #3004
Should also allow covariant overrides of getter
-
Better handling of
__new__
Believe more __new__ return types #16020This is part of the Python language and comes up weirdly frequently.
-
Love for match statement https://github.com/python/mypy/issues?q=is%3Aopen+label%3Atopic-match-statement+sort%3Areactions-%2B1-desc
I fixed the most popular of these issues, but there's still a long tail of them
-
PEP 688 Drop bytes/bytearray and bytes/memoryview promotions (PEP 688) #15313
Easy, is just a somewhat breaking change
UI
-
Per module strict=true bug: strict = true is incompatible with per-module configuration #11401
There's maybe some other UI stuff we can think about for groups of flags and error codes, as discussed in meetup. I also don't like the new
--extra-checks
since flag name doesn't mean anything and can't be decomposed. -
Ability to override PEP 561 Allow/disallow pep561 packages #8545
It would be nice to be able to opt-in to treating packages missing py.typed as having py.typed. mypy can still provide a lot of value just based on function shape.
-
Exclude should imply per-module follow_import=skip exclude should imply a per-module follow import skip for matching modules #10377
Currently
--exclude
only affects file discovery on command line, not import following. This is a source of frustration for users because the relevant modules can still end up being type checked. -
Provide flag to generate stubs requirements (🎁) Improve usability of
--install-types
#10600 (comment)--install-types
is slow, results in unstable type checking, doesn't let users manage their own envs, can fail unclearly if cache isn't written -
Rethink stub suggestion logic Improving and evolving stub package suggestions #10619
Our current behaviour was needed to help the migration to modular typeshed, but is not behaviour we'd have designed from scratch.
Gradual typing
-
Make
check_untyped_defs = True
the default Give an error if there is a variable annotation within a function but no signature #3948 (comment) / Should we eventually type check all function bodies by default? #6646We decided not to do this for mypy 1.0, but could still make sense in the future.
-
Infer obvious return types Proposal: treat "obvious" return type as annotated #4409 / Proposal: infer obvious parameters and return types #10149
As a 1/3-way measure, we could also do (🎁) Flag to make default return type
None
instead ofAny
#9413 -
Infer method types from superclass untyped defs on derived classes #3903 (comment)
Performance
- Parallel type checking Faster, parallel type checking #933
- Faster caching Faster cache deserialization #3456
Misc
-
Member access Refactor all member access to go through checkmember.py (meta issue) #7724
-
Merge configuration docs Consider merging command line flags and configuration file options descriptions #12347
See also a similar issue for mypyc here: mypyc/mypyc#785
(other maintainers, feel free to edit)