Skip to content

Error type checking nested namedtuples #15061

Closed

Description

@hmc-cs-mdrissi

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.

Activity

  1. hmc-cs-mdrissi commented on Apr 16, 2023

    @hmc-cs-mdrissi
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions