[go: up one dir, main page]

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

Metaclass conflict when combine class with a custom metaclass and str class #14818

Open
kabell opened this issue Mar 2, 2023 · 0 comments
Open
Labels
bug mypy got something wrong topic-metaclasses

Comments

@kabell
Copy link
kabell commented Mar 2, 2023

Bug Report

Mypy returns

error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

when I combine a class with a custom metaclass and a str class

To Reproduce

This works

class M1(type): pass
class A1(metaclass=M1): pass

class CorrectMeta(M1, type): pass
class B2(A1, int, metaclass=CorrectMeta): pass  

but this not - I only replaced int with str

class M1(type): pass
class A1(metaclass=M1): pass

class CorrectMeta(M1, type): pass
class B2(A1, str, metaclass=CorrectMeta): pass 

Expected Behavior

There is no error

Actual Behavior

Mypy returned an error

Your Environment

  • Mypy version used: >=0.991
  • Mypy command-line flags: mypy -p mypackage
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
files = "**/**.py"
plugins = [
    "pydantic.mypy"
]

ignore_missing_imports = false
scripts_are_modules = false
namespace_packages = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
no_implicit_optional = true
show_error_context = true
show_traceback = true
strict_equality = true
check_untyped_defs = true

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true

[[tool.mypy.overrides]]
module = [
    "tests.*"
]
disallow_untyped_defs = false
disallow_incomplete_defs = false

[[tool.mypy.overrides]]
module = [
    "request_session.*",
    "sentry_sdk.*",
    "structlog.*",
]
ignore_missing_imports = true
ignore_errors = true
  • Python version used:
    3.9, 3.10, 3.11
@kabell kabell added the bug mypy got something wrong label Mar 2, 2023
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-metaclasses
Projects
None yet
Development

No branches or pull requests

2 participants