Skip to content

Detect functional typing.NamedTuples that have fields beginning with underscores #2511

@AlexWaygood

Description

@AlexWaygood

We currently detect that the first two of these classes will lead to an error being raised at runtime, but we do not currently detect that the third of these classes will lead to an error being raised at runtime:

import collections
from typing import NamedTuple

class X(NamedTuple):
    _foo: int

Y = collections.namedtuple("Y", "_x")

Foo = NamedTuple("Foo", [("_x", int), ("_y", str)])

Metadata

Metadata

Assignees

Labels

namedtuplesruntime semanticsAccurate modeling of how Python's semantics work at runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions