Skip to content

1.6.1 > 1.7.0 and 1.7.1 regression in for "broken" dataclasses #16580

Open

Description

@DanielNoord

Bug Report

When type checking the following code the output changes depending on whether you use 1.6.0 or 1.7.1.

To Reproduce

from dataclasses import dataclass


@dataclass(frozen=True)
class A:
    attr_one: int
    attr_two: int | None


@dataclass(frozen=True)
class B(A):
    attr_two = None


instance = B(attr_one=1)
print(instance.attr_two)

Playground: https://mypy-play.net/?mypy=1.7.0&python=3.11&gist=f74740e7a7ef6bf0c9f88175a988aed5

The code is likely not doing what the author expects it to do, but the new message is wrong as attr_two can be referenced and is certainly not an instance of B.

Expected Behavior

main.py:15: error: Missing positional argument "attr_two" in call to "B"  [call-arg]
Found 1 error in 1 file (checked 1 source file)

Actual Behavior

main.py:15: error: Missing positional argument "attr_two" in call to "B"  [call-arg]
main.py:16: error: "B" not callable  [operator]
Found 2 errors in 1 file (checked 1 source file)

Your Environment
master branch on Playground.

Activity

  1. added
    bug
    on Nov 28, 2023
  2. DanielNoord commented on Nov 28, 2023

    @DanielNoord
    ContributorAuthor

    @AlexWaygood I have now also been able to reproduce without the deamon. You might want to update the label. (I'll update the title)

  3. changed the title [-]1.6.1 > 1.7.0 and 1.7.1 regression in ``dmypy`` for "broken" ``dataclasses``[/-] [+]1.6.1 > 1.7.0 and 1.7.1 regression in for "broken" ``dataclasses``[/+] on Nov 28, 2023
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

    bugtopic-dataclasses

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions