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

Remove compatibility utils for old Python #2645

Merged
merged 11 commits into from
Jan 16, 2024

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Jan 16, 2024

The goal of this PR is to remove Python 2.7 and 3.5 compatibility utils from _compat.py and replace them with their Python 3.6+ equivalents throughout the codebase.

Note: This PR removes some import handling for imports that are different between py2 and py3, but not all -- this will be done in a separate PR.


General Notes

Thank you for contributing to sentry-python!

Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.

For maintainers

Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.

Before running sensitive test suites, please carefully check the PR. Then, apply the Trigger: tests using secrets label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.

@sentrivana sentrivana marked this pull request as ready for review January 16, 2024 12:11
@sentrivana sentrivana self-assigned this Jan 16, 2024
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Left some comments

sentry_sdk/_compat.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/__init__.py Show resolved Hide resolved
sentry_sdk/integrations/_wsgi_common.py Show resolved Hide resolved
sentry_sdk/integrations/_wsgi_common.py Show resolved Hide resolved
sentry_sdk/tracing.py Outdated Show resolved Hide resolved
sentry_sdk/tracing.py Show resolved Hide resolved
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Thanks for addressing everything!

Looks good, I left a small nitpick you can consider changing before we merge

sentry_sdk/integrations/_wsgi_common.py Show resolved Hide resolved
@@ -14,7 +14,7 @@
from typing import Dict
from typing import Iterator
from typing import List
from typing import Mapping
from collections.abc import Mapping
Copy link
Member

Choose a reason for hiding this comment

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

Small nitpick (feel free to leave unchanged): Now that you changed this line to import from collections.abc instead of from typing, it is a bit weird that it is surrounded by typing imports. Could you reorder this import to be above all the typing imports?

On a related note, it would be nice if we could use some kind of automatic Python formatting tool to automatically enforce alphabetical ordering for imports. Something like this exists in Rust, and I find that it helps keep code more organized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are multiple tools for this in Python, too, e.g. isort. Would be very happy to have this automated at some point. Will change the order here manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: 3110117

sentry_sdk/tracing.py Show resolved Hide resolved
@sentrivana sentrivana enabled auto-merge (squash) January 16, 2024 16:45
@sentrivana sentrivana merged commit 2d354c7 into sentry-sdk-2.0 Jan 16, 2024
110 checks passed
@sentrivana sentrivana deleted the ivana/py2.7/remove-compat branch January 16, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants