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 typing information for contexts, token #4346

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mrnicegyu11
Copy link

@mrnicegyu11 mrnicegyu11 commented Dec 11, 2024

Description

Trying to get #4164 in.

Opening this 1:1 similar PR for now, with changes from upstream/main, to see how the tests look. Locally, all tests are green.

This is WIP for now.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Ran the tox full test suite locally, all green. Waiting for maintainer approval for the github actions tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Dec 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@mrnicegyu11 mrnicegyu11 changed the title 2024/add/token typing Add typing information for Tokens, etc. Dec 11, 2024
@mrnicegyu11 mrnicegyu11 changed the title Add typing information for Tokens, etc. [WIP] Add typing information for Tokens, etc. Dec 11, 2024
@mrnicegyu11
Copy link
Author

Dear maintainers, on the original PR #4164 I cannot see the details of the github action test failures, to me the code contribution by @hyoinandout looks good and mergeable. If there are incompatabilities with the python-contrib-instrumentations I am willing to look into it, but for this I'd need to see the github-action-results/failures ;)

@mrnicegyu11 mrnicegyu11 changed the title [WIP] Add typing information for Tokens, etc. [WIP] Add typing information for contexts, token Dec 11, 2024
@@ -64,7 +64,7 @@ def test_attach(self):
self.assertEqual("yyy", context.get_value("a"))

with self.assertLogs(level=ERROR):
context.detach("some garbage")
context.detach("some garbage") # type:ignore
Copy link

Choose a reason for hiding this comment

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

Why is the type: ignore needed?

Suggested change
context.detach("some garbage") # type:ignore
context.detach("some garbage") # type: ignore[?]

Copy link
Author

Choose a reason for hiding this comment

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

True thanks this was actually not necessary, slipped past me. I removed the type:ignore

@mrnicegyu11 mrnicegyu11 marked this pull request as ready for review January 2, 2025 08:06
@mrnicegyu11 mrnicegyu11 requested a review from a team as a code owner January 2, 2025 08:06
@mrnicegyu11 mrnicegyu11 changed the title [WIP] Add typing information for contexts, token Add typing information for contexts, token Jan 2, 2025
@mrnicegyu11 mrnicegyu11 requested a review from Kludex January 2, 2025 09:57
Copy link

@Kludex Kludex left a comment

Choose a reason for hiding this comment

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

The opentelemetry/context directory needs to be included in the mypy setup.


Not related to this PR, but I already pointed out that this setup doesn't make sense. mypy needs to run once, and it should have the context of the local imports.

I've shared my thoughts here: open-telemetry/opentelemetry-python-contrib#3116 (comment)

I'm happy to push a PR switching the type checker used here, and I'm happy to help this project to have proper type hints. Otherwise, I think someone should try to make the mypy setup work properly.

I'll bring the above to the next Python SIG meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants