Skip to content

a 'final' NamedTuple is flagged with pyright 1.1.401 #10490

@tpgillam

Description

@tpgillam

Consider:

import typing

@typing.final
class Moo(typing.NamedTuple):
    x: int
    y: float
$ uv run --with pyright==1.1.400 pyright moo.py
WARNING: there is a new pyright version available (v1.1.400 -> v1.1.401).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

0 errors, 0 warnings, 0 informations

$ uv run --with pyright==1.1.401 pyright moo.py
/SNIP/.cache/uv/archive-v0/zIVt7Dtwp850HkvvxOiHh/lib/python3.12/site-packages/pyright/dist/dist/typeshed-fallback/stdlib/_typeshed/_type_checker_internals.pyi
  /SNIP/.cache/uv/archive-v0/zIVt7Dtwp850HkvvxOiHh/lib/python3.12/site-packages/pyright/dist/dist/typeshed-fallback/stdlib/_typeshed/_type_checker_internals.pyi:52:91 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
/SNIP/moo.py
  /SNIP/moo.py:5:7 - error: Variables defined in abstract base class are not initialized in final class "Moo"
    Instance variable "_field_defaults" is defined in abstract base class "NamedTuple" but not initialized
    Instance variable "_fields" is defined in abstract base class "NamedTuple" but not initialized
    Instance variable "__orig_bases__" is defined in abstract base class "NamedTuple" but not initialized (reportUninitializedInstanceVariable)
2 errors, 0 warnings, 0 informations

(We can see #10487 too, but I'm identifying the second error here).

Note that this error only appears when the type is marked with typing.final.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't workingregression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions