You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a generic Serializer class which declares a serialize(...) method. My issue is that the superclass abstract method uses a generic parameter name (o) which is hidden by a positional-only / (PEP570). while I would like to use more descriptive parameter names in my subclasses. All uses of this class will pass-by-position, never by name.
from abc import ABC, abstractmethod
from typing import Generic, TypeVar
from overrides import overrides
T = TypeVar("T")
class Serializer(Generic[T], ABC):
@abstractmethod
def serialize(self, o: T, /) -> bytes:
raise NotImplementedError()
class MyDataSerializer(Serializer[object]):
@overrides
def serialize(self, data: object, /) -> bytes:
pass
The above example raises a TypeError on overrides==6.1.0.
TypeError: MyDataSerializer.serialize: data is not a valid parameter.
I can see the necessity of name-checking when parameter names can be used directly. However, when used with PEP570 I would like to see parameters only validated by the type at each ordinal/position and to ignore the name.
Thanks!
The text was updated successfully, but these errors were encountered:
Hello!
I have a generic Serializer class which declares a
serialize(...)
method. My issue is that the superclass abstract method uses a generic parameter name (o
) which is hidden by a positional-only/
(PEP570). while I would like to use more descriptive parameter names in my subclasses. All uses of this class will pass-by-position, never by name.The above example raises a TypeError on
overrides==6.1.0
.I can see the necessity of name-checking when parameter names can be used directly. However, when used with PEP570 I would like to see parameters only validated by the type at each ordinal/position and to ignore the name.
Thanks!
The text was updated successfully, but these errors were encountered: