Remove compatibility utils for old Python#2645
Conversation
Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Thanks for addressing everything!
Looks good, I left a small nitpick you can consider changing before we merge
sentry_sdk/tracing.py
Outdated
| from typing import Iterator | ||
| from typing import List | ||
| from typing import Mapping | ||
| from collections.abc import Mapping |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The goal of this PR is to remove Python 2.7 and 3.5 compatibility utils from
_compat.pyand 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 secretslabel. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.