From 0f88fa1b39a5ae21551738d90be97fe94340f3d3 Mon Sep 17 00:00:00 2001 From: Shantanu Jain Date: Sat, 28 Dec 2024 02:46:25 -0800 Subject: [PATCH] Fix crash from NamedTuple placeholder Fixes https://github.com/python/mypy/issues/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' ``` --- mypy/semanal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index 6e3335aed4e1..ebe6a9312b96 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -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)