Skip to content

inner class of NamedTuple triggers "Invalid statement" #10337

Description

@Lambda-Logan

This will show an error.

from typing import NamedTuple


class Name(NamedTuple):
    name: str = ""

    class Inner:
        pass

>>> error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"

However, this works fine:

class Name:
    name: str = ""

    class Inner:
        pass

mypy 0.761
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions