Skip to content
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

Error type checking nested namedtuples #15061

Closed
hmc-cs-mdrissi opened this issue Apr 16, 2023 · 1 comment
Closed

Error type checking nested namedtuples #15061

hmc-cs-mdrissi opened this issue Apr 16, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@hmc-cs-mdrissi
Copy link
Contributor

Bug Report

from typing import NamedTuple

class RaggedFeature(NamedTuple):
  class RowSplits(NamedTuple):
    x: int

  splits: RowSplits

produces an error message of,

Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"
Expected Behavior

No error. I ran into this writing stubs for real code from here that does use nested namedtuples at runtime. It also type checks fine in pyright. Minor though as type: ignore seems to work fine for it in typeshed.

Your Environment

Latest mypy version 1.2. Default flags/configuration is enough.

@hmc-cs-mdrissi hmc-cs-mdrissi added the bug mypy got something wrong label Apr 16, 2023
@hmc-cs-mdrissi
Copy link
Contributor Author

After some searching I found this is duplicate issue of this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant