-
Notifications
You must be signed in to change notification settings - Fork 651
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
Added generic to textmap getter and setter #2657
Conversation
@alanisaac Is there anything pending or is it ready to be reviewed? |
@srikanthccv thanks for the ping. I think this is ready for review, though I'm not sure if this requires the public API / changelog items in the checks. Let me know what else I can do. |
I see the public API check says:
This PR does not introduce these symbols, but does make them |
I think this should work in the library itself, but as this is my first PR for this repo I'm not sure about how the downstream effects on the contrib repo are handled. I imagine the contrib repo is also type checking, and if so, when integrated, this PR would break those checks as the signatures are slightly different? I can create a PR there as well if needed. |
There aren't any type checks running on contrib packages. |
Description
Add
Generic[CarrierT]
totextmap.Getter
andtextmap.Setter
in order to allow inherited classes to be typed properly.Ultimately, the default
getter
andsetter
work with more specific types thanCarrierT
. That means we need to either work with a complex system of overloads or alternatively lie to the type system at some point.The original code did this through
# type: ignore
on the function signatures of inherited classes fromGetter
andSetter
. But that means any inherited classes in a type-checked context need to do the same. This PR just lies to the type system in a different place: instead declaringdefault_getter
anddefault_setter
as typed generically but ignoring the fact that the classesDefaultGetter
andDefaultSetter
are not.Fixes #2656
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
tox -e mypy
to verify changes locallyDoes This PR Require a Contrib Repo Change?
Answer the following question based on these examples of changes that would require a Contrib Repo Change:
The OTel specification has changed which prompted this PR to update the method interfaces of
opentelemetry-api/
oropentelemetry-sdk/
The method interfaces of
test/util
have changedScripts in
scripts/
that were copied over to the Contrib repo have changedConfiguration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in
pyproject.toml
isort.cfg
.flake8
When a new
.github/CODEOWNER
is addedMajor changes to project information, such as in:
README.md
CONTRIBUTING.md
No. See Added generic to textmap getter and setter #2657 (comment)
Checklist: