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

dataclass(frozen=True) not working with default Final qualifier #18567

Open
mflova opened this issue Jan 29, 2025 · 0 comments · May be fixed by #18572
Open

dataclass(frozen=True) not working with default Final qualifier #18567

mflova opened this issue Jan 29, 2025 · 0 comments · May be fixed by #18572
Labels
bug mypy got something wrong topic-dataclasses

Comments

@mflova
Copy link

mflova commented Jan 29, 2025

Bug Report

When using Final type hint in combination with dataclass(frozen=True), mypy displays an error. This error disappears either if frozen=True is removed or the type of Final is provided.

To Reproduce

from dataclasses import dataclass
from typing import Final


@dataclass
class Foo:
    var: Final = "a"

@dataclass(frozen=True)
class Foo2:
    var: Final = "a"

@dataclass(frozen=True)
class Foo3:
    var: Final[str] = "a"

foo = Foo()
foo.var  # OK

foo2 = Foo2()
foo2.var  # ERROR: "Foo" not callable [operator]

foo3 = Foo3()
foo3.var  # OK

Your Environment

  • Mypy version used: 1.14.1
  • Mypy command-line flags: mypy script.py
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10.11
@mflova mflova added the bug mypy got something wrong label Jan 29, 2025
@mflova mflova changed the title dataclass(frozen=True not working with default Final qualifier dataclass(frozen=True) not working with default Final qualifier Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-dataclasses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants