Is your feature request related to a problem?
Currently, if I inherit a custom textmap.Getter or textmap.Setter, I can't properly type hint it. For example, take this class:
from opentelemetry.propagators.textmap import Getter
from typing import Dict, Optional, List
class SimpleGetter(Getter):
def get(
self, carrier: Dict[str, List[str]], key: str
) -> Optional[List[str]]:
return carrier[key]
When checked with mypy==0.920:
main.py:6: error: Argument 1 of "get" is incompatible with supertype "Getter"; supertype defines the argument type as "CarrierT"
main.py:6: note: This violates the Liskov substitution principle
main.py:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
If I try to type hint carrier with the CarrierT TypeVar:
main.py:9: error: Value of type "CarrierT" is not indexable
Found 1 error in 1 file (checked 1 source file)
Describe the solution you'd like
Could Getter and Setter should be marked / inherit from Generic[CarrierT], so the specific TCarrier type can be defined? Happy to contribute a PR.
Describe alternatives you've considered
N/A
Additional context
Note: I see from #1690 that this could be somewhat more complicated. Specifically #1690 (comment)
Is your feature request related to a problem?
Currently, if I inherit a custom
textmap.Getterortextmap.Setter, I can't properly type hint it. For example, take this class:When checked with
mypy==0.920:If I try to type hint
carrierwith theCarrierTTypeVar:Describe the solution you'd like
Could
GetterandSettershould be marked / inherit fromGeneric[CarrierT], so the specificTCarriertype can be defined? Happy to contribute a PR.Describe alternatives you've considered
N/A
Additional context
Note: I see from #1690 that this could be somewhat more complicated. Specifically #1690 (comment)