-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-metaclassestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
Bug Report
Mixing a numpy ndarray
with a metaclass that uses keyword arguments causes a false positive.
To Reproduce
Run mypy
on the following code
from typing import Dict, Optional, Tuple
import numpy as np
class Meta(type):
def __new__(
cls, name: str, bases: Tuple[type, ...], dct: Dict, *args,
a: Optional[int] = None, **kwargs
):
return super().__new__(cls, name, bases, dct, *args, **kwargs)
class A(np.ndarray, a=1, metaclass=Meta):
pass
a = A(shape=(2,))
Expected Behavior
Should pass without errors
Actual Behavior
Get the following error:
error: Unexpected keyword argument "a" for "__init_subclass__" of "object"
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.8.6
- Operating system and version: Ubuntu 20.04
AlexanderSalge and qadahtm
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-metaclassestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly