You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New semantic analyzer: Enable namedtuple tests and fix self-check error (#6452)
This fixes the `Name 'cls' already defined error` in self-check with new analyzer. The error is caused by the fact that now we actually analyze generated methods. I solve them simply by using underscored versions of `_self` and `_cls` (this is btw the same what runtime implementation does for some generated methods).
I also enable both named tuple test files. This needs the same temporary redundant variable hack as I did for typed dicts, it can be removed when we will not need to be compatible with old analyzer, I will create an issue so we will not forget about this.
I skip a bunch of test cases for recursive named tuples (there is already an issue for this). I also skip one test because it is tricky to fix, I will open a follow-up issue.
X._replace(x=1, y=2) # E: Missing positional argument "self" in call to "_replace" of "X"
355
+
X._replace(x=1, y=2) # E: Missing positional argument "_self" in call to "_replace" of "X"
355
356
356
357
[builtins fixtures/list.pyi]
357
358
@@ -497,7 +498,9 @@ b = B._make(['']) # type: B
497
498
498
499
[builtins fixtures/list.pyi]
499
500
501
+
-- Depends on tuple fallback PR
500
502
[case testNamedTupleIncompatibleRedefinition]
503
+
# flags: --no-new-semantic-analyzer
501
504
from typing import NamedTuple
502
505
class Crash(NamedTuple):
503
506
count: int # E: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "Callable[[Tuple[int, ...], Any], int]")
@@ -573,6 +576,7 @@ tmp/b.py:4: error: Revealed type is 'Tuple[Any, fallback=a.N]'
573
576
tmp/b.py:7: error: Revealed type is 'Tuple[Any, fallback=a.N]'
0 commit comments