Tuesday, 31 March 2026

Mypy 1.20 Released

We’ve just uploaded mypy 1.20.0 to the Python Package Index (PyPI). Mypy is a static type checker for Python. This release includes new features, performance improvements and bug fixes. You can install it as follows:

python3 -m pip install -U mypy

You can read the full documentation for this release on Read the Docs.

Planned Changes to Defaults and Flags in Mypy 2.0

As a reminder, we are planning to enable --local-partial-types by default in mypy 2.0, which will likely be the next feature release. This will often require at least minor code changes. This option is implicitly enabled by mypy daemon, so this makes the behavior of daemon and non-daemon modes consistent.

Note that this release improves the compatibility of --local-partial-types significantly to make the switch easier (see below for more).

This can also be configured in a mypy configuration file (use False to disable):

local_partial_types = True

For more information, refer to the documentation.

We will also enable --strict-bytes by default in mypy 2.0. This usually requires at most minor code changes to adopt. For more information, refer to the documentation.

Finally, --allow-redefinition-new will be renamed to --allow-redefinition. If you want to continue using the older --allow-redefinition semantics which are less flexible (e.g. limited support for conditional redefinitions), you can switch to --allow-redefinition-old, which is currently supported as an alias to the legacy --allow-redefinition behavior. To use --allow-redefinition in the upcoming mypy 2.0, you can't use --no-local-partial-types. For more information, refer to the documentation.

Better Type Narrowing

Mypy's implementation of narrowing has been substantially reworked. Mypy will now narrow more aggressively, more consistently, and more correctly. In particular, you are likely to notice new narrowing behavior in equality expressions (==), containment expressions (in), match statements, and additional expressions providing type guards.

Note that mypy (and other Python type checkers) do not model the potential for various non-local operations to invalidate narrowing assumptions. This means mypy may conclude that some of your code is unreachable and avoid further checking of it. The --warn-unreachable flag is useful for highlighting these cases. To reset narrowing, you can insert dummy reassignments, for instance var = var will reset all narrowing of var.attr.

Future work includes better narrowing on initial assignments, more narrowing to Literal types, and better checking of unreachable code.

Contributed by Shantanu Jain.

  • Rework narrowing logic for equality and identity (Shantanu, PR 20492)
  • Refactor equality and identity narrowing for clarity (Shantanu, PR 20595)
  • Treat NotImplemented as a singleton type (Shantanu, PR 20601)
  • Improve narrowing logic for Enum int and str subclasses (Shantanu, PR 20609)
  • Narrow types based on collection containment (Shantanu, PR 20602)
  • Refactor and improve narrowing for type(x) == t checks (Shantanu, PR 20634)
  • Narrow for type expr comparisons to type exprs (Shantanu, PR 20639)
  • Narrowing for comparisons against x.__class__ (Shantanu, PR 20642)
  • Better narrowing with custom equality (Shantanu, PR 20643)
  • Use a single pass for core narrowing logic, add comments (Shantanu, PR 20659)
  • Narrowing for final type objects (Shantanu, PR 20661)
  • Avoid narrowing type[T] (Shantanu, PR 20662)
  • Avoid widening to Any for checks like type(x) is type(y: Any) (Shantanu, PR 20663)
  • Preserve some lost narrowing, cleanup (Shantanu, PR 20674)
  • Fix narrowing related code for types with overloaded __new__ (Shantanu, PR 20676)
  • Fix isinstance with unions of tuples (Shantanu, PR 20677)
  • Fix regression to chained containment (Shantanu, PR 20688)
  • Improve else handling with custom equality (Shantanu, PR 20692)
  • Better model runtime in isinstance and type checks (Shantanu, PR 20675)
  • Use --warn-unreachable and --strict-equality in more tests (Shantanu, PR 20707)
  • Model exact narrowing with type(x) checks (Shantanu, PR 20703)
  • Short term fix for bytes narrowing (Shantanu, PR 20704)
  • Preserve narrowing in unreachable code (Shantanu, PR 20710)
  • Fix bug when narrowing union containing custom eq against custom eq (Shantanu, PR 20754)
  • Fix narrowing for unions (Shantanu, PR 20728)
  • Unsoundly narrow away from None with custom eq (Shantanu, PR 20756)
  • Improve narrowing with numeric types (Shantanu, PR 20727)
  • Fix narrowing with final type objects (Shantanu, PR 20743)
  • Further improve match statement narrowing against unions (Shantanu, PR 20744)
  • Avoid narrowing to NewType (Shantanu, PR 20766)
  • Better match narrowing for irrefutable sequence patterns (Shantanu, PR 20782)
  • Remove prohibit_none_typevar_overlap (Shantanu, PR 20864)
  • Fix match statement narrowing reachability for tuples (Shantanu, PR 20896)
  • Better handling of generics when narrowing (Shantanu, PR 20863)
  • Better match narrowing for type objects (Shantanu, PR 20872)
  • Narrow Callable generic return types (Shantanu, PR 20868)
  • Better match narrowing for unions of type objects (Shantanu, PR 20905)
  • Improve reachability in narrowing logic (Shantanu, PR 20660)
  • Better match narrowing for irrefutable mapping patterns (Shantanu, PR 20906)
  • Fix match statement semantic reachability (Shantanu, PR 20968)
  • Add some additional narrowing test cases (Shantanu, PR 20598)
  • Move tests to check-narrowing , improve them slightly (Shantanu, PR 20637)
  • Add more tests for narrowing logic (Shantanu, PR 20672)
  • More testing related improvements and updates (Shantanu, PR 20709)
  • Add --warn-unreachable to more tests (Shantanu, PR 20977)

Drop Support for Python 3.9

Mypy no longer supports running with Python 3.9, which has reached end of life. When running mypy with Python 3.10+, it is still possible to type check code that needs to support Python 3.9 with the --python-version 3.9 argument. Support for this will be dropped in the first half of 2026!

Contributed by Marc Mueller (PR 20156).

Mypyc Accelerated Mypy Wheels for ARM Windows and Free Threading

For best performance, mypy can be compiled to C extension modules using mypyc. This makes mypy 3-5x faster than when interpreted with pure Python. We now build and upload mypyc accelerated mypy wheels for win_arm64 and cp314t-... to PyPI, making it easy for Windows users on ARM and those using the free theading builds for Python 3.14 to realise this speedup -- just pip install the latest mypy.

Contributed by Marc Mueller (PR mypy_mypyc-wheels#106, PR mypy_mypyc-wheels#110).

Improved Compatibility for Local Partial Types

Compatibility between mypy's default behavior and the --local-partial-types flag is now improved. This improves compatibility between mypy daemon and non-daemon modes, since the mypy daemon requires local partial types to be enabled.

In particular, code like this now behaves consistently independent of whether local partial types are enabled or not:

x = None

def foo() -> None:
    global x
    x = 1

# The inferred type of 'x' is always 'int | None'.

Also, we are planning to turn local partial types on by default in mypy 2.0 (to be released soon), and this makes the change much less disruptive. Explicitly disabling local partial types will continue to be supported, but the support will likely be deprecated and removed eventually, as the legacy behavior is hard to support together with some important changes we are working on, in addition to being incompatible with the mypy daemon.

This feature was contributed by Ivan Levkivskyi (PR 20938).

Python 3.14 T-String Support (PEP 750)

Mypy now supports t-strings that were introduced in Python 3.14.

  • Add support for Python 3.14 t-strings (PEP 750) (Neil Schemenauer and Brian Schubert, PR 20850)
  • Add implicit module dependency if using t-string (Jukka Lehtosalo, PR 20900)

Experimental New Parser

If you install mypy using pip install mypy[native-parser] and run mypy with --native-parser, you can experiment with a new Python parser. It is based on the Ruff parser, and it's more efficient than the default parser. It will also enable access to all Python syntax independent of which Python version you use to run mypy. The new parser is still not feature-complete and has known issues.

Related changes:

  • Add work-in-progress implementation of a new Python parser (Jukka Lehtosalo, PR 20856)
  • Skip redundant analysis pass when using the native parser (Ivan Levkivskyi, PR 21015)
  • Add t-string support to native parser (Ivan Levkivskyi, PR 21007)
  • Handle hex bigint literals in native parser (Ivan Levkivskyi, PR 20988)
  • Pass all relevant options to native parser (Ivan Levkivskyi, PR 20984)
  • Support @no_type_check with native parser (Ivan Levkivskyi, PR 20959)
  • Fix error code handling in native parser (Ivan Levkivskyi, PR 20952)
  • Add ast-serialize as an optional dependency (Ivan Levkivskyi, PR 21028)
  • Use native-parser instead of native-parse for optional dependency (Jukka Lehtosalo, PR 21115)

Performance Improvements

Mypy now uses a binary cache format (fixed-format cache) by default to speed up incremental checking. You can still use --no-fixed-format-cache to use the legacy JSON cache format, but we will remove the JSON cache format in a future release. Mypy includes a tool to convert individual fixed-format cache files (.ff) to the JSON format to make it possible to inspect cache contents:

python -m mypy.exportjson <path> ...

If the SQLite cache is enabled, you will first need to convert the SQLite cache into individual files using the misc/convert-cache.py tool available in the mypy GitHub repository. You can also disable the SQLite cache using --no-sqlite-cache.

The SQLite cache (--sqlite-cache) is now enabled by default. It improves mypy performance significantly in certain environments where slow file system operations used to be a bottleneck.

List of all performance improvements (for mypyc improvements there is a separate section below):

  • Flip fixed-format cache to on by default (Ivan Levkivskyi, PR 20758)
  • Enable --sqlite-cache by default (Shantanu, PR 21041)
  • Save work on emitting ignored diagnostics (Shantanu, PR 20621)
  • Skip logging and stats collection calls if they are no-ops (Jukka Lehtosalo, PR 20839)
  • Speed up large incremental builds by optimizing internal state construction (Jukka Lehtosalo, PR 20838)
  • Speed up suppressed dependencies options processing (Jukka Lehtosalo, PR 20806)
  • Avoid path operations that need syscalls (Jukka Lehtosalo, PR 20802)
  • Use faster algorithm for topological sort (Jukka Lehtosalo, PR 20790)
  • Replace old topological sort (Jukka Lehtosalo, PR 20805)
  • Fix quadratic performance in dependency graph loading for incremental builds (Jukka Lehtosalo, PR 20786)
  • Micro-optimize transitive dependency hash calculation (Jukka Lehtosalo, PR 20798)
  • Speed up options snapshot calculation (Jukka Lehtosalo, PR 20797)
  • Micro-optimize read buffering, metastore abspath, path joining (Shantanu, PR 20810)
  • Speed up type comparisons and hashing for literal types (Shantanu, PR 20423)
  • Optimize overloaded signatures check (asce, PR 20378)
  • Avoid unnecessary work when checking deferred functions (Ivan Levkivskyi, PR 20860)
  • Improve --allow-redefinition-new performance for code with loops (Ivan Levkivskyi, PR 20862)
  • Avoid setattr/getattr with fixed format cache (Ivan Levkivskyi, PR 20826)

Improvements to Allowing Redefinitions

Mypy now allows significantly more flexible variable redefinitions when using --allow-redefinition-new. In particular, function parameters can now be redefined with a different type:

# mypy: allow-redefinition-new, local-partial-types

def process(items: list[str]) -> None:
    # Reassign parameter to a completely different type.
    # Without --allow-redefinition-new, this is a type error 
    # because list[list[str]] is not compatible with 
    # list[str].
    items = [item.split() for item in items]
    ...

In mypy 2.0, we will update --allow-redefinition to mean --allow-redefinition-new. This release adds --allow-redefinition-old as an alias of --allow-redefinition, which can be used to continue using the old redefinition behavior in mypy 2.0 and later.

List of changes:

  • Add --allow-redefinition-old as an alias of --allow-redefinition (Ivan Levkivskyi, PR 20764)
  • Allow redefinitions for function arguments (Ivan Levkivskyi, PR 20853)
  • Fix regression on redefinition in deferred loop (Ivan Levkivskyi, PR 20879)
  • Fix loop convergence with redefinitions (Ivan Levkivskyi, PR 20865)
  • Make sure new redefinition semantics only apply to inferred variables (Ivan Levkivskyi, PR 20909)
  • Fix union edge case in function argument redefinition (Ivan Levkivskyi, PR 20908)
  • Show an error when old and new redefinition are enabled in a file (Ivan Levkivskyi, PR 20920)
  • --allow-redefinition-new is no longer experimental (Jukka Lehtosalo, PR 21110)
  • Fix type inference for nested union types (Ivan Levkivskyi, PR 20912)
  • Fix type inference regression for multiple variables in loops (Ivan Levkivskyi, PR 20892)
  • Improve type inference for empty collections in conditional contexts (Ivan Levkivskyi, PR 20851)

Incremental Checking Improvements

This release includes multiple fixes to incremental type checking:

  • Invalidate cache when --enable-incomplete-feature changes (kaushal trivedi, PR 20849)
  • Add back support for warn_unused_configs (Ivan Levkivskyi, PR 20801)
  • Recover from corrupted fixed-format cache meta file (Jukka Lehtosalo, PR 20780)
  • Distinguish not found versus skipped modules (Ivan Levkivskyi, PR 20812)
  • Fix undetected submodule deletion on warm run (Ivan Levkivskyi, PR 20784)
  • Fix staleness on changed follow-imports options (Ivan Levkivskyi, PR 20773)
  • Verify indirect dependencies reachable on incremental run (Ivan Levkivskyi, PR 20735)
  • Fix indirect dependencies for protocols (Ivan Levkivskyi, PR 20752)
  • Show error locations in other modules on warm runs (Ivan Levkivskyi, PR 20635)
  • Don't read errors from cache on silent import (Sjoerd Job Postmus, PR 20509)
  • More robust fix for re-export of __all__ (Ivan Levkivskyi, PR 20487)

Fixes to Crashes

  • Fix crash on partially typed namespace package (Ivan Levkivskyi, PR 20742)
  • Fix internal error caused by the generic type alias with an unpacked list (Kai (Kazuya Ito), PR 20689)
  • Fix crash when missing format character (Shantanu, PR 20524)
  • Fix crash when passing literal values as type arguments to variadic generics (Aaron Wieczorek, PR 20543)
  • Fix crash on circular star import in incremental mode (Ivan Levkivskyi, PR 20511)
  • Fix crash with tuple unpack inside TypeVar default (Marc Mueller, PR 20456)
  • Fix crash on typevar with forward reference used in other module (Ivan Levkivskyi, PR 20334)
  • Fix crash on star import of redefinition (Ivan Levkivskyi, PR 20333)
  • Fix crash involving Unpack-ed TypeVarTuple (Shantanu, PR 20323)
  • Fix crashes caused by type variable defaults in-place modifications (Stanislav Terliakov, PR 20139)
  • Fix crash when calling len() with no arguments (Jukka Lehtosalo, PR 20774)
  • Fix crash when checking async for inside nested comprehensions (A5rocks, PR 20540)
  • Fix ParamSpec related crash (Stanislav Terliakov, PR 20119)

Mypyc: Faster Imports on macOS

Imports in native (compiled) modules that target other native modules that are compiled together are now significantly faster on macOS, especially on the first run after a compiled package has been installed. This also speeds up the first mypy run after installation/update on macOS.

This was contributed by Jukka Lehtosalo (PR 21101).

librt: Mypyc Standard Library

Mypyc now has a dedicated standard library, librt, to provide basic features that are optimized for compiled code. They are faster than corresponding Python stdlib functionality. There is no plan to replace the Python stdlib, though. We'll only include a carefully selected set of features that help with common performance bottlenecks in compiled code.

Currently, we provide librt.base64 that has optimized SIMD (Single Instruction, Multiple Data) base64 encoding and decoding functions. In future mypyc releases we are planning to add efficient data structures, string/bytes utilities, and more.

Use python3 -m pip install librt to make librt available to compiled modules. Compiled modules don't require librt unless they explicitly import librt. If you install mypy, you will also get a compatible version of librt as a dependency. We will keep librt backward compatible, so you should always be able to update to a newer version of the library.

Related changes:

  • Add minimal, experimental librt.base64 module (Jukka Lehtosalo, PR 20226)
  • Use faster base64 encode implementation in librt.base64 (Jukka Lehtosalo, PR 20237)
  • Add efficient librt.base64.b64decode (Jukka Lehtosalo, PR 20263)
  • Enable SIMD for librt.base64 on x86-64 (Jukka Lehtosalo, PR 20244)
  • Add primitive for librt.base64.b64decode (Jukka Lehtosalo, PR 20272)
  • Add urlsafe_b64encode and urlsafe_b64decode to librt.base64 (Jukka Lehtosalo, PR 20274)
  • Make librt.base64 non-experimental (Ivan Levkivskyi, PR 20783)
  • Support pyodide for Python 3.12 (Michael R. Crusoe, PR 20342)
  • Support pyodide via the NEON intrinsics (Michael R. Crusoe, PR 20316)
  • Fix librt compilation on platforms with OpenMP (Ivan Levkivskyi, PR 20583)
  • Fix cross-compiling librt by enabling x86_64 optimizations with pragmas (James Le Cuirot, PR 20815)
  • Use existing SIMD CPU dispatch by customizing build flags (Michael R. Crusoe, PR 20253)
  • Document librt and librt.base64 (Jukka Lehtosalo, PR 21114)

Mypyc: Acyclic Classes

Mypyc now supports defining acyclic native classes that don't participate in the tracing garbage collection:

from mypy_extensions import mypyc_attr

@mypyc_attr(acyclic=True)
class Item:
    def __init__(self, key: str, value: str) -> None:
        self.key = key
        self.value = value

Allocating and freeing instances of acyclic classes is faster than regular native class instances, and they use less memory, but if they participate in reference cycles, there may be memory leaks.

This was contributed by Jukka Lehtosalo (PR 20795).

Additional Mypyc Fixes and Improvements

  • Fix range loop variable off-by-one after loop exit (Vaggelis Danias, PR 21098)
  • Fix memory leak on property setter call (Piotr Sawicki, PR 21095)
  • Fix ClassVar self-references in class bodies (Vaggelis Danias, PR 21011)
  • Fix cross-module class attribute defaults causing KeyError (Vaggelis Danias, PR 21012)
  • Fix shadow vtable misalignment for @property getters/setters (Vaggelis Danias, PR 21010)
  • Fix lambda inside comprehension (Vaggelis Danias, PR 21009)
  • Use cached ASCII characters in CPyStr_GetItem (Vaggelis Danias, PR 21035)
  • Speed up int to bytes conversion (Piotr Sawicki, PR 21036)
  • Add missing primitive documentation (Jukka Lehtosalo, PR 21037)
  • Fix undefined behavior in generated C (Jukka Lehtosalo, PR 21094)
  • Fix vtable construction for deep trait inheritance (Vaggelis Danias, PR 20917)
  • Fix __init_subclass__ running before ClassVar instantiations (Vaggelis Danias, PR 20916)
  • Add support for str.lower() and str.upper() (Vaggelis Danias, PR 20948)
  • Add str.isdigit() primitive (Vaggelis Danias, PR 20893)
  • Add str.isalnum() primitive (Vaggelis Danias, PR 20852)
  • Add str.isspace() primitive (Vaggelis Danias, PR 20842)
  • Reduce memory usage when compiling large files (Vaggelis Danias, PR 20897)
  • Generate error if using Python 3.14 t-string (Jukka Lehtosalo, PR 20899)
  • Fix undefined attribute in nested coroutines (Piotr Sawicki, PR 20654)
  • Do not emit tracebacks with negative line numbers (Piotr Sawicki, PR 20641)
  • Fix crash on multiple nested decorated functions with same name (Piotr Sawicki, PR 20666)
  • Fix Final load in unreachable branches (BobTheBuidler, PR 20617)
  • Add new primitive for int.to_bytes (BobTheBuidler, PR 19674)
  • Support constant folding in f-string to str conversion (BobTheBuidler, PR 19970)
  • Implement bytes.endswith (esarp, PR 20447)
  • Fix coercion from short tagged int to fixed-width int (Jukka Lehtosalo, PR 20587)
  • Fix generation of function wrappers for decorated functions (Piotr Sawicki, PR 20584)
  • Generate function wrappers for each callable class instance (Piotr Sawicki, PR 20575)
  • Speed up ord(str[n]) by inlining (Jukka Lehtosalo, PR 20578)
  • Add inline primitives for bytes.__getitem__ (Jukka Lehtosalo, PR 20552)
  • Add primitive type for bytearray (Jukka Lehtosalo, PR 20551)
  • Fix and clean up bytearray support in primitives (Jukka Lehtosalo, PR 20550)
  • Enable --strict-bytes by default in mypyc (and require it) (Jukka Lehtosalo, PR 20548)
  • Fix exception reraising when awaiting a future (Piotr Sawicki, PR 20547)
  • Add inline primitives for BytesBuilder get item and set item (Jukka Lehtosalo, PR 20546)
  • Optimize loops over enumerate, map, zip, range, and other builtins with known lengths (BobTheBuidler, PR 19927)
  • Raise ValueError if int too big for native int type (Jukka Lehtosalo, PR 20385)
  • Fix generator regression with empty tuple (BobTheBuidler, PR 20371)
  • Improve constant folding for len() of string literals and Final values (BobTheBuidler, PR 20074)
  • Add primitive for bytes.startswith (esarp, PR 20387)
  • Fix calling async methods through vectorcall (Piotr Sawicki, PR 20393)
  • Extend loop optimization to use constant folding for determining sequence lengths (BobTheBuidler, PR 19930)
  • Wrap async functions with function-like type (Piotr Sawicki, PR 20260)
  • Add a primitive for bytes translate method (Jukka Lehtosalo, PR 20305)
  • Add primitives for bytes and str multiply (Jukka Lehtosalo, PR 20303)
  • Match int arguments to primitives with native int parameters (Jukka Lehtosalo, PR 20299)
  • Allow disabling extra flags with MYPYC_NO_EXTRA_FLAGS environment variable (James Hilliard, PR 20507)
  • Fix unsupported imports for type annotations (Lukas Geiger, PR 20390)
  • Fix unaligned memory access in librt internal helper function (Gregor Riepl, PR 20474)
  • Fix build issue (James Hilliard, PR 20510)

Removed Flags --force-uppercase-builtins and --force-union-syntax

The --force-uppercase-builtins flag was deprecated and has been a no-op since mypy 1.17.0. Since mypy has dropped support for Python 3.9, the --force-union-syntax flag is no longer necessary.

Contributed by Marc Mueller (PR 20410) and (PR 20405).

Stubgen Improvements

  • Fix mis-parsing of double colon ("::") (Jeremy Nimmer, PR 20285)

Stubtest Improvements

  • Attempt to resolve decorators from their type (Shantanu, PR 20867)
  • Fix crash on instances with redefined __class__ (sobolevn, PR 20926)
  • Improve checking of positional-only parameters in dunder methods (Brian Schubert, PR 19593)
  • Check Final variables with literal values against runtime (Vikash Kumar, PR 20858)
  • Fix duplicate errors with invalid line numbers (Joren Hammudoglu, PR 20417)
  • Ignore __conditional_annotations__ (Joren Hammudoglu, PR 20392)
  • Transparent @type_check_only types (Joren Hammudoglu, PR 20352)
  • Check runtime availability of private types not marked @type_check_only (Brian Schubert, PR 19574)

Documentation Updates

  • Document semantics of function argument redefinition (Ivan Levkivskyi, PR 20910)
  • Update common issues: document how the type ignore must come first (wyattscarpenter, PR 20886)
  • Update "type inference and annotations" (Kai (Kazuya Ito), PR 20619)
  • Document unreachability handling of return NotImplemented (wyattscarpenter, PR 20561)

Changes to Messages

  • Simpler/cleaner reveal_type() (Ivan Levkivskyi, PR 20929)
  • Use "parameter" instead of "argument" in overload error (Kai (Kazuya Ito), PR 20994)
  • Use "parameter" instead of "argument" in unpacking error (Kai (Kazuya Ito), PR 20683)
  • Use "type arguments" instead of "type parameters" for bare generics (Kai (Kazuya Ito), PR 20494)
  • Update "arguments" to "parameters" (Kai (Kazuya Ito), PR 20711)
  • Use "parameter" instead of "argument" in default value error messages (Kai (Kazuya Ito), PR 20964)
  • Update error message for parameter overlap in TypedDict (Kai (Kazuya Ito), PR 20956)
  • Correct "Duplicate argument" error messages (Kai (Kazuya Ito), PR 20957)
  • Use standard formatting for note on unexpected keyword (Ivan Levkivskyi, PR 20808)
  • Fix edge cases in pretty formatting (Ivan Levkivskyi, PR 20809)
  • Add function definition notes for missing named argument errors (Kevin Kannammalil, PR 20794)
  • Make overloaded constructors consistent in error messages (Ivan Levkivskyi, PR 20483)
  • Improve error message for invalid Python package (Shantanu, PR 20482)
  • Emit end line/column in JSON format for span tracking (Adam Turner, PR 20734)
  • Wrap callable in union syntax (Marc Mueller, PR 20406)

Other Notable Fixes and Improvements

  • Unify handling of self attributes in daemon (Ivan Levkivskyi, PR 21025)
  • Improve support for hasattr() (Ivan Levkivskyi, PR 20914)
  • Warn when @disjoint_base is used on protocols or TypedDicts (Brian Schubert, PR 21029)
  • Model tuple type aliases better (Shantanu, PR 20967)
  • Fix incorrect type inference for container literals inside loops (Ivan Levkivskyi, PR 20875)
  • Fix edge case in type comparison for type variables with narrowed bounds (Ivan Levkivskyi, PR 20874)
  • Prohibit access via class for instance-only attributes (Ivan Levkivskyi, PR 20855)
  • Update JSON export tool to support binary meta cache files (Jukka Lehtosalo, PR 20096)
  • Better handling for uncaught top-level exceptions (Ivan Levkivskyi, PR 20749)
  • Attrs field level kw_only=False overrides kw_only=True at class level (getzze, PR 20949)
  • Fix __slots__ issue with deferred base (Shantanu, PR 20573)
  • Fix deferral logic for special types (Ivan Levkivskyi, PR 20678)
  • Fix false negatives in walrus versus inference fallback logic (Ivan Levkivskyi, PR 20622)
  • Fix enum value inference with user-defined data type mixin (E. M. Bray, PR 16320)
  • Fix incorrect classification of class attributes versus enum members (Stanislav Terliakov, PR 19687)
  • Improve type inference when finding common types for callable types (Shantanu, PR 18406)
  • Remove special case for Union type context (Shantanu, PR 20610)
  • Evaluate argument expressions in runtime evaluation order (Shantanu, PR 20491)
  • Allow empty type applications for ParamSpec (A5rocks, PR 20572)
  • Make X[()] count as a type application (A5rocks, PR 20568)
  • Accept value as keyword argument in TypeAliasType (Ali Hamdan, PR 20556)
  • Avoid treating pass and ... as no-op for reachability (Shantanu, PR 20488)
  • Fix specialization leak in generic TypedDict.update() (Aaron Wieczorek, PR 20517)
  • Fix false positive redundant expression warnings with isinstance() on Any | Protocol unions (Randolf Scholz, PR 20450)
  • Fix type checking of class-scope imports accessed via self or cls (bzoracler, PR 20480)
  • Prevent synthetic intersections from leaking to module public interfaces (bzoracler, PR 20459)
  • Fix package build failure when the compiler types are not defined (Steven Pitman, PR 20429)
  • Fix --strict-equality for iteratively visited code (Christoph Tyralla, PR 19635)
  • Allow literals as kwargs dict keys (Shantanu, PR 20416)
  • Error for invalid varargs and varkwargs to Any call (Shantanu, PR 20324)
  • Fix type inference for binary operators with tuple subclasses (Randolf Scholz, PR 19046)
  • Improve type inference for ternary expressions with literals and collections (Randolf Scholz, PR 19563)
  • Do not treat match value patterns as isinstance checks (Stanislav Terliakov, PR 20146)
  • Fix noncommutative joins with bounded TypeVars (Shantanu, PR 20345)
  • Fix error location reporting for **rest patterns in match statements (Marc Mueller, PR 20407)
  • Fix matching against union of tuples (Saul Shanabrook, PR 19600)
  • Allow types.NoneType in match cases (A5rocks, PR 20383)
  • Treat Literal["xyz"] as iterable (Shantanu, PR 20347)
  • Treat functions that return None as returning None (Shantanu, PR 20350)
  • Fix str unpack type propagation, use dedicated error code (Shantanu, PR 20325)
  • Unpack unions inside tuples in except handlers (asce, PR 17762)
  • Ignore empty error codes from type: ignore (Donghoon Nam, PR 20052)
  • Make NoneType annotation error use a new error code (wyattscarpenter, PR 20222)
  • Fail with an explicit error on PyPy (Ivan Levkivskyi, PR 20384)
  • Add hidden --overwrite-union-syntax option (Marc Mueller, PR 20332)
  • Fix possibly-undefined false-positive with nesting (grayjk, PR 20276)
  • Fix spurious possibly-undefined errors in for-else with break (Łukasz Langa, PR 19696)
  • Avoid false possibly-undefined errors due to omitted unrequired else statements (Christoph Tyralla, PR 20149)
  • Fix generator expression behavior for reveal_type (michaelm-openai, PR 20594)
  • Fix error on instance property and init-only variable with the same name in a dataclass (Roberto Fernández Iglesias, PR 17219)
  • Improve error messages when __module__ or __qualname__ are used as type annotations (A5rocks, PR 20288)
  • Check for multiple type var tuples for PEP 695 (A5rocks, PR 20289)
  • Improve interaction between --local-partial-types and hashability (Shantanu, PR 20719)
  • Stop looking for .gitignore at top level of working tree (Colin Watson, PR 20775)
  • Try fixing Cygwin build (Ivan Levkivskyi, PR 20830)
  • Fix daemon dependencies in diff-cache.py tool (Jukka Lehtosalo, PR 20837)
  • Support fixed-format cache in diff-cache.py tool (Jukka Lehtosalo, PR 20827)
  • Update convert-cache.py tool to work with fixed-format caches (Ivan Levkivskyi, PR 20761)
  • Write errors to a separate cache file (Ivan Levkivskyi, PR 21022)
  • Write ignored lines to cache meta (Ivan Levkivskyi, PR 20747)
  • Serialize raw errors in cache metas (Ivan Levkivskyi, PR 20372)
  • Include misc/{diff-cache,apply-cache-diff}.py in sdist (Michael R. Crusoe, PR 21096)

Typeshed updates

Please see git log for full list of standard library typeshed stub changes.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

  • A5rocks
  • Aaron Wieczorek
  • Adam Turner
  • Ali Hamdan
  • asce
  • BobTheBuidler
  • Brent Westbrook
  • Brian Schubert
  • bzoracler
  • Chris Burroughs
  • Christoph Tyralla
  • Colin Watson
  • Donghoon Nam
  • E. M. Bray
  • Emma Smith
  • Ethan Sarp
  • George Ogden
  • getzze
  • grayjk
  • Gregor Riepl
  • Ivan Levkivskyi
  • James Hilliard
  • James Le Cuirot
  • Jeremy Nimmer
  • Joren Hammudoglu
  • Kai (Kazuya Ito)
  • kaushal trivedi
  • Kevin Kannammalil
  • Lukas Geiger
  • Łukasz Langa
  • Marc Mueller
  • Michael R. Crusoe
  • michaelm-openai
  • Neil Schemenauer
  • Piotr Sawicki
  • Randolf Scholz
  • Roberto Fernández Iglesias
  • Saul Shanabrook
  • Shantanu Jain
  • Sjoerd Job Postmus
  • sobolevn
  • Stanislav Terliakov
  • Steven Pitman
  • Vaggelis Danias
  • Vikash Kumar
  • wyattscarpenter

I’d also like to thank my employer, Dropbox, for supporting mypy development.