{"id":497156,"date":"2026-10-02T15:54:50","date_gmt":"2026-10-02T15:54:50","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=497156"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=497156","title":{"rendered":"Typing \u0432 Python 3.11\u20133.14: \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042f \u0447\u0438\u0442\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Python \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0433\u0434\u0435 \u0435\u044e \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435\u0440\u044c\u0451\u0437, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0433\u0430\u043b\u043e\u0447\u043a\u0438. \u041f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435 \u043d\u043e\u0432\u0435\u0435 3.11: <code>Optional<\/code>, <code>TypeVar<\/code> \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0443\u043b\u044f, <code>Generic[T]<\/code>, \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443 Python 3.10 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043a\u0442\u044f\u0431\u0440\u0435 2026 \u0433\u043e\u0434\u0430 [1], \u0438 \u0447\u0430\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0433\u043e \u043d\u0438\u0436\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440.<\/p>\n<p>\u0417\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043b\u0438\u0437\u043e\u0432 \u0432 typing \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e: \u0432 3.11 \u2014 <code>Self<\/code> \u0438 <code>Required<\/code>\/<code>NotRequired<\/code>, \u0432 3.12 \u2014 \u0441\u0432\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f generic-\u0442\u0438\u043f\u043e\u0432 \u0438 \u0430\u043b\u0438\u0430\u0441\u043e\u0432, \u0432 3.13 \u2014 <code>TypeIs<\/code> \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430, \u0432 3.14 \u2014 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a. \u0414\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0433\u0434\u0435 \u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0438 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Python.<\/p>\n<blockquote>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u043d\u0430 CPython 3.10.20, 3.11.15, 3.12.13, 3.13.14 \u0438 3.14.2. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0435\u043b\u0430\u043b mypy 2.3.1, ty 0.0.78 \u0438 pyright 1.1.414, \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u043c \u0431\u044b\u043b Ruff 0.15.22. \u0422\u0435\u0440\u043c\u0438\u043d\u044b: \u00ab\u0440\u0430\u043d\u0442\u0430\u0439\u043c\u00bb \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440, \u00abchecker\u00bb \u044d\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u0440\u043e\u0434\u0435 mypy. \u041c\u043d\u043e\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f checker\u2019\u0430, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438\u0445 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0438 \u044f \u0431\u0443\u0434\u0443 \u043d\u0430 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c.<\/p>\n<\/blockquote>\n<h2>\u0413\u043b\u0430\u0432\u043d\u043e\u0435: \u0447\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0449\u0435<\/h2>\n<p>\u0421\u0432\u043e\u0434\u043a\u0430 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u044f\u043c, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0438\u0436\u0435.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0427\u0442\u043e<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u0430\u043a \u0431\u044b\u043b\u043e<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u0430\u043a \u0441\u0442\u0430\u043b\u043e<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0421 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>TypeVar(bound=...)<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>Self<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.11<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0427\u0430\u0441\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0439 <code>TypedDict<\/code> \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>total=False<\/code> \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>Required<\/code>\/<code>NotRequired<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.11<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Generic-\u043a\u043b\u0430\u0441\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>T = TypeVar(\"T\")<\/code> \u0438 <code>Generic[T]<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>class Stack[T]<\/code>, <code>def first[T]<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.12<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0410\u043b\u0438\u0430\u0441 \u0442\u0438\u043f\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>X: TypeAlias = \"...\"<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>type X = ...<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.12<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>TypeVar(\"T_co\", covariant=True)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.12<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>@override<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.12<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0442\u0438\u043f\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>TypeVar(default=...)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>class Box[T = int]<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>TypeGuard<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>TypeIs<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041a\u043b\u044e\u0447\u0438 <code>TypedDict<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>ReadOnly[...]<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">3.13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0438\u043b\u0438 <code>from __future__ import annotations<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.14<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>Self \u0432\u043c\u0435\u0441\u0442\u043e TypeVar(bound=\u2026) (3.11)<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u043d\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e, \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b <code>TypeVar<\/code>, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 <code>bound<\/code>:<\/p>\n<pre><code class=\"python\">from typing import TypeVarTAnimal = TypeVar(\"TAnimal\", bound=\"Animal\")class Animal:    @classmethod    def create(cls: type[TAnimal]) -&gt; TAnimal:        return cls()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u0421 3.11 (PEP 673 [8]) \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c <code>Self<\/code>, \u0431\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"python\">from typing import Self, reveal_typeclass Animal:    @classmethod    def create(cls) -&gt; Self:        return cls()    def clone(self) -&gt; Self:        return type(self)()class Dog(Animal):    passreveal_type(Dog.create())reveal_type(Dog().clone())<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u044f\u0442 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441, \u0430 \u043d\u0435 <code>Animal<\/code>, \u043d\u043e <code>Self<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 (<code>clone<\/code>), \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c <code>TypeVar<\/code> \u0437\u0430\u043d\u043e\u0432\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u2014 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, <code>clone<\/code>, <code>__enter__<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <code>self<\/code>:<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:14: note: Revealed type is \"example.Dog\"example.py:15: note: Revealed type is \"example.Dog\"Success: no issues found in 1 source file$ ty check example.pyinfo[revealed-type]: Revealed type  --&gt; example.py:14:13   |14 | reveal_type(Dog.create())   |             ^^^^^^^^^^^^ `Dog`info[revealed-type]: Revealed type  --&gt; example.py:15:13   |15 | reveal_type(Dog().clone())   |             ^^^^^^^^^^^^^ `Dog`Found 2 diagnostics$ pyright example.pyexample.py:14:13 - information: Type of \"Dog.create()\" is \"Dog\"example.py:15:13 - information: Type of \"Dog().clone()\" is \"Dog\"0 errors, 0 warnings, 2 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>Required \u0438 NotRequired (3.11)<\/h3>\n<p>\u0414\u043e 3.11 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0439 <code>TypedDict<\/code> \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">from typing import TypedDictclass _MovieBase(TypedDict):    title: strclass Movie(_MovieBase, total=False):    year: int<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421 3.11 (PEP 655 [9]) \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435:<\/p>\n<pre><code class=\"python\">from typing import NotRequired, TypedDictclass Movie(TypedDict):    title: str    year: NotRequired[int]def f(m: Movie) -&gt; None:    m[\"title\"]f({})<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>year<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d, \u0430 <code>title<\/code> \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c; <code>f({})<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>f<\/code> \u0441 \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c, \u0433\u0434\u0435 <code>title<\/code> \u043d\u0435\u0442, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:10: error: Missing key \"title\" for TypedDict \"Movie\"  [typeddict-item]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-argument-type]: Argument to function `f` is incorrect  --&gt; example.py:10:3   |10 | f({})   |   ^^ Expected `Movie`, found `dict[Unknown, Unknown]`info: Function defined here --&gt; example.py:7:5  |7 | def f(m: Movie) -&gt; None:  |     ^ -------- Parameter declared hereerror[missing-typed-dict-key]: Missing required key 'title' in TypedDict `Movie` constructor  --&gt; example.py:10:3   |10 | f({})   |   ^^Found 2 diagnostics$ pyright example.pyexample.py:10:3 - error: Argument of type \"dict[Any, Any]\" cannot be assigned to parameter \"m\" of type \"Movie\" in function \"f\"    \"title\" is required in \"Movie\" (reportArgumentType)1 error, 0 warnings, 0 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>Generic \u0431\u0435\u0437 TypeVar (3.12)<\/h3>\n<p>\u0414\u043e 3.12 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438 <code>Generic<\/code> \u0432 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"python\">from typing import Generic, TypeVarT = TypeVar(\"T\")class Stack(Generic[T]):    def __init__(self) -&gt; None:        self._items: list[T] = []    def push(self, item: T) -&gt; None:        self._items.append(item)    def pop(self) -&gt; T:        return self._items.pop()def first(items: list[T]) -&gt; T:    return items[0]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421 3.12 (PEP 695 [2]) \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435:<\/p>\n<pre><code class=\"python\">class Stack[T]:    def __init__(self) -&gt; None:        self._items: list[T] = []    def push(self, item: T) -&gt; None:        self._items.append(item)    def pop(self) -&gt; T:        return self._items.pop()def first[T](items: list[T]) -&gt; T:    return items[0]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0418\u043c\u044f <code>T<\/code> \u0436\u0438\u0432\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u043e\u043d\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442. \u041e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 <code>T<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0418 <code>bound<\/code>, \u0438 <code>constraints<\/code> \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e: <code>def f[T: Hashable](x: T)<\/code>, <code>def g[T: (int, str)](x: T)<\/code>. \u0414\u043b\u044f <code>ParamSpec<\/code> \u0438 <code>TypeVarTuple<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f <code>**P<\/code> \u0438 <code>*Ts<\/code>. \u0421\u0430\u043c\u0438 <code>TypeVarTuple<\/code> \u0438 <code>Unpack<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u0432 3.11 (PEP 646 [10]) \u2014 \u0434\u043e 3.12 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 generic \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u043a <code>Generic[*Ts]<\/code>, \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043b\u0438\u0448\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<h3>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 type (3.12)<\/h3>\n<p>\u0410\u043b\u0438\u0430\u0441\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0447\u0435\u0440\u0435\u0437 <code>TypeAlias<\/code>, \u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0438\u0430\u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0439:<\/p>\n<pre><code class=\"python\">from typing import TypeAliasJson: TypeAlias = \"dict[str, Json] | list[Json] | str | int | float | bool | None\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>type<\/code>:<\/p>\n<pre><code class=\"python\">type Json = dict[str, Json] | list[Json] | str | int | float | bool | None<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0435\u0451 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u043b\u0438\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f \u0438\u043b\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435, \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a. \u0410\u043b\u0438\u0430\u0441\u044b \u0431\u044b\u0432\u0430\u044e\u0442 generic: <code>type Pair[T] = tuple[T, T]<\/code>.<\/p>\n<p><code>TypeAlias<\/code> \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c, \u043d\u043e \u0441\u0440\u043e\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d [3].<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (3.12)<\/h3>\n<p>\u0414\u043b\u044f \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0430\u043c\u043e\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 PEP 695. \u0420\u0430\u043d\u044c\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">T_co = TypeVar(\"T_co\", covariant=True)class ReadOnlyBox(Generic[T_co]):    def __init__(self, item: T_co) -&gt; None:        self._item = item    def get(self) -&gt; T_co:        return self._item<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c checker \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435:<\/p>\n<pre><code class=\"python\">class ReadOnlyBox[T]:    def __init__(self, item: T) -&gt; None:        self._item = item    def get(self) -&gt; T:        return self._itemclass MutableBox[T]:    def __init__(self, item: T) -&gt; None:        self.item = itemdef show(box: ReadOnlyBox[int]) -&gt; None: ...def edit(box: MutableBox[int]) -&gt; None: ...ro: ReadOnlyBox[bool] = ReadOnlyBox(True)mu: MutableBox[bool] = MutableBox(True)show(ro)  # bool \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c int, \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430edit(mu)  # \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0433\u043b\u0430\u0448\u0430\u044e\u0442\u0441\u044f: <code>show(ro)<\/code> \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u043e\u043b\u0447\u0430, \u0430 \u043d\u0430 <code>edit(mu)<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 <code>MutableBox[bool]<\/code> \u0438 <code>MutableBox[int]<\/code> \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b.<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:22: error: Argument 1 to \"edit\" has incompatible type \"MutableBox[bool]\"; expected \"MutableBox[int]\"  [arg-type]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-argument-type]: Argument to function `edit` is incorrect  --&gt; example.py:22:6   |22 | edit(mu)  # \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d   |      ^^ Expected `MutableBox[int]`, found `MutableBox[bool]`info: `MutableBox` is invariant in its type parameterFound 1 diagnostic$ pyright example.pyexample.py:22:6 - error: Argument of type \"MutableBox[bool]\" cannot be assigned to parameter \"box\" of type \"MutableBox[int]\" in function \"edit\"    \"MutableBox[bool]\" is not assignable to \"MutableBox[int]\"      Type parameter \"T@MutableBox\" is invariant, but \"bool\" is not the same as \"int\" (reportArgumentType)1 error, 0 warnings, 0 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>@override (3.12)<\/h3>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>typing.override<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 checker\u2019\u0443, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u044f\u0437\u0430\u043d \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u2014 \u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>__override__<\/code>, \u0430 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e. \u041e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e checker:<\/p>\n<pre><code class=\"python\">from typing import overrideclass Base:    def run(self) -&gt; None: ...class Child(Base):    @override    def runn(self) -&gt; None: ...  # \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430, \u043e\u0448\u0438\u0431\u043a\u0430 checker'\u0430<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:8: error: Method \"runn\" is marked as an override, but no base method was found with this name  [misc]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-explicit-override]: Method `runn` is decorated with `@override` but does not override anything --&gt; example.py:8:9  |7 |     @override  |     ---------8 |     def runn(self) -&gt; None: ...  |         ^^^^info: No `runn` definitions were found on any superclasses of `Child`Found 1 diagnostic$ pyright example.pyexample.py:8:9 - error: Method \"runn\" is marked as override, but no base method of same name is present (reportGeneralTypeIssues)1 error, 0 warnings, 0 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (3.13)<\/h3>\n<p>\u0423 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (PEP 696). \u0414\u043e 3.13 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>default<\/code> \u0432 <code>typing.TypeVar<\/code> \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b. \u0412 3.13 \u043e\u043d \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u043f\u0440\u0438\u0448\u0451\u043b \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code class=\"python\">from typing import reveal_typeclass Box[T = int]:    def __init__(self, item: T | None = None) -&gt; None:        self.item = itemdef f(b: Box, c: Box[str]) -&gt; None:    reveal_type(b)  # Box[int], \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b default    reveal_type(c)  # Box[str]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0413\u043e\u043b\u043e\u0435 <code>Box<\/code> \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <code>Box[int]<\/code>, \u0430 \u043d\u0435 <code>Box[Any]<\/code>, \u0438 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u0438\u0434\u044f\u0442 \u044d\u0442\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e:<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:8: note: Revealed type is \"example.Box[int]\"example.py:9: note: Revealed type is \"example.Box[str]\"Success: no issues found in 1 source file$ ty check example.pyinfo[revealed-type]: Revealed type --&gt; example.py:8:17  |8 |     reveal_type(b)  |                 ^ `Box[int]`info[revealed-type]: Revealed type --&gt; example.py:9:17  |9 |     reveal_type(c)  |                 ^ `Box[str]`Found 2 diagnostics$ pyright example.pyexample.py:8:17 - information: Type of \"b\" is \"Box[int]\"example.py:9:17 - information: Type of \"c\" is \"Box[str]\"0 errors, 0 warnings, 2 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<blockquote>\n<p>\u0412 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043b\u0435\u0436\u0438\u0442 \u0432 <code>Box.__type_params__[0].__default__<\/code>.<\/p>\n<\/blockquote>\n<h3>TypeIs (3.13)<\/h3>\n<p><code>TypeGuard<\/code> \u0441\u0443\u0436\u0430\u0435\u0442 \u0442\u0438\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0432\u0435\u0442\u043a\u0435 <code>if<\/code>, \u0432 <code>else<\/code> checker \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442. <code>TypeIs<\/code> \u0441\u0443\u0436\u0430\u0435\u0442 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b:<\/p>\n<pre><code class=\"python\">from typing import TypeGuard, TypeIs, reveal_typedef is_int(value: int | str) -&gt; TypeIs[int]:    return isinstance(value, int)def is_int_guard(value: int | str) -&gt; TypeGuard[int]:    return isinstance(value, int)def check_type_is(x: str | int) -&gt; None:    if is_int(x):        reveal_type(x)  # int    else:        reveal_type(x)  # str, TypeIs \u0441\u0443\u0437\u0438\u043b \u0438 elsedef check_type_guard(y: str | int) -&gt; None:    if is_int_guard(y):        reveal_type(y)  # int    else:        reveal_type(y)  # str | int, TypeGuard else \u043d\u0435 \u0441\u0443\u0436\u0430\u0435\u0442<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u0438\u0434\u044f\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435: <code>TypeIs<\/code> \u0441\u0443\u0436\u0430\u0435\u0442 \u0442\u0438\u043f \u0438 \u0432 <code>if<\/code>, \u0438 \u0432 <code>else<\/code>, <code>TypeGuard<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 <code>if<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:11: note: Revealed type is \"int\"example.py:13: note: Revealed type is \"str\"example.py:17: note: Revealed type is \"int\"example.py:19: note: Revealed type is \"str | int\"Success: no issues found in 1 source file$ ty check example.pyinfo[revealed-type]: Revealed type  --&gt; example.py:11:21   |11 |         reveal_type(x)  # int   |                     ^ `int`info[revealed-type]: Revealed type  --&gt; example.py:13:21   |13 |         reveal_type(x)  # str, TypeIs \u0441\u0443\u0437\u0438\u043b \u0438 else   |                     ^ `str`info[revealed-type]: Revealed type  --&gt; example.py:17:21   |17 |         reveal_type(y)  # int   |                     ^ `int`info[revealed-type]: Revealed type  --&gt; example.py:19:21   |19 |         reveal_type(y)  # str | int, TypeGuard else \u043d\u0435 \u0441\u0443\u0436\u0430\u0435\u0442   |                     ^ `str | int`Found 4 diagnostics$ pyright example.pyexample.py:11:21 - information: Type of \"x\" is \"int\"example.py:13:21 - information: Type of \"x\" is \"str\"example.py:17:21 - information: Type of \"y\" is \"int\"example.py:19:21 - information: Type of \"y\" is \"str | int\"0 errors, 0 warnings, 4 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0438\u0434\u0430 \u00ab\u044d\u0442\u043e <code>str<\/code>?\u00bb <code>TypeIs<\/code> \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<h3>ReadOnly (3.13)<\/h3>\n<p><code>ReadOnly<\/code> \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u043a\u043b\u044e\u0447 <code>TypedDict<\/code> \u043a\u0430\u043a \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439:<\/p>\n<pre><code class=\"python\">from typing import ReadOnly, TypedDictclass Movie(TypedDict):    title: ReadOnly[str]    year: intm: Movie = {\"title\": \"Alien\", \"year\": 1979}m[\"year\"] = 1980       # \u043c\u043e\u0436\u043d\u043e, year \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447m[\"title\"] = \"Aliens\"  # \u043d\u0435\u043b\u044c\u0437\u044f, ReadOnly \u2014 \u043e\u0448\u0438\u0431\u043a\u0430 checker'\u0430 (\u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u043d\u0442\u0430\u0439\u043c)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043b\u043e\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u2014 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 <code>title<\/code>, \u0438 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0435\u0451:<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:9: error: ReadOnly TypedDict key \"title\" TypedDict is mutated  [typeddict-readonly-mutated]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-assignment]: Cannot assign to key \"title\" on TypedDict `Movie` --&gt; example.py:9:3  |9 | m[\"title\"] = \"Aliens\"  | - ^^^^^^^ key is marked read-only  | |  | TypedDict `Movie`info: Item declaration --&gt; example.py:4:5  |4 |     title: ReadOnly[str]  |     -------------------- Read-only item declared hereFound 1 diagnostic$ pyright example.pyexample.py:9:1 - error: Could not assign item in TypedDict    \"title\" is a read-only key in \"Movie\" (reportTypedDictNotRequiredAccess)1 error, 0 warnings, 0 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>\u0411\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a (3.14)<\/h3>\n<p>\u0412 3.14 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 (PEP 649 \u0438 749 [4]). \u0417\u043d\u0430\u0447\u0438\u0442, \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b:<\/p>\n<pre><code class=\"python\">class Node:    def link(self, other: Node) -&gt; Node:        return other<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 \u0438\u043c\u0451\u043d, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 <code>if TYPE_CHECKING:<\/code>, \u043f\u043e\u043a\u0430 \u043d\u0438\u043a\u0442\u043e \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u0442. \u041f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0442\u0430\u0435\u0442, \u043d\u0438\u0436\u0435.<\/p>\n<h2>\u041d\u044e\u0430\u043d\u0441\u044b<\/h2>\n<h3>type-\u0430\u043b\u0438\u0430\u0441 \u043d\u0435 \u043a\u043b\u0430\u0441\u0441<\/h3>\n<p>\u0410\u043b\u0438\u0430\u0441, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 <code>type<\/code>, \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <code>typing.TypeAliasType<\/code>, \u0430 \u043d\u0435 \u0441\u0430\u043c \u0442\u0438\u043f. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <code>isinstance<\/code> \u0441 \u043d\u0438\u043c \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"python\">type Json = dict[str, Json] | list[Json] | str | int | float | bool | Noneisinstance({}, Json)# TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>Json.__value__<\/code>. \u0415\u0441\u043b\u0438 \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0442\u0438\u043f\u044b \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0447\u0435\u0440\u0435\u0437 \u0430\u043b\u0438\u0430\u0441, \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>Json = dict | list | str | ...<\/code> \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 Ruff UP040, UP046 \u0438 UP047 \u0443\u043c\u0435\u044e\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432 \u043d\u043e\u0432\u044b\u0439, \u043d\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u043d\u0438 \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442 \u043a\u0430\u043a \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 [5], \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u044e\u0430\u043d\u0441\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443. \u042f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043d\u0430 \u0446\u0435\u043b\u0438 py312. \u0411\u0435\u0437 <code>--unsafe-fixes<\/code> Ruff \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f\u0445. \u0421 \u0444\u043b\u0430\u0433\u043e\u043c \u043e\u043d \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b <code>Json: TypeAlias = \"dict[str, Json] | ...\"<\/code> \u0432 <code>type Json = \"dict[str, Json] | ...\"<\/code> \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u0430 \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0430, \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0432\u0442\u043e\u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0433\u043b\u0430\u0437\u0430\u043c\u0438.<\/p>\n<h3>\u041d\u043e\u0432\u044b\u0439 \u0438 \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f<\/h3>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <code>Generic[T]<\/code>:<\/p>\n<pre><code class=\"python\">class A[U](Generic[T]): ...# TypeError: Cannot inherit from Generic[...] multiple times.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0441\u0442\u043e\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u0418\u043d\u0430\u0447\u0435 \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">class B[T = int, U]: ...# SyntaxError: non-default type parameter 'U' follows default type parameter<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u043a\u043e\u0434\u0435<\/h3>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u0438\u0434\u043d\u0430 \u0432 \u0438\u043c\u0435\u043d\u0438 <code>T_co<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 <code>ReadOnlyBox<\/code> \u043c\u0435\u0442\u043e\u0434 <code>set<\/code>, \u0438 \u043e\u043d \u0442\u0438\u0445\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u044b\u043c, \u0430 \u043a\u043e\u0434, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0432\u0448\u0438\u0439 <code>ReadOnlyBox[bool]<\/code> \u043a\u0430\u043a <code>ReadOnlyBox[int]<\/code>, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u0412 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u043c API \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0437\u0430 \u044d\u0442\u0438\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u043e\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439, \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u0439 <code>TypeVar<\/code> \u0441 \u044f\u0432\u043d\u044b\u043c <code>covariant=True<\/code>.<\/p>\n<p>\u0412 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442. \u0423 <code>Box.__type_params__[0]<\/code> <code>__infer_variance__<\/code> \u0440\u0430\u0432\u0435\u043d <code>True<\/code>, \u0430 <code>__covariant__<\/code> \u0438 <code>__contravariant__<\/code> \u0440\u0430\u0432\u043d\u044b <code>False<\/code>. \u0412\u044b\u0432\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e checker.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0438 \u043c\u0435\u043d\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0430\u043c, \u043d\u043e \u0438 \u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438 generic-\u0442\u0438\u043f\u0430 \u043f\u043e\u043b\u044f, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <code>T<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435. <code>list<\/code> \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d \u2014 \u0432 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c, \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>T<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>list[T]<\/code> \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u0442. <code>Sequence<\/code>, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043d\u0435\u043c\u0443\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, \u0442\u0430\u043a \u0447\u0442\u043e <code>T<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>Sequence[T]<\/code> \u0442\u043e\u0436\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u044b\u043c:<\/p>\n<pre><code class=\"python\">from collections.abc import Sequenceclass ListBox[T]:    def __init__(self, items: list[T]) -&gt; None:        self._items = itemsclass SeqBox[T]:    def __init__(self, items: Sequence[T]) -&gt; None:        self._items = itemslb: ListBox[bool] = ListBox([True, False])sb: SeqBox[bool] = SeqBox([True, False])lb2: ListBox[int] = lb  # error: list[T] \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, ListBox[bool] != ListBox[int]sb2: SeqBox[int] = sb   # OK: Sequence[T] \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, bool \u2014 \u043f\u043e\u0434\u0442\u0438\u043f int<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0423 <code>ListBox<\/code> \u0438 <code>SeqBox<\/code> \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u043e\u0435: <code>ListBox<\/code> \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, <code>SeqBox<\/code> \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, \u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432 \u0442\u0438\u043f\u0435 \u043f\u043e\u043b\u044f, \u0430 \u043d\u0435 \u0432 \u0442\u0435\u043b\u0435 <code>__init__<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">$ mypy example.pyexample.py:17: error: Incompatible types in assignment (expression has type \"ListBox[bool]\", variable has type \"ListBox[int]\")  [assignment]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-assignment]: Object of type `ListBox[bool]` is not assignable to `ListBox[int]`  --&gt; example.py:17:21   |17 | lb2: ListBox[int] = lb  # error: list[T] \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d, ListBox[bool] != ListBox[int]   |      ------------   ^^ Incompatible value of type `ListBox[bool]`   |      |   |      Declared typeinfo: `ListBox` is invariant in its type parameterFound 1 diagnostic$ pyright example.pyexample.py:17:21 - error: Type \"ListBox[bool]\" is not assignable to declared type \"ListBox[int]\"    \"ListBox[bool]\" is not assignable to \"ListBox[int]\"      Type parameter \"T@ListBox\" is invariant, but \"bool\" is not the same as \"int\" (reportAssignmentType)1 error, 0 warnings, 0 informations<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435: \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0442\u0438\u043f\u0430 <code>list[T]<\/code> \u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u044b\u043c \u043f\u043e <code>T<\/code>, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u043a\u043b\u0430\u0441\u0441 \u043d\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b read-only \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u2014 \u0441\u0430\u043c <code>list<\/code> \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0430\u0451\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0443\u0436\u043d\u0430 \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0441\u0442\u043e\u0438\u0442 \u0441\u0443\u0437\u0438\u0442\u044c \u0434\u043e <code>Sequence[T]<\/code> \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e generic-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c <code>list[T]<\/code>.<\/p>\n<h3>TypeIs \u0441\u0442\u0440\u043e\u0436\u0435 TypeGuard<\/h3>\n<p><code>TypeIs<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0431\u044b\u043b \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c \u0442\u0438\u043f\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"python\">def bad(x: int) -&gt; TypeIs[str]:    return isinstance(x, str)# error: Narrowed type \"str\" is not a subtype of input type \"int\"  [narrowed-type-not-subtype]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>list[object]<\/code> \u043d\u0430 <code>list[str]<\/code>), \u043d\u0443\u0436\u0435\u043d <code>TypeGuard<\/code>. \u041e\u043d \u0441\u0443\u0436\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e <code>else<\/code>.<\/p>\n<h3>reveal_type \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439<\/h3>\n<p><code>reveal_type<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432\u044b\u0448\u0435, \u0432\u043e\u0448\u0451\u043b \u0432 <code>typing<\/code> \u0442\u043e\u0436\u0435 \u0432 3.11. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u0438\u043c\u044f \u0431\u044b\u043b\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435\u043c: mypy \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043b \u0432\u044b\u0437\u043e\u0432 <code>reveal_type(x)<\/code> \u043a\u0430\u043a \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0438\u043c\u043f\u043e\u0440\u0442\u0430, \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u043b \u0442\u0438\u043f \u0432 \u0441\u0432\u043e\u0439 \u0432\u044b\u0432\u043e\u0434. \u041d\u0430 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e:<\/p>\n<pre><code class=\"python\">x = 1reveal_type(x)  # \u0431\u0435\u0437 \u0438\u043c\u043f\u043e\u0440\u0442\u0430<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>mypy<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0438\u0448\u0435\u0442 <code>Revealed type is \"int\"<\/code>, \u043d\u043e \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 <code>NameError: name 'reveal_type' is not defined<\/code> \u2014 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Python, \u0432\u043a\u043b\u044e\u0447\u0430\u044f 3.11. \u0421 3.11 <code>from typing import reveal_type<\/code> \u0434\u0430\u0451\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e: \u043e\u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0442\u0438\u043f \u0432 stderr \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043e\u0434\u0435, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u0437\u043e\u0432\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<h3>ReadOnly \u0438 override \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435<\/h3>\n<p><code>ReadOnly<\/code> \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 <code>m[\"title\"] = \"Aliens\"<\/code> \u043d\u0430 3.13 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 <code>Movie.__readonly_keys__<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <code>title<\/code>. <code>@override<\/code> \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u2014 \u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>__override__<\/code> \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0435\u043c\u0443 \u0432\u0435\u0440\u0438\u0442 \u043d\u0430 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<h3>\u041a\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0432 3.14<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0435\u0440\u0435\u0435\u0437\u0436\u0430\u0435\u0442 \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0438\u0445 \u0447\u0438\u0442\u0430\u044e\u0442. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0438\u0437 <code>TYPE_CHECKING<\/code>:<\/p>\n<pre><code class=\"python\">from typing import TYPE_CHECKING, get_type_hintsfrom annotationlib import Format, get_annotationsif TYPE_CHECKING:    from decimal import Decimaldef total(x: Decimal) -&gt; Decimal:    return xprint(get_annotations(total, format=Format.FORWARDREF))# {'x': ForwardRef('Decimal', owner=&lt;function total at ...&gt;), 'return': ForwardRef('Decimal', ...)}print(get_annotations(total, format=Format.STRING))# {'x': 'Decimal', 'return': 'Decimal'}total.__annotations__       # NameError: name 'Decimal' is not definedget_type_hints(total)       # NameError: name 'Decimal' is not defined<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>def<\/code> \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442, \u0430 \u0432\u043e\u0442 <code>__annotations__<\/code> \u0438 <code>get_type_hints()<\/code> \u0431\u0440\u043e\u0441\u0430\u044e\u0442 <code>NameError<\/code>. \u041d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>annotationlib<\/code> \u0443\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430: <code>VALUE<\/code> (\u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435), <code>FORWARDREF<\/code> (\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 <code>ForwardRef<\/code>) \u0438 <code>STRING<\/code>. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0438\u0442\u0430\u044e\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, What\u2019s New \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 <code>get_annotations()<\/code> \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c <code>FORWARDREF<\/code>, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b <code>dataclasses<\/code> [4].<\/p>\n<blockquote>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0442\u0435\u043e\u0440\u0438\u044f. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 Mergify \u043e\u043f\u0438\u0441\u0430\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 3.14 \u0443\u043f\u0430\u043b FastAPI 0.128.0, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0447\u0438\u0442\u0430\u043b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0438\u0437 <code>TYPE_CHECKING<\/code>, \u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 0.128.1 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u043e \u0435\u0433\u043e \u043d\u0430 <code>Format.FORWARDREF<\/code> [6]. \u0418\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u043f\u043e\u0442\u043e\u043c Python, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0443\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0438 <code>from __future__ import annotations<\/code>.<\/p>\n<\/blockquote>\n<h3>Union \u0438 | \u0441\u0442\u0430\u043b\u0438 \u043e\u0434\u043d\u0438\u043c \u0442\u0438\u043f\u043e\u043c (3.14)<\/h3>\n<p>\u0412 3.14 <code>typing.Union<\/code> \u0438 <code>types.UnionType<\/code> \u0441\u0442\u0430\u043b\u0438 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u043b\u043e\u0447\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u043e\u043c\u0430\u044e\u0442 \u043a\u043e\u0434, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0447\u0435\u0440\u0435\u0437 <code>is<\/code> \u0438\u043b\u0438 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <code>repr<\/code>:<\/p>\n<pre><code class=\"python\">from typing import UnionUnion[int, str] is Union[int, str]       # False (\u0440\u0430\u043d\u044c\u0448\u0435 True \u0438\u0437-\u0437\u0430 \u043a\u0435\u0448\u0430)Union[int, str] == (int | str)           # Truerepr(Union[int, str])                    # 'int | str', \u0430 \u043d\u0435 'typing.Union[int, str]'isinstance(int | str, Union)             # True (\u0440\u0430\u043d\u044c\u0448\u0435 TypeError)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 <code>==<\/code>, \u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>typing.get_origin()<\/code> \u0438 <code>typing.get_args()<\/code>.<\/p>\n<h2>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0430 3.12 \u0438 \u0432\u044b\u0448\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0435\u043b\u044c\u0437\u044f<\/h2>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0441\u043a\u043e\u0447\u0438\u0442\u044c \u043d\u0430 3.14. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0431\u0440\u0430\u0437 \u0432 \u043f\u0440\u043e\u0434\u0435, \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u0418\u0437 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0435-\u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0438 \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445, \u043d\u043e \u043d\u0435 \u0432\u0441\u0451, \u0438 \u0442\u043e, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0444\u0438\u0447\u0438.<\/p>\n<h3>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435 \u0431\u044d\u043a\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/h3>\n<p>\u041d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043f\u0430\u0440\u0441\u0435\u0440\u0443, \u0430 \u043d\u0435 \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435: <code>class C[T]<\/code>, <code>def f[T]<\/code>, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>type<\/code>, <code>[T = int]<\/code> \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041d\u0430 3.10\u20133.11 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 <code>SyntaxError: invalid syntax<\/code>, \u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u044d\u0442\u043e \u043d\u0435 \u043e\u0431\u0445\u043e\u0434\u0438\u0442. <code>from __future__ import annotations<\/code> \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u043f\u043e\u0440\u0442 \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442:<\/p>\n<pre><code class=\"python\">class Box[T]: ...        # SyntaxError \u043d\u0430 &lt;=3.11class Box[T = int]: ...  # SyntaxError \u043d\u0430 &lt;=3.12<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>typing_extensions \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h3>\n<p><code>TypeIs<\/code>, <code>ReadOnly<\/code>, <code>override<\/code> \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 <code>TypeVar<\/code> \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f <code>typing<\/code>. \u041f\u0430\u043a\u0435\u0442 <code>typing_extensions<\/code> \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u0438\u0445 \u0436\u0435 \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0444\u0438\u0447 3.12 \u0438 3.13 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 3.7\u20133.11 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0430.<\/p>\n<h3>from __future__ import annotations \u0434\u043b\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439<\/h3>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442 \u0438\u0437 <code>__future__<\/code> (PEP 563, \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441 3.7) \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442, \u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0431\u044b \u043d\u0435 \u0441\u043c\u043e\u0433. \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0437 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 3.10 \u0438 3.13, \u0430 \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"python\">from __future__ import annotations as _annotationsfrom typing import TYPE_CHECKINGif TYPE_CHECKING:    from decimal import Decimal    from typing_extensions import TypeIsclass Node:    def link(self, other: Node) -&gt; Node:        return otherdef total(x: Decimal) -&gt; Decimal:    return xdef is_str(x: object) -&gt; TypeIs[str]:    return isinstance(x, str)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0411\u0435\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 3.10.20 \u0438 3.13.14 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>NameError: name 'Node' is not defined<\/code>, \u0441 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u042d\u0442\u043e \u0434\u0430\u0451\u0442 \u0441\u0440\u0430\u0437\u0443 \u0442\u0440\u0438 \u0432\u0435\u0449\u0438 \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a (\u0442\u043e, \u0447\u0442\u043e 3.14 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e),<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u0434 <code>TYPE_CHECKING<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>typing_extensions<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0432 dev-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445,<\/p>\n<\/li>\n<li>\n<p><code>list[int]<\/code> \u0438 <code>int | None<\/code> \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f\u0445, \u0433\u0434\u0435 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0438\u0445 \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430 3.7\u20133.9.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0430\u043b\u0438\u0430\u0441 `_annotations`, \u0430 \u043d\u0435 \u0433\u043e\u043b\u044b\u0439 `annotations`<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0418\u043c\u043f\u043e\u0440\u0442 <code>from __future__ import annotations<\/code> \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u043b\u0430\u0433 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u043e\u043d \u0435\u0449\u0451 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u043c\u043e\u0434\u0443\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0438\u043c\u044f <code>annotations<\/code> \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c <code>__future__._Feature<\/code>:<\/p>\n<pre><code class=\"python\">from __future__ import annotationsprint(annotations)# _Feature((3, 7, 0, 'beta', 1), None, 16777216)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0438\u043c\u044f \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044f: \u043e\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 <code>dir(module)<\/code>, \u0443\u0442\u0435\u0447\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 <code>from module import *<\/code>, \u0435\u0441\u043b\u0438 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 \u043d\u0435\u0442 <code>__all__<\/code>.<\/p>\n<p><code>from __future__ import annotations as _annotations<\/code> \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u044d\u0442\u043e \u0438\u043c\u044f \u0438\u0437 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f, \u0430 \u043d\u0430 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 PEP 563 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442. \u0422\u043e\u0442 \u0436\u0435 \u043f\u0440\u0438\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Pydantic, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0432 <a href=\"https:\/\/github.com\/pydantic\/pydantic\/blob\/main\/pydantic\/main.py\" rel=\"noopener nofollow\">pydantic\/main.py<\/a>.<\/p>\n<\/div>\n<\/details>\n<h4>\u0427\u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442<\/h4>\n<p>\u041e\u043d \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043d\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439. \u041d\u0430 \u0432\u0441\u0435\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0441 3.10 \u043f\u043e 3.14, \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0438 \u0431\u0435\u0437, \u043f\u0430\u0434\u0430\u044e\u0442 \u0441 <code>NameError<\/code>:<\/p>\n<pre><code class=\"python\">Alias = list[Later]T = TypeVar(\"T\", bound=Later)cast(Later, 1)class Sub(dict[str, Later]): ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0422\u0443\u0442 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u044b \u043a\u0430\u0432\u044b\u0447\u043a\u0438. \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>type<\/code> \u043d\u0430 3.12+, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u0435\u043d\u0438\u0432\u043e\u0435.<\/p>\n<h4>\u0426\u0435\u043d\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0430<\/h4>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442, \u0430 \u043f\u0435\u0440\u0435\u0435\u0437\u0436\u0430\u0435\u0442 \u0432 \u0442\u0435\u0445, \u043a\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u041d\u0430 3.13 \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c, \u0433\u0434\u0435 <code>Decimal<\/code> \u0432\u0437\u044f\u0442 \u0438\u0437 <code>TYPE_CHECKING<\/code>, <code>get_type_hints(total)<\/code> \u0431\u0440\u043e\u0441\u0430\u0435\u0442 <code>NameError<\/code>, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u043d\u0430 3.14. \u0415\u0441\u0442\u044c \u0438 \u043c\u0435\u043d\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p><code>TypedDict<\/code> \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 <code>ReadOnly<\/code> \u0438 <code>NotRequired<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\">from __future__ import annotations as _annotationsfrom typing import NotRequired, ReadOnly, TypedDictclass Movie(TypedDict):    title: ReadOnly[str]    year: NotRequired[int]print(sorted(Movie.__required_keys__), sorted(Movie.__optional_keys__), sorted(Movie.__readonly_keys__))# 3.13 \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c: ['title', 'year'] [] []# 3.13 \u0431\u0435\u0437 \u0438\u043c\u043f\u043e\u0440\u0442\u0430: ['title'] ['year'] ['title']<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435\u0442, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0435. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>typing<\/code> \u044d\u0442\u043e \u043f\u0440\u044f\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0438 \u043a <code>__required_keys__<\/code>.<\/p>\n<p>\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u044d\u0444\u0444\u0435\u043a\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 generic-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 3.12 \u0438 \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"python\">from __future__ import annotations as _annotationsfrom typing import get_type_hintsclass Box[T]:    def get(self) -&gt; T: ...get_type_hints(Box.get)  # NameError: name 'T' is not defined<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<blockquote>\n<p>\u042d\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 <a href=\"https:\/\/github.com\/python\/cpython\/issues\/124089\" rel=\"noopener nofollow\">cpython#124089<\/a>, \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0430\u044f \u043f\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043d\u0430 25 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2026 \u0433\u043e\u0434\u0430. \u0414\u043b\u044f \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<code>def first[T]<\/code>) \u0438 \u0434\u043b\u044f <code>get_type_hints(Box)<\/code> \u043e\u043d\u0430 \u043d\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0432 <a href=\"https:\/\/github.com\/python\/cpython\/issues\/114053\" rel=\"noopener nofollow\">cpython#114053<\/a>.<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u044e\u0442 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u042f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b Pydantic 2.13.5: \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043f\u043e\u043b\u0435\u043c <code>total: Decimal<\/code> \u0438 <code>Decimal<\/code> \u043f\u043e\u0434 <code>TYPE_CHECKING<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f (\u043d\u0430 3.13 \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0438\u0437 <code>__future__<\/code>, \u043d\u0430 3.14 \u0441 \u043d\u0438\u043c \u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e), \u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 <code>PydanticUserError: ... is not fully defined; you should define Decimal, then call Order.model_rebuild()<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0438\u043c\u0435\u043d\u0430 \u0438\u0437 <code>TYPE_CHECKING<\/code>, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>model_rebuild()<\/code> \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e. Ruff \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b: FA100 \u0438 FA102 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0438\u043c\u043f\u043e\u0440\u0442 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f <code>Optional<\/code>, <code>list[str]<\/code> \u0438 <code>int | None<\/code>, \u0430 <code>lint.pyupgrade.keep-runtime-typing = true<\/code> \u043d\u0435 \u0434\u0430\u0451\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0438\u0442\u0430\u0435\u0442 Pydantic.<\/p>\n<h3>\u0427\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0443\u0431\u0438\u0440\u0430\u0442\u044c<\/h3>\n<p>\u0423 \u0434\u0432\u0443\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0431\u044d\u043a\u043f\u043e\u0440\u0442\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u0434\u043b\u044f \u043e\u0442\u043a\u0430\u0437\u0430.<\/p>\n<p><code>typing_extensions<\/code> \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445. <code>typing_extensions.TypeIs<\/code> \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438 \u043d\u0430 3.14, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c.<\/p>\n<p>\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <code>typing<\/code> \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0430 \u043d\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. \u0414\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u0434\u043e \u0442\u043e\u0439, \u0433\u0434\u0435 \u0444\u0438\u0447\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c <code>typing<\/code>: <code>override<\/code> \u0441 3.12, <code>TypeIs<\/code>, <code>ReadOnly<\/code>, <code>TypeVar(default=...)<\/code> \u0441 3.13. \u0422\u043e\u0433\u0434\u0430 <code>typing_extensions<\/code> \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0421 <code>from __future__ import annotations<\/code> \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0434\u0440\u0443\u0433\u0430\u044f. \u041d\u0430 3.14+ \u043e\u043d \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0438 \u0434\u0430\u0436\u0435 \u043c\u0435\u0448\u0430\u0435\u0442: \u0438\u0437-\u0437\u0430 \u043d\u0435\u0433\u043e <code>Format.FORWARDREF<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0447\u0442\u043e \u0438 <code>STRING<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u0440\u044f\u0435\u0442 \u0441\u043c\u044b\u0441\u043b. What\u2019s New 3.14 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u0438\u043c\u043f\u043e\u0440\u0442 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c, \u043d\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u0430 \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 Python 3.13 [4]. \u0423\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u043e\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0442\u0430\u043b\u0430 3.14 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442. \u0412\u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3.9\u20133.10<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>typing_extensions<\/code> \u0434\u043b\u044f <code>Self<\/code>, <code>Required<\/code>\/<code>NotRequired<\/code>, <code>TypeIs<\/code>, <code>ReadOnly<\/code>, <code>override<\/code>, <code>TypeVar(default=...)<\/code>. <code>from __future__ import annotations as _annotations<\/code>, \u0435\u0441\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u0442 Pydantic \u0438\u043b\u0438 FastAPI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3.11<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>Self<\/code>, <code>Required<\/code>\/<code>NotRequired<\/code> \u2014 \u0431\u0435\u0437 <code>typing_extensions<\/code>; \u0434\u043b\u044f <code>TypeIs<\/code>, <code>ReadOnly<\/code>, <code>override<\/code>, <code>TypeVar(default=...)<\/code> \u043f\u0430\u043a\u0435\u0442 \u0435\u0449\u0451 \u043d\u0443\u0436\u0435\u043d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3.12<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>class C[T]<\/code>, <code>def f[T]<\/code>, <code>type<\/code>, <code>@override<\/code>, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c. \u0411\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>ruff check --select UP035 UP040 UP046 UP047 --target-version py312<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3.13<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>[T = int]<\/code>, <code>TypeIs<\/code>, <code>ReadOnly<\/code> \u0431\u0435\u0437 <code>typing_extensions<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3.14<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a \u0438 \u0431\u0435\u0437 <code>from __future__ import annotations<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0435\u0442 <code>class C[T]<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u043e\u043f\u0430\u0434\u0430\u044e\u0442 <code>T = TypeVar(\"T\")<\/code> \u0438 \u0441\u0443\u0444\u0444\u0438\u043a\u0441\u044b <code>_co<\/code>, \u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u044f\u0432\u043d\u043e\u0439. \u0421 3.14 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a \u0436\u0435, \u043d\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0438\u043d\u0430\u0447\u0435, \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0445 \u0447\u0438\u0442\u0430\u044e\u0442.<\/p>\n<p>\u0423 \u0447\u0430\u0441\u0442\u0438 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u0446\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u0430\u043d\u043e\u043d\u0441\u0430\u0445 \u043d\u0435\u0442: \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Ruff, <code>isinstance<\/code> \u0441 <code>type<\/code>-\u0430\u043b\u0438\u0430\u0441\u043e\u043c, \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 <code>TypedDict<\/code> \u043f\u043e\u0434 <code>from __future__ import annotations<\/code>.<\/p>\n<h2>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>Python Developer\u2019s Guide, \u043f\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043d\u0430 26 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2026 \u0433\u043e\u0434\u0430. <a href=\"https:\/\/devguide.python.org\/versions\/\" rel=\"noopener nofollow\">Status of Python versions<\/a><\/p>\n<\/li>\n<li>\n<p>Python Docs, 2 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2023. <a href=\"https:\/\/peps.python.org\/pep-0695\/\" rel=\"noopener nofollow\">PEP 695: Type Parameter Syntax<\/a><\/p>\n<\/li>\n<li>\n<p>Python Docs, 2 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2023. <a href=\"https:\/\/docs.python.org\/3.12\/whatsnew\/3.12.html\" rel=\"noopener nofollow\">What\u2019s New In Python 3.12<\/a> \u0438 \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u0440\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 <a href=\"https:\/\/docs.python.org\/3\/library\/typing.html\" rel=\"noopener nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 typing<\/a><\/p>\n<\/li>\n<li>\n<p>Python Docs, 7 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2025. <a href=\"https:\/\/docs.python.org\/3.14\/whatsnew\/3.14.html\" rel=\"noopener nofollow\">What\u2019s New In Python 3.14: deferred evaluation of annotations<\/a><\/p>\n<\/li>\n<li>\n<p>Astral, Ruff 0.15.22. \u041f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/docs.astral.sh\/ruff\/rules\/non-pep695-type-alias\/\" rel=\"noopener nofollow\">UP040, UP046, UP047<\/a> \u0438 <a href=\"https:\/\/docs.astral.sh\/ruff\/rules\/deprecated-import\/\" rel=\"noopener nofollow\">UP035<\/a><\/p>\n<\/li>\n<li>\n<p>Mergify, 14 \u0430\u043f\u0440\u0435\u043b\u044f 2026. <a href=\"https:\/\/mergify.com\/blog\/python-314-what-pep-649-actually-breaks\" rel=\"noopener nofollow\">Python 3.14 in Production: What PEP 649 Actually Breaks<\/a><\/p>\n<\/li>\n<li>\n<p>mypy. <a href=\"https:\/\/mypy.readthedocs.io\/en\/stable\/runtime_troubles.html\" rel=\"noopener nofollow\">Annotation issues at runtime<\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Ruff \u043f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c FA100, FA102 \u0438 UP006<\/p>\n<\/li>\n<li>\n<p>Python Docs, 24 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2022. <a href=\"https:\/\/peps.python.org\/pep-0673\/\" rel=\"noopener nofollow\">PEP 673: Self Type<\/a><\/p>\n<\/li>\n<li>\n<p>Python Docs, 24 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2022. <a href=\"https:\/\/peps.python.org\/pep-0655\/\" rel=\"noopener nofollow\">PEP 655: Marking Individual TypedDict Items as Required or Potentially-Missing<\/a><\/p>\n<\/li>\n<li>\n<p>Python Docs, 24 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2022. <a href=\"https:\/\/peps.python.org\/pep-0646\/\" rel=\"noopener nofollow\">PEP 646: Variadic Generics<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1089780\/\">https:\/\/habr.com\/ru\/articles\/1089780\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u042f \u0447\u0438\u0442\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Python \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0433\u0434\u0435 \u0435\u044e \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435\u0440\u044c\u0451\u0437, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0433\u0430\u043b\u043e\u0447\u043a\u0438. \u041f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435 \u043d\u043e\u0432\u0435\u0435 3.11: Optional, TypeVar \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0443\u043b\u044f, Generic[T], \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443 Python 3.10 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043a\u0442\u044f\u0431\u0440\u0435 2026 \u0433\u043e\u0434\u0430 [1], \u0438 \u0447\u0430\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0433\u043e \u043d\u0438\u0436\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440.\u0417\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043b\u0438\u0437\u043e\u0432 \u0432 typing \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e: \u0432 3.11 \u2014 Self \u0438 Required\/NotRequired, \u0432 3.12 \u2014 \u0441\u0432\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f generic-\u0442\u0438\u043f\u043e\u0432 \u0438 \u0430\u043b\u0438\u0430\u0441\u043e\u0432, \u0432 3.13 \u2014 TypeIs \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430, \u0432 3.14 \u2014 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a. \u0414\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0433\u0434\u0435 \u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0438 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Python.\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u043d\u0430 CPython 3.10.20, 3.11.15, 3.12.13, 3.13.14 \u0438 3.14.2. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0435\u043b\u0430\u043b mypy 2.3.1, ty 0.0.78 \u0438 pyright 1.1.414, \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u043c \u0431\u044b\u043b Ruff 0.15.22. \u0422\u0435\u0440\u043c\u0438\u043d\u044b: \u00ab\u0440\u0430\u043d\u0442\u0430\u0439\u043c\u00bb \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440, \u00abchecker\u00bb \u044d\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u0440\u043e\u0434\u0435 mypy. \u041c\u043d\u043e\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f checker\u2019\u0430, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438\u0445 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0438 \u044f \u0431\u0443\u0434\u0443 \u043d\u0430 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c.\u0413\u043b\u0430\u0432\u043d\u043e\u0435: \u0447\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0449\u0435\u0421\u0432\u043e\u0434\u043a\u0430 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u044f\u043c, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0438\u0436\u0435.\u0427\u0442\u043e\u041a\u0430\u043a \u0431\u044b\u043b\u043e\u041a\u0430\u043a \u0441\u0442\u0430\u043b\u043e\u0421 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438\u041c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441TypeVar(bound=&#8230;) \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441Self3.11\u0427\u0430\u0441\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0439 TypedDict \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430total=False \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0435Required\/NotRequired3.11Generic-\u043a\u043b\u0430\u0441\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044fT = TypeVar(&#171;T&#187;) \u0438 Generic[T]class Stack[T], def first[T]3.12\u0410\u043b\u0438\u0430\u0441 \u0442\u0438\u043f\u0430X: TypeAlias = &#171;&#8230;&#187;type X = &#8230;3.12\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044cTypeVar(&#171;T_co&#187;, covariant=True)\u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u04383.12\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043d\u0435\u0442@override3.12\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0442\u0438\u043f\u0430TypeVar(default=&#8230;)class Box[T = int]3.13\u0421\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430TypeGuardTypeIs3.13\u041a\u043b\u044e\u0447\u0438 TypedDict \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f\u043d\u0435\u0442ReadOnly[&#8230;]3.13\u041e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438\u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0438\u043b\u0438 from __future__ import annotations\u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a3.14Self \u0432\u043c\u0435\u0441\u0442\u043e TypeVar(bound=\u2026) (3.11)\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u043d\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e, \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b TypeVar, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 bound:from typing import TypeVarTAnimal = TypeVar(&#171;TAnimal&#187;, bound=&#187;Animal&#187;)class Animal:    @classmethod    def create(cls: type[TAnimal]) -&gt; TAnimal:        return cls()\u0421 3.11 (PEP 673 [8]) \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c Self, \u0431\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:from typing import Self, reveal_typeclass Animal:    @classmethod    def create(cls) -&gt; Self:        return cls()    def clone(self) -&gt; Self:        return type(self)()class Dog(Animal):    passreveal_type(Dog.create())reveal_type(Dog().clone())\u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u044f\u0442 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441, \u0430 \u043d\u0435 Animal, \u043d\u043e Self \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 (clone), \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c TypeVar \u0437\u0430\u043d\u043e\u0432\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u2014 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, clone, __enter__, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 self:\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright$ mypy example.pyexample.py:14: note: Revealed type is &#171;example.Dog&#187;example.py:15: note: Revealed type is &#171;example.Dog&#187;Success: no issues found in 1 source file$ ty check example.pyinfo[revealed-type]: Revealed type  &#8212;&gt; example.py:14:13   |14 | reveal_type(Dog.create())   |             ^^^^^^^^^^^^ `Dog`info[revealed-type]: Revealed type  &#8212;&gt; example.py:15:13   |15 | reveal_type(Dog().clone())   |             ^^^^^^^^^^^^^ `Dog`Found 2 diagnostics$ pyright example.pyexample.py:14:13 &#8212; information: Type of &#171;Dog.create()&#187; is &#171;Dog&#187;example.py:15:13 &#8212; information: Type of &#171;Dog().clone()&#187; is &#171;Dog&#187;0 errors, 0 warnings, 2 informationsRequired \u0438 NotRequired (3.11)\u0414\u043e 3.11 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0439 TypedDict \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435:from typing import TypedDictclass _MovieBase(TypedDict):    title: strclass Movie(_MovieBase, total=False):    year: int\u0421 3.11 (PEP 655 [9]) \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435:from typing import NotRequired, TypedDictclass Movie(TypedDict):    title: str    year: NotRequired[int]def f(m: Movie) -&gt; None:    m[&#171;title&#187;]f({})year \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d, \u0430 title \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c; f({}) \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 f \u0441 \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c, \u0433\u0434\u0435 title \u043d\u0435\u0442, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430:\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright$ mypy example.pyexample.py:10: error: Missing key &#171;title&#187; for TypedDict &#171;Movie&#187;  [typeddict-item]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-argument-type]: Argument to function `f` is incorrect  &#8212;&gt; example.py:10:3   |10 | f({})   |   ^^ Expected `Movie`, found `dict[Unknown, Unknown]`info: Function defined here &#8212;&gt; example.py:7:5  |7 | def f(m: Movie) -&gt; None:  |     ^ &#8212;&#8212;&#8212; Parameter declared hereerror[missing-typed-dict-key]: Missing required key &#8216;title&#8217; in TypedDict `Movie` constructor  &#8212;&gt; example.py:10:3   |10 | f({})   |   ^^Found 2 diagnostics$ pyright example.pyexample.py:10:3 &#8212; error: Argument of type &#171;dict[Any, Any]&#187; cannot be assigned to parameter &#171;m&#187; of type &#171;Movie&#187; in function &#171;f&#187;    &#171;title&#187; is required in &#171;Movie&#187; (reportArgumentType)1 error, 0 warnings, 0 informationsGeneric \u0431\u0435\u0437 TypeVar (3.12)\u0414\u043e 3.12 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438 Generic \u0432 \u0431\u0430\u0437\u044b:from typing import Generic, TypeVarT = TypeVar(&#171;T&#187;)class Stack(Generic[T]):    def __init__(self) -&gt; None:        self._items: list[T] = []    def push(self, item: T) -&gt; None:        self._items.append(item)    def pop(self) -&gt; T:        return self._items.pop()def first(items: list[T]) -&gt; T:    return items[0]\u0421 3.12 (PEP 695 [2]) \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435:class Stack[T]:    def __init__(self) -&gt; None:        self._items: list[T] = []    def push(self, item: T) -&gt; None:        self._items.append(item)    def pop(self) -&gt; T:        return self._items.pop()def first[T](items: list[T]) -&gt; T:    return items[0]\u0418\u043c\u044f T \u0436\u0438\u0432\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u043e\u043d\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442. \u041e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 T \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b.\u0418 bound, \u0438 constraints \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e: def f[T: Hashable](x: T), def g[T: (int, str)](x: T). \u0414\u043b\u044f ParamSpec \u0438 TypeVarTuple \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f **P \u0438 *Ts. \u0421\u0430\u043c\u0438 TypeVarTuple \u0438 Unpack \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u0432 3.11 (PEP 646 [10]) \u2014 \u0434\u043e 3.12 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 generic \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u043a Generic[*Ts], \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043b\u0438\u0448\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u0430.\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 type (3.12)\u0410\u043b\u0438\u0430\u0441\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0447\u0435\u0440\u0435\u0437 TypeAlias, \u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0438\u0430\u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0439:from typing import TypeAliasJson: TypeAlias = &#171;dict[str, Json] | list[Json] | str | int | float | bool | None&#187;\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 type:type Json = dict[str, Json] | list[Json] | str | int | float | bool | None\u041f\u0440\u0430\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0435\u0451 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u043b\u0438\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f \u0438\u043b\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435, \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a. \u0410\u043b\u0438\u0430\u0441\u044b \u0431\u044b\u0432\u0430\u044e\u0442 generic: type Pair[T] = tuple[T, T].TypeAlias \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c, \u043d\u043e \u0441\u0440\u043e\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d [3].\u0412\u044b\u0432\u043e\u0434 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (3.12)\u0414\u043b\u044f \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0430\u043c\u043e\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 PEP 695. \u0420\u0430\u043d\u044c\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438:T_co = TypeVar(&#171;T_co&#187;, covariant=True)class ReadOnlyBox(Generic[T_co]):    def __init__(self, item: T_co) -&gt; None:        self._item = item    def get(self) -&gt; T_co:        return self._item\u0421 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c checker \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435:class ReadOnlyBox[T]:    def __init__(self, item: T) -&gt; None:        self._item = item    def get(self) -&gt; T:        return self._itemclass MutableBox[T]:    def __init__(self, item: T) -&gt; None:        self.item = itemdef show(box: ReadOnlyBox[int]) -&gt; None: &#8230;def edit(box: MutableBox[int]) -&gt; None: &#8230;ro: ReadOnlyBox[bool] = ReadOnlyBox(True)mu: MutableBox[bool] = MutableBox(True)show(ro)  # bool \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c int, \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430edit(mu)  # \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d\u0412\u0441\u0435 \u0442\u0440\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0433\u043b\u0430\u0448\u0430\u044e\u0442\u0441\u044f: show(ro) \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u043e\u043b\u0447\u0430, \u0430 \u043d\u0430 edit(mu) \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 MutableBox[bool] \u0438 MutableBox[int] \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b.\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright$ mypy example.pyexample.py:22: error: Argument 1 to &#171;edit&#187; has incompatible type &#171;MutableBox[bool]&#187;; expected &#171;MutableBox[int]&#187;  [arg-type]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-argument-type]: Argument to function `edit` is incorrect  &#8212;&gt; example.py:22:6   |22 | edit(mu)  # \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435\u043d   |      ^^ Expected `MutableBox[int]`, found `MutableBox[bool]`info: `MutableBox` is invariant in its type parameterFound 1 diagnostic$ pyright example.pyexample.py:22:6 &#8212; error: Argument of type &#171;MutableBox[bool]&#187; cannot be assigned to parameter &#171;box&#187; of type &#171;MutableBox[int]&#187; in function &#171;edit&#187;    &#171;MutableBox[bool]&#187; is not assignable to &#171;MutableBox[int]&#187;      Type parameter &#171;T@MutableBox&#187; is invariant, but &#171;bool&#187; is not the same as &#171;int&#187; (reportArgumentType)1 error, 0 warnings, 0 informations@override (3.12)\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 typing.override \u0433\u043e\u0432\u043e\u0440\u0438\u0442 checker\u2019\u0443, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u044f\u0437\u0430\u043d \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u2014 \u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 __override__, \u0430 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e. \u041e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e checker:from typing import overrideclass Base:    def run(self) -&gt; None: &#8230;class Child(Base):    @override    def runn(self) -&gt; None: &#8230;  # \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430, \u043e\u0448\u0438\u0431\u043a\u0430 checker&#8217;\u0430\u0412\u044b\u0432\u043e\u0434 mypy, ty, pyright$ mypy example.pyexample.py:8: error: Method &#171;runn&#187; is marked as an override, but no base method was found with this name  [misc]Found 1 error in 1 file (checked 1 source file)$ ty check example.pyerror[invalid-explicit-override]: Method `runn` is decorated with `@override` but does not override anything &#8212;&gt; example.py:8:9  |7 |     @override  |     &#8212;&#8212;&#8212;8 |     def runn(self) -&gt; None: &#8230;  |         ^^^^info: No `runn` definitions were found on any superclasses of `Child`Found 1 diagnostic$ pyright example.pyexample.py:8:9 &#8212; error: Method &#171;runn&#187; is marked as override, but no base&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-497156","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=497156"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497156\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=497156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=497156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=497156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}