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

Add type hints to BaseInstrumentor #3084

Merged

Conversation

Kludex
Copy link
Contributor

@Kludex Kludex commented Dec 10, 2024

No description provided.

@Kludex Kludex requested a review from a team as a code owner December 10, 2024 15:40
@emdneto emdneto added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Dec 10, 2024
Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why only to this type? Is it mainly to lower risk?

I'm new to python and thought this was a python 3.10 change but as tests pass must be all good. Maybe someone can teach me why Optional[str] -> str | None passes on all versions we test!

@Kludex
Copy link
Contributor Author

Kludex commented Dec 11, 2024

This project is not very familiar with modern typing. I'm trying to be mindful and create minimal PRs to spread the knowledge, and move faster.

When you use from __future__ import annotations, at runtime Python will not look at the type hints, which allow us to use notation from future Python versions. Note that even if the notation is only introduced on newer versions, the Python parser can still parse the code, so we don't have any issue.

@codefromthecrypt
Copy link
Contributor

@Kludex hero level explanation. thanks for teaching me!

@xrmx xrmx merged commit 7804e0a into open-telemetry:main Dec 11, 2024
573 of 574 checks passed
@Kludex Kludex deleted the add-type-hints-to-base-instrumentor branch December 11, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants