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.
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!