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

Why _types.finfo_object and _types.iinfo_object, _array_object._array does not inherit Protocol ? #856

Open
34j opened this issue Nov 24, 2024 · 0 comments · May be fixed by #857
Open

Why _types.finfo_object and _types.iinfo_object, _array_object._array does not inherit Protocol ? #856

34j opened this issue Nov 24, 2024 · 0 comments · May be fixed by #857
Labels
topic: Static Typing Static typing.

Comments

@34j
Copy link

34j commented Nov 24, 2024

@dataclass
class finfo_object:
"""Dataclass returned by `finfo`."""
bits: int
eps: float
max: float
min: float
smallest_normal: float
dtype: dtype
@dataclass
class iinfo_object:
"""Dataclass returned by `iinfo`."""
bits: int
max: int
min: int
dtype: dtype

 class finfo_object(Protocol[dtype]): 
     """Dataclass returned by `finfo`.""" 
  
     bits: int 
     eps: float 
     max: float 
     min: float 
     smallest_normal: float 
     dtype: dtype 
  
  
 class iinfo_object(Protocol[dtype]): 
     """Dataclass returned by `iinfo`.""" 
  
     bits: int 
     max: int 
     min: int 
     dtype: dtype 

I wonder why they are defined as dataclass

class _array:
def __init__(self: array) -> None:

array = TypeVar("array", bound="_array")

class _array(Protocol[Device, Dtype, PyCapsule, array])
	def __add__(self, other: Union[int, float, array], /) -> array:
@34j 34j changed the title Why _types.finfo_object and _types.iinfo_object does not inherit Protocol[dtype] ? Why _types.finfo_object and _types.iinfo_object, _array_object._array does not inherit Protocol ? Nov 24, 2024
@34j 34j linked a pull request Nov 24, 2024 that will close this issue
@rgommers rgommers added the topic: Static Typing Static typing. label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: Static Typing Static typing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants