Skip to content

Switch type hints to strings for 3.4 #27

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

Merged
merged 1 commit into from
Jun 25, 2019

Conversation

c24t
Copy link
Member

@c24t c24t commented Jun 24, 2019

One possible fix for #25.

Since type annotations are evaluated at import time, annotations that refer to classes later in the same module will fail. This is fixed in 3.8, and available as a future import in 3.7. If we want to support python versions older than 3.7 our type annotations need to be strings that evaluate to the right type when the module is finished loading.

@c24t c24t requested a review from Oberon00 June 24, 2019 22:39
Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

This seems to be the only viable solution :)

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

LGTM, Though personally I wouldn't mind using string hints only where required.

@c24t c24t merged commit 132ef43 into open-telemetry:master Jun 25, 2019
@c24t
Copy link
Member Author

c24t commented Jun 25, 2019

I wouldn't mind using string hints only where required

This PR does that, I only changed the annotations that caused errors after removing the future import.

@Oberon00
Copy link
Member

Ok, I see. I was thrown off by the TraceOptions & TraceState change. I guess to avoid strings there we would have to reorder the class definitions.

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