|
2 | 2 |
|
3 | 3 | ## Next release
|
4 | 4 |
|
| 5 | +## Mypy 1.12 |
| 6 | + |
| 7 | +We’ve just uploaded mypy 1.12 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)). Mypy is a static type |
| 8 | +checker for Python. This release includes new features, performance improvements and bug fixes. |
| 9 | +You can install it as follows: |
| 10 | + |
| 11 | + python3 -m pip install -U mypy |
| 12 | + |
| 13 | +You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io). |
| 14 | + |
| 15 | +### Support Python 3.12 Syntax for Generics (PEP 695) |
| 16 | + |
| 17 | +Support for the new type parameter syntax introduced in 3.12 is now enabled by default. |
| 18 | + |
| 19 | +These improvements are included: |
| 20 | + |
| 21 | + * [PEP 695] Further documentation updates (Jukka Lehtosalo, PR [17826](https://github.com/python/mypy/pull/17826)) |
| 22 | + * [PEP 695] Document Python 3.12 type parameter syntax (Jukka Lehtosalo, PR [17816](https://github.com/python/mypy/pull/17816)) |
| 23 | + * [PEP 695] Allow Self return types with contravariance (Jukka Lehtosalo, PR [17786](https://github.com/python/mypy/pull/17786)) |
| 24 | + * [PEP 695] Enable new type parameter syntax by default (Jukka Lehtosalo, PR [17798](https://github.com/python/mypy/pull/17798)) |
| 25 | + * [PEP 695] Generate error if new-style type alias used as base class (Jukka Lehtosalo, PR [17789](https://github.com/python/mypy/pull/17789)) |
| 26 | + * [PEP 695] Inherit variance if base class has explicit variance (Jukka Lehtosalo, PR [17787](https://github.com/python/mypy/pull/17787)) |
| 27 | + * [PEP 695] Fix crash on invalid type var reference (Jukka Lehtosalo, PR [17788](https://github.com/python/mypy/pull/17788)) |
| 28 | + * [PEP 695] Fix covariance of frozen dataclasses (Jukka Lehtosalo, PR [17783](https://github.com/python/mypy/pull/17783)) |
| 29 | + * [PEP 695] Allow covariance with attribute that has "_" name prefix (Jukka Lehtosalo, PR [17782](https://github.com/python/mypy/pull/17782)) |
| 30 | + * [PEP 695] Support Annotated[...] in new-style type aliases (Jukka Lehtosalo, PR [17777](https://github.com/python/mypy/pull/17777)) |
| 31 | + * [PEP 695] Fix nested generic classes (Jukka Lehtosalo, PR [17776](https://github.com/python/mypy/pull/17776)) |
| 32 | + * PEP 695: Add detection and error reporting for the use of incorrect expressions within the scope of a type parameter and a type alias (Kirill Podoprigora, PR [17560](https://github.com/python/mypy/pull/17560)) |
| 33 | + |
| 34 | +### Basic Support for Python 3.13 |
| 35 | + |
| 36 | +This release adds compiled binaries for Python 3.13 and partial support for Python 3.13 |
| 37 | +features. Mypyc also now supports Python 3.13. |
| 38 | + |
| 39 | +These features are supported: |
| 40 | + * Various stdlib updates (through typeshed stub improvements) |
| 41 | + * `typing.ReadOnly` (see below for more) |
| 42 | + * `typing.TypeIs` (support was added in mypy 1.10) |
| 43 | + * Type parameter defaults when using the legacy syntax ([PEP 695](https://peps.python.org/pep-0696/)) |
| 44 | + |
| 45 | +These features are not supported yet: |
| 46 | + * `warnings.deprecated` ([PEP 702](https://peps.python.org/pep-0702/)) |
| 47 | + * Type parameter defaults when using Python 3.12 for type parameters |
| 48 | + |
| 49 | +### Mypyc Support for Python 3.13 |
| 50 | + |
| 51 | +Mypyc now supports Python 3.13. Full list of changes: |
| 52 | + |
| 53 | + * Add additional includes for Python 3.13 (Marc Mueller, PR [17506](https://github.com/python/mypy/pull/17506)) |
| 54 | + * Add another include for Python 3.13 (Marc Mueller, PR [17509](https://github.com/python/mypy/pull/17509)) |
| 55 | + * Fix ManagedDict functions for Python 3.13 (Marc Mueller, PR [17507](https://github.com/python/mypy/pull/17507)) |
| 56 | + * Update mypyc test output for Python 3.13 (Marc Mueller, PR [17508](https://github.com/python/mypy/pull/17508)) |
| 57 | + * Fix `PyUnicode` functions for Python 3.13 (Marc Mueller, PR [17504](https://github.com/python/mypy/pull/17504)) |
| 58 | + * Fix `_PyObject_LookupAttrId` for Python 3.13 (Marc Mueller, PR [17505](https://github.com/python/mypy/pull/17505)) |
| 59 | + * Fix `_PyList_Extend` for Python 3.13 (Marc Mueller, PR [17503](https://github.com/python/mypy/pull/17503)) |
| 60 | + * Fix `gen_is_coroutine` for Python 3.13 (Marc Mueller, PR [17501](https://github.com/python/mypy/pull/17501)) |
| 61 | + * Fix `_PyObject_FastCall` for Python 3.13 (Marc Mueller, PR [17502](https://github.com/python/mypy/pull/17502)) |
| 62 | + * Avoid uses of `_PyObject_CallMethodOneArg` on 3.13 (Jukka Lehtosalo, PR [17526](https://github.com/python/mypy/pull/17526)) |
| 63 | + * Don't rely on `_PyType_CalculateMetaclass` on 3.13 (Jukka Lehtosalo, PR [17525](https://github.com/python/mypy/pull/17525)) |
| 64 | + * Don't use `_PyUnicode_FastCopyCharacters` on 3.13 (Jukka Lehtosalo, PR [17524](https://github.com/python/mypy/pull/17524)) |
| 65 | + * Don't use `_PyUnicode_EQ` on 3.13, as it's no longer exported (Jukka Lehtosalo, PR [17523](https://github.com/python/mypy/pull/17523)) |
| 66 | + |
| 67 | +### ReadOnly support TypedDict |
| 68 | + |
| 69 | + * Add `ReadOnly` support for TypedDicts (sobolevn, PR [17644](https://github.com/python/mypy/pull/17644)) |
| 70 | + |
| 71 | +### Other Notables Fixes and Improvements |
| 72 | + |
| 73 | + * [PEP 696] Report error if using unsupported type parameter defaults (Jukka Lehtosalo, PR [17876](https://github.com/python/mypy/pull/17876)) |
| 74 | + * Fix re-processing cross-reference when node kind changes (Ivan Levkivskyi, PR [17883](https://github.com/python/mypy/pull/17883)) |
| 75 | + * Don't consider None vs IntEnum comparison ambiguous (Jukka Lehtosalo, PR [17877](https://github.com/python/mypy/pull/17877)) |
| 76 | + * Fix narrowing of IntEnum and StrEnum types (Jukka Lehtosalo, PR [17874](https://github.com/python/mypy/pull/17874)) |
| 77 | + * Filter overload items based on self type during type inference (Jukka Lehtosalo, PR [17873](https://github.com/python/mypy/pull/17873)) |
| 78 | + * Fix typos in .github/worflows/test.yml (Jukka Lehtosalo, PR [17867](https://github.com/python/mypy/pull/17867)) |
| 79 | + * Don't use equality to narrow when value is IntEnum/StrEnum (Jukka Lehtosalo, PR [17866](https://github.com/python/mypy/pull/17866)) |
| 80 | + * Revert "Narrow based on collection containment (#17344)" (Jukka Lehtosalo, PR [17865](https://github.com/python/mypy/pull/17865)) |
| 81 | + * .git-blame-ignore-revs: add #15059 and #16847 (Brian Schubert, PR [17862](https://github.com/python/mypy/pull/17862)) |
| 82 | + * Enable negative narrowing of Union TypeVar upper bounds (Brian Schubert, PR [17850](https://github.com/python/mypy/pull/17850)) |
| 83 | + * Fix tests on latest Python 3.13 (and 3.12) (Shantanu, PR [17849](https://github.com/python/mypy/pull/17849)) |
| 84 | + * Fix get_member_expr_fullname returning strings with embedded "None" (Brian Schubert, PR [17848](https://github.com/python/mypy/pull/17848)) |
| 85 | + * Avoid type size explosion when expanding types (Jukka Lehtosalo, PR [17842](https://github.com/python/mypy/pull/17842)) |
| 86 | + * Document `--output=json` CLI option (Edgar Ramírez Mondragón, PR [17611](https://github.com/python/mypy/pull/17611)) |
| 87 | + * Fix negative narrowing of tuples in match statement (Brian Schubert, PR [17817](https://github.com/python/mypy/pull/17817)) |
| 88 | + * Make "X | Y" union syntax more prominent in documentation (Jukka Lehtosalo, PR [17835](https://github.com/python/mypy/pull/17835)) |
| 89 | + * Update various references to deprecated type aliases in docs (Jukka Lehtosalo, PR [17829](https://github.com/python/mypy/pull/17829)) |
| 90 | + * Discuss upper bounds before self types in documentation (Jukka Lehtosalo, PR [17827](https://github.com/python/mypy/pull/17827)) |
| 91 | + * Narrow falsey str/bytes/int to literal type (Brian Schubert, PR [17818](https://github.com/python/mypy/pull/17818)) |
| 92 | + * Test against latest Python 3.13, make testing 3.14 easy (Shantanu, PR [17812](https://github.com/python/mypy/pull/17812)) |
| 93 | + * Reject ParamSpec-typed callables calls with insufficient arguments (Stanislav Terliakov, PR [17323](https://github.com/python/mypy/pull/17323)) |
| 94 | + * Copyedit final_attrs.rst (Michael I Chen, PR [17813](https://github.com/python/mypy/pull/17813)) |
| 95 | + * Fix crash when passing too many type arguments to generic base class accepting single ParamSpec (Brian Schubert, PR [17770](https://github.com/python/mypy/pull/17770)) |
| 96 | + * Fix TypeVar upper bounds sometimes not being displayed in pretty callables (Brian Schubert, PR [17802](https://github.com/python/mypy/pull/17802)) |
| 97 | + * Added error code for overlapping function signatures (Katrina Connors, PR [17597](https://github.com/python/mypy/pull/17597)) |
| 98 | + * Check for `truthy-bool` in `not ...` unary expressions (sobolevn, PR [17773](https://github.com/python/mypy/pull/17773)) |
| 99 | + * Add missing lines-covered and lines-valid attributes (Soubhik Kumar Mitra, PR [17738](https://github.com/python/mypy/pull/17738)) |
| 100 | + * Make changelog visible in mypy documentation (quinn-sasha, PR [17742](https://github.com/python/mypy/pull/17742)) |
| 101 | + * stubgen: Use `Generator` type var defaults (Sebastian Rittau, PR [17670](https://github.com/python/mypy/pull/17670)) |
| 102 | + * Use newer Python in docs build (Shantanu, PR [17747](https://github.com/python/mypy/pull/17747)) |
| 103 | + * [nit] conf.py: annotate the type, instead of ignoring the error (wyattscarpenter, PR [17727](https://github.com/python/mypy/pull/17727)) |
| 104 | + * Fix another crash scenario on recursive tuple types (Ivan Levkivskyi, PR [17708](https://github.com/python/mypy/pull/17708)) |
| 105 | + * Add optional stderr result to `run_stubtest` in tests (sobolevn, PR [17636](https://github.com/python/mypy/pull/17636)) |
| 106 | + * [stubgen] Fix crash on literal class-level keywords (sobolevn, PR [17663](https://github.com/python/mypy/pull/17663)) |
| 107 | + * Stubgen add `--version` (sobolevn, PR [17662](https://github.com/python/mypy/pull/17662)) |
| 108 | + * stubtest: Add support for cached_property (Ali Hamdan, PR [17626](https://github.com/python/mypy/pull/17626)) |
| 109 | + * Resolve TypeVar upper bounds in functools.partial (Shantanu, PR [17660](https://github.com/python/mypy/pull/17660)) |
| 110 | + * Add `enable_incomplete_feature` validation to `stubtest` (sobolevn, PR [17635](https://github.com/python/mypy/pull/17635)) |
| 111 | + * Fix typo in error_code_list.rst (sobolevn, PR [17645](https://github.com/python/mypy/pull/17645)) |
| 112 | + * Always reset binder when checking deferred nodes (Ivan Levkivskyi, PR [17643](https://github.com/python/mypy/pull/17643)) |
| 113 | + * Fix crash on a callable attribute with single unpack (Ivan Levkivskyi, PR [17641](https://github.com/python/mypy/pull/17641)) |
| 114 | + * List all incomplete features in `--enable-incomplete-feature` docs (sobolevn, PR [17633](https://github.com/python/mypy/pull/17633)) |
| 115 | + * Fix `stubgen --no-analysis/--parse-only` docs (sobolevn, PR [17632](https://github.com/python/mypy/pull/17632)) |
| 116 | + * Fix error code handling in `stubtest` with `--mypy-config-file` (sobolevn, PR [17629](https://github.com/python/mypy/pull/17629)) |
| 117 | + * fix: Mismatched signature between checker plugin API and implementation (bzoracler, PR [17343](https://github.com/python/mypy/pull/17343)) |
| 118 | + * Narrow based on collection containment (Jordandev678, PR [17344](https://github.com/python/mypy/pull/17344)) |
| 119 | + * Remove the explicit setting of a pygments theme (Pradyun Gedam, PR [17571](https://github.com/python/mypy/pull/17571)) |
| 120 | + * Bump setuptools from 68.2.2 to 70.0.0 (dependabot[bot], PR [17533](https://github.com/python/mypy/pull/17533)) |
| 121 | + * Indexing a type also produces a GenericAlias (Shantanu, PR [17546](https://github.com/python/mypy/pull/17546)) |
| 122 | + * Experimental: allow inline/anonymous TypedDicts (Ivan Levkivskyi, PR [17457](https://github.com/python/mypy/pull/17457)) |
| 123 | + * Fix crash on self-type in callable protocol (Ivan Levkivskyi, PR [17499](https://github.com/python/mypy/pull/17499)) |
| 124 | + * Fix crash on NamedTuple with method and error in function (Ivan Levkivskyi, PR [17498](https://github.com/python/mypy/pull/17498)) |
| 125 | + * Fix cross-variable type-narrowing example (InSync, PR [17488](https://github.com/python/mypy/pull/17488)) |
| 126 | + * Run Python 3.13 tests in CI (with failures allowed) (Shantanu, PR [17484](https://github.com/python/mypy/pull/17484)) |
| 127 | + * Revert "Have namedtuple `__replace__` return `Self`" (Ivan Levkivskyi, PR [17496](https://github.com/python/mypy/pull/17496)) |
| 128 | + * Refactor: remove temporary `def` from `semanal_classprop.check_protocol_status` (sobolevn, PR [17486](https://github.com/python/mypy/pull/17486)) |
| 129 | + * Have namedtuple `__replace__` return `Self` (Max Muoto, PR [17475](https://github.com/python/mypy/pull/17475)) |
| 130 | + * Add `__replace__` for dataclasses in 3.13 (Max Muoto, PR [17469](https://github.com/python/mypy/pull/17469)) |
| 131 | + * Fix help message for --no-namespace-packages. (Raphael Krupinski, PR [17472](https://github.com/python/mypy/pull/17472)) |
| 132 | + * Infer unions for ternary expressions (Ivan Levkivskyi, PR [17427](https://github.com/python/mypy/pull/17427)) |
| 133 | + * Use Python 3.12 for mypy_primer (Shantanu, PR [17456](https://github.com/python/mypy/pull/17456)) |
| 134 | + * Fix typechecking for async generators (Danny Yang, PR [17452](https://github.com/python/mypy/pull/17452)) |
| 135 | + * Fix strict optional handling in attrs plugin (Ivan Levkivskyi, PR [17451](https://github.com/python/mypy/pull/17451)) |
| 136 | + * Include keyword only args when generating signatures in stubgenc (Eric Mark Martin, PR [17448](https://github.com/python/mypy/pull/17448)) |
| 137 | + * Add Literal support for docstrings (Michael Carlstrom, PR [17441](https://github.com/python/mypy/pull/17441)) |
| 138 | + * Allow mixing ParamSpec and TypeVarTuple in Generic (Ivan Levkivskyi, PR [17450](https://github.com/python/mypy/pull/17450)) |
| 139 | + * Fix typo in `error_code_list2.rst` (InSync, PR [17443](https://github.com/python/mypy/pull/17443)) |
| 140 | + |
| 141 | +### Typeshed Updates |
| 142 | + |
| 143 | +Please see [git log](https://github.com/python/typeshed/commits/main?after=91a58b07cdd807b1d965e04ba85af2adab8bf924+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes. |
| 144 | + |
| 145 | +### Acknowledgements |
| 146 | +Thanks to all mypy contributors who contributed to this release: |
| 147 | + |
| 148 | +- TODO |
| 149 | + |
| 150 | +I’d also like to thank my employer, Dropbox, for supporting mypy development. |
| 151 | + |
5 | 152 |
|
6 | 153 | ## Mypy 1.11
|
7 | 154 |
|
|
0 commit comments