Skip to content

ref(api): Abstract base classes - #2667

Merged
szokeasaurusrex merged 14 commits into
sentry-sdk-2.0from
szokeasaurusrex/ABCs
Feb 26, 2024
Merged

szokeasaurusrex merged 14 commits into
sentry-sdk-2.0from
szokeasaurusrex/ABCs

Conversation

@szokeasaurusrex

Copy link
Copy Markdown
Member

We have some classes in the SDK that essentially function as abstract classes, since they have some methods that raise NotImplementedError when called, since they are intended to be overriden by a subclass. Now that all supported Python versions support abstract base classes (ABCs), we should refactor these classes to be ABCs. Making this change will explicitly indicate which methods need to be overridden by a subclass.

Changing a public class into an ABC is a breaking change, since instantiating the class, or any subclass that hasn't overridden all abstract methods, will raise an error. Therefore, I have added this (draft) PR to the SDK 2.0 milestone.


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.

@szokeasaurusrex szokeasaurusrex self-assigned this Jan 22, 2024
@szokeasaurusrex szokeasaurusrex added this to the Sentry SDK 2.0 milestone Jan 22, 2024
@szokeasaurusrex
szokeasaurusrex changed the base branch from master to sentry-sdk-2.0 January 22, 2024 17:11
@sentrivana sentrivana removed this from the Sentry SDK 2.0 milestone Feb 15, 2024
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review February 21, 2024 13:31
This change is required because otherwise, the linter complains about the `stop_profiling` being an empty concrete method in an abstract class.

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks ok, see comments. When addressed feel free to merge

Comment thread sentry_sdk/integrations/_wsgi_common.py
Comment thread sentry_sdk/profiler.py Outdated
@szokeasaurusrex
szokeasaurusrex merged commit eca23b8 into sentry-sdk-2.0 Feb 26, 2024
@szokeasaurusrex
szokeasaurusrex deleted the szokeasaurusrex/ABCs branch February 26, 2024 14:29
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.

2 participants