Skip to content

no error when using field outside of a dataclass #13120

Open
@DetachHead

Description

@DetachHead
from dataclasses import field

a = field(default=1)

a + 1  # runtime error
reveal_type(a)  # int

playground

Activity

KotlinIsland

KotlinIsland commented on Jul 14, 2022

@KotlinIsland
Contributor

Take it to typeshed general

added and removed
bugmypy got something wrong
on Jul 14, 2022
KotlinIsland

KotlinIsland commented on Jul 19, 2022

@KotlinIsland
Contributor
from dataclasses import dataclass, field

@dataclass
class A:
    a = field(default=1)
    print(a + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JelleZijlstra@DetachHead@KotlinIsland@AlexWaygood

        Issue actions

          no error when using `field` outside of a `dataclass` · Issue #13120 · python/mypy