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

ref: ensure_integration_enabled without original function #2893

Conversation

szokeasaurusrex
Copy link
Member

ensure_integration_enabled and ensure_integration_enabled_async can now decorate functions that return None without an original function.

if TYPE_CHECKING:

@overload
def ensure_integration_enabled_async(
Copy link
Member Author

Choose a reason for hiding this comment

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

I am confused about why mypy is complaining about this overload, but not the ones for ensure_integration_enabled. Do you have any idea? Maybe I am missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, no idea. Agree that it looks exactly like the sync case. Maybe we can just ignore the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think that is the best option. Won't affect runtime anyway because we are in an if TYPE_CHECKING guard

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

The more I see of this advanced typing business the less I understand it 😆 But in addition to being the decorator master you're now also the typing master, so I trust this works and gives nice type hints as intended.

Found a couple typos, please fix, otherwise lgtm.

sentry_sdk/utils.py Outdated Show resolved Hide resolved
sentry_sdk/utils.py Outdated Show resolved Hide resolved
szokeasaurusrex and others added 2 commits March 22, 2024 13:18
Co-authored-by: Ivana Kellyerova <[email protected]>
Co-authored-by: Ivana Kellyerova <[email protected]>
@szokeasaurusrex
Copy link
Member Author

The more I see of this advanced typing business the less I understand it 😆 But in addition to being the decorator master you're now also the typing master, so I trust this works and gives nice type hints as intended.

Yeah, at first glance it appears to work. Of course, if you or anyone else notices weird hinting behavior, let me know, and I can look into fixing it.

@szokeasaurusrex szokeasaurusrex merged commit 4fc60aa into sentry-sdk-2.0 Mar 25, 2024
110 of 111 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/ensure-integration-enabled-no-original-func branch March 25, 2024 14:06
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