diff --git a/mypy/semanal_namedtuple.py b/mypy/semanal_namedtuple.py index 56104c1ffc46..4c4caa80353a 100644 --- a/mypy/semanal_namedtuple.py +++ b/mypy/semanal_namedtuple.py @@ -7,7 +7,7 @@ import keyword from contextlib import contextmanager -from typing import Container, Final, Iterator, List, Mapping, Optional, cast +from typing import Container, Final, Iterator, List, Mapping, cast from mypy.exprtotype import TypeTranslationError, expr_to_unanalyzed_type from mypy.messages import MessageBuilder @@ -688,7 +688,7 @@ def save_namedtuple_body(self, named_tuple_info: TypeInfo) -> Iterator[None]: # Helpers - def check_namedtuple_field_name(self, field: str, seen_names: Container[str]) -> Optional[str]: + def check_namedtuple_field_name(self, field: str, seen_names: Container[str]) -> str | None: """Return None for valid fields, a string description for invalid ones.""" if field in seen_names: return f'has duplicate field name "{field}"'