-
Notifications
You must be signed in to change notification settings - Fork 143
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
Only import future for py2 #343
Conversation
2db7bbf
to
c45c8e6
Compare
try: | ||
from future.standard_library import install_aliases | ||
install_aliases() | ||
except ImportError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using try-except
, can we reuse the PY2
variable from compat.py
?
Then this could be something like:
from aws_xray_sdk.core.utils.compat import PY2
if PY2:
from future.standard_library import install_aliases
install_aliases()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting! I took this path because StackOverflow says it was the status quo and I saw it used in OpenTelemetry Python Contrib, but this PY2
looks super useful so I'll change it to that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. That's good to know. :)
Since we already have the other mechanism, I think it would be better to just reuse for the sake of consistency.
c45c8e6
to
245c9c6
Compare
An environment marker is already used for `enum34` so why do it differently for `future`? https://peps.python.org/pep-0508/#environment-markers ref aws#343
Issue #, if available: #212
Description of changes:
If we only import
future
when the SDK is run on Python 2, then we don't need to import it forPython 3
systems. This will prevent conflicts with people downloading conflicting versions of thefuture
package.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Fixes: #212