8000 Fix crash from NamedTuple placeholder by hauntsaninja · Pull Request #18351 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix crash from NamedTuple placeholder #18351

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Fix crash from NamedTuple placeholder
Fixes #17396

I'm having trouble writing a regression test, but the following
reproduces the issue nicely:
```
rm -rf repro
mkdir repro
mkdir repro/np
echo 'from .arraysetops import UniqueAllResult' > repro/np/__init__.pyi
echo '
from typing import Generic, NamedTuple, TypeVar
from np import does_not_exist

_SCT = TypeVar("_SCT", bound=does_not_exist)

class UniqueAllResult(NamedTuple, Generic[_SCT]):
    values: int
' > repro/np/arraysetops.pyi
touch repro/np/py.typed

PYTHONPATH=repro mypy -c 'import np'
```
  • Loading branch information
hauntsaninja committed Dec 28, 2024
commit 0f88fa1b39a5ae21551738d90be97fe94340f3d3
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ def analyze_namedtuple_classdef(
defn, self.is_stub_file, self.is_func_scope()
)
if is_named_tuple:
if info is None:
if info is None or any(has_placeholder(tv) for tv in tvar_defs):
self.mark_incomplete(defn.name, defn)
else:
self.prepare_class_def(defn, info, custom_names=True)
Expand Down
Loading
0