Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00530db

Browse files
authored
[mypyc] Support nested functions without type annotations (#7545)
... this was actually as simple as removing an assert.
1 parent 1f11538 commit 00530db

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

mypyc/genops.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4686,8 +4686,6 @@ def setup_func_for_recursive_call(self, fdef: FuncDef, base: ImplicitClass) -> N
46864686
environment so that the function can be called recursively. Note that this needs to be done
46874687
only for nested functions.
46884688
"""
4689-
assert fdef.type is not None
4690-
46914689
# First, set the attribute of the environment class so that GetAttr can be called on it.
46924690
prev_env = self.fn_infos[-2].env_class
46934691
prev_env.attributes[fdef.name()] = self.type_to_rtype(fdef.type)

mypyc/test-data/run-functions.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def while_loop() -> int:
146146
def free_vars(foo: int, bar: int) -> int:
147147
x = 1
148148
y = 2
149-
def g() -> None:
149+
def g(): # type: ignore # missing type annotation for testing
150150
nonlocal y
151151
y = 3
152152
nonlocal bar

0 commit comments

Comments
 (0)