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

Abstract dataclasses don't work #11868

Closed
inducer opened this issue Dec 29, 2021 · 2 comments
Closed

Abstract dataclasses don't work #11868

inducer opened this issue Dec 29, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@inducer
Copy link

inducer commented Dec 29, 2021

Consider this snippet, let's name it mypy-abstract-dataclass.py:

from dataclasses import dataclass
from abc import ABC, abstractmethod


@dataclass(frozen=True)
class Something(ABC):
    xyz: int

    @abstractmethod
    def abc(self) -> int:
        pass

I think this should typecheck (subclasses of this can be instantiated without error), but mypy 0.930 says:

mypy-abstract-dataclass.py:5: error: Only concrete class can be given where "Type[Something]" is expected
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.930
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10
  • Operating system and version: Linux
@inducer inducer added the bug mypy got something wrong label Dec 29, 2021
@AlexWaygood
Copy link
Member

I think this may be a duplicate of #5374? 🙂

@inducer
Copy link
Author

inducer commented Dec 30, 2021

Looks that way. Thanks for the pointer!

@inducer inducer closed this as completed Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants