Skip to content

Support conditional definitions in dataclasses, etc. #21316

@JukkaL

Description

@JukkaL

Feature

Support Python version and other checks that can be evaluated statically in bodies of dataclasses, named tuples, and other cases discussed in python/typing-council#58.

Example that should work:

import sys

from typing import NamedTuple

class NT(NamedTuple):
    x: int
    if sys.version_info >= (3, 12):
        y: str

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions