Closed
Description
Bug Report
This bug is experienced in classes lib
To Reproduce
from typing import List
class ListOfStrMeta(type):
def __instancecheck__(cls, other) -> bool:
return (
isinstance(other, list) and
bool(other) and
all(isinstance(list_item, str) for list_item in other)
)
class ListOfStr(List[str], metaclass=ListOfStrMeta):
...
Expected Behavior
No errors should appear
Actual Behavior
Error from the code above:
poetry run mypy ex.py
ex.py:13: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.2.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files):
[mypy]
# Plugins, includes custom:
plugins =
classes.contrib.mypy.classes_plugin
disable_error_code = empty-body
allow_redefinition = false
check_untyped_defs = true
disallow_any_explicit = true
# disallow_any_generics = true
disallow_untyped_calls = true
ignore_errors = false
ignore_missing_imports = true
implicit_reexport = false
local_partial_types = true
strict_optional = true
strict_equality = true
no_implicit_optional = true
warn_no_return = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unreachable = true
- Python version used: 3.10.10
cc @sobolevn