-
Notifications
You must be signed in to change notification settings - Fork 500
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(typing): Add additional stub packages for type checking #3122
Changes from 9 commits
0d3d273
d10b5de
fd3433f
3eaca55
079e38a
536b3e3
42702d1
a654915
3e6d871
135c85b
760249e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
gevent | ||
shibuya | ||
sphinx==7.2.6 | ||
sphinx-autodoc-typehints[type_comments]>=1.8.0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ | |
Union, | ||
) | ||
|
||
from gevent.hub import Hub | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no conditional imports for typing unfortunately. So yes, if people leave Generally the expectation with type hints is that people are responsible for managing |
||
|
||
import sentry_sdk.integrations | ||
from sentry_sdk._types import Event, ExcInfo | ||
|
||
|
@@ -1182,8 +1184,8 @@ def _is_contextvars_broken(): | |
Returns whether gevent/eventlet have patched the stdlib in a way where thread locals are now more "correct" than contextvars. | ||
""" | ||
try: | ||
import gevent # type: ignore | ||
from gevent.monkey import is_object_patched # type: ignore | ||
import gevent | ||
from gevent.monkey import is_object_patched | ||
|
||
# Get the MAJOR and MINOR version numbers of Gevent | ||
version_tuple = tuple( | ||
|
@@ -1209,7 +1211,7 @@ def _is_contextvars_broken(): | |
pass | ||
|
||
try: | ||
import greenlet # type: ignore | ||
import greenlet | ||
from eventlet.patcher import is_monkey_patched # type: ignore | ||
|
||
greenlet_version = parse_version(greenlet.__version__) | ||
|
@@ -1794,12 +1796,14 @@ def now(): | |
from gevent.monkey import is_module_patched | ||
except ImportError: | ||
|
||
def get_gevent_hub(): | ||
# type: () -> Any | ||
# it's not great that the signatures are different, get_hub can't return None | ||
# consider adding an if TYPE_CHECKING to change the signature to Optional[Hub] | ||
def get_gevent_hub(): # type: ignore[misc] | ||
# type: () -> Optional[Hub] | ||
return None | ||
|
||
def is_module_patched(*args, **kwargs): | ||
# type: (*Any, **Any) -> bool | ||
def is_module_patched(mod_name): | ||
# type: (str) -> bool | ||
# unable to import from gevent means no modules have been patched | ||
return False | ||
|
||
|
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.
Why is this necessary?
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.
If we don't do this, then mypy will complain about redefinition of
ThreadPool
toNone
in theexcept
clause. So the type and the variable need a separate name, so I can use the type separately from the runtime variable.