Skip to content

[PEP 695] Fix handling of undefined name in generic function annotation #17338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def analyze_func_def(self, defn: FuncDef) -> None:
# Don't store not ready types (including placeholders).
if self.found_incomplete_ref(tag) or has_placeholder(result):
self.defer(defn)
# TODO: pop type args
self.pop_type_args(defn.type_args)
return
assert isinstance(result, ProperType)
if isinstance(result, CallableType):
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,8 @@ else:
x: T # E: Name "T" is not defined
a: A[int]
reveal_type(a) # N: Revealed type is "builtins.list[builtins.int]"

[case testPEP695UndefinedNameInAnnotation]
# flags: --enable-incomplete-feature=NewGenericSyntax
def f[T](x: foobar, y: T) -> T: ... # E: Name "foobar" is not defined
reveal_type(f) # N: Revealed type is "def [T] (x: Any, y: T`-1) -> T`-1"
Loading