Skip to content

[ty] Annotations are deferred by default for 3.14+#20799

Merged
sharkdp merged 1 commit intomainfrom
david/deferred-annotations-3.14
Oct 10, 2025
Merged

[ty] Annotations are deferred by default for 3.14+#20799
sharkdp merged 1 commit intomainfrom
david/deferred-annotations-3.14

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Oct 10, 2025

Summary

Type annotations are deferred by default starting with Python 3.14. No from __future__ import annotations import is necessary.

Test Plan

New Markdown test

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Oct 10, 2025
@github-actions
Copy link
Contributor

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-10-10 09:34:05.987405174 +0000
+++ new-output.txt	2025-10-10 09:34:09.226430462 +0000
@@ -54,12 +54,9 @@
 aliases_variance.py:18:24: error[non-subscriptable] Cannot subscript object of type `<class 'ClassA[typing.TypeVar]'>` with no `__class_getitem__` method
 aliases_variance.py:28:16: error[non-subscriptable] Cannot subscript object of type `<class 'ClassA[typing.TypeVar]'>` with no `__class_getitem__` method
 aliases_variance.py:44:16: error[non-subscriptable] Cannot subscript object of type `<class 'ClassB[typing.TypeVar, typing.TypeVar]'>` with no `__class_getitem__` method
-annotations_forward_refs.py:22:7: error[unresolved-reference] Name `ClassA` used when not defined
-annotations_forward_refs.py:23:12: error[unresolved-reference] Name `ClassA` used when not defined
 annotations_forward_refs.py:49:10: error[invalid-type-form] Variable of type `Literal[1]` is not allowed in a type expression
 annotations_forward_refs.py:54:11: error[fstring-type-annotation] Type expressions cannot use f-strings
 annotations_forward_refs.py:55:11: error[invalid-type-form] Variable of type `<module 'types'>` is not allowed in a type expression
-annotations_forward_refs.py:66:26: error[unresolved-reference] Name `ClassB` used when not defined
 annotations_forward_refs.py:80:14: error[unresolved-reference] Name `ClassF` used when not defined
 annotations_forward_refs.py:82:11: error[invalid-type-form] Variable of type `Literal[""]` is not allowed in a type expression
 annotations_forward_refs.py:87:9: error[invalid-type-form] Variable of type `def int(self) -> None` is not allowed in a type expression
@@ -900,5 +897,5 @@
 typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
 typeddicts_usage.py:28:18: error[invalid-key] Invalid key access on TypedDict `Movie`: Unknown key "title"
 typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions. Did you mean to use a concrete TypedDict or `collections.abc.Mapping[str, object]` instead?
-Found 901 diagnostics
+Found 898 diagnostics
 WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details.

@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@sharkdp
Copy link
Contributor Author

sharkdp commented Oct 10, 2025

-annotations_forward_refs.py:22:7: error[unresolved-reference] Name `ClassA` used when not defined
-annotations_forward_refs.py:23:12: error[unresolved-reference] Name `ClassA` used when not defined
 annotations_forward_refs.py:49:10: error[invalid-type-form] Variable of type `Literal[1]` is not allowed in a type expression
 annotations_forward_refs.py:54:11: error[fstring-type-annotation] Type expressions cannot use f-strings
 annotations_forward_refs.py:55:11: error[invalid-type-form] Variable of type `<module 'types'>` is not allowed in a type expression
-annotations_forward_refs.py:66:26: error[unresolved-reference] Name `ClassB` used when not defined

I opened python/typing#2096 to address this.

@sharkdp sharkdp merged commit 69f9182 into main Oct 10, 2025
42 checks passed
@sharkdp sharkdp deleted the david/deferred-annotations-3.14 branch October 10, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants