ref(typing): Add additional stub packages for type checking#3122
ref(typing): Add additional stub packages for type checking#3122sentrivana merged 11 commits intogetsentry:masterfrom
Conversation
100da78 to
e247d0c
Compare
Adds `types-webob`, `types-greenlet` and `types-gevent` to linter requirements and fixes newly exposed typing issues. Fixes getsentryGH-2226
e247d0c to
0d3d273
Compare
sentrivana
left a comment
There was a problem hiding this comment.
Thanks @Daverball, looks good to me overall. I left two comments, could you please take a look?
| from gevent.threadpool import ThreadPool as _ThreadPool | ||
|
|
||
| ThreadPool = _ThreadPool # type: Optional[Type[_ThreadPool]] |
There was a problem hiding this comment.
If we don't do this, then mypy will complain about redefinition of ThreadPool to None in the except clause. So the type and the variable need a separate name, so I can use the type separately from the runtime variable.
| Union, | ||
| ) | ||
|
|
||
| from gevent.hub import Hub |
There was a problem hiding this comment.
Since gevent is an optional dependency, won't this break type checking for folks that don't have it installed? Would a conditional import help in any way?
There was a problem hiding this comment.
There's no conditional imports for typing unfortunately. So yes, if people leave follow_imports at normal for sentry_sdk they will see an error if they don't have types-gevent installed, but the same is true for any of the other typing only dependencies that are only listed in dev-requirements.txt, so this would be nothing new.
Generally the expectation with type hints is that people are responsible for managing typing- requirements and otherwise silence the errors by setting follow_imports to silent or skip.
Adds `types-webob`, `types-greenlet` and `types-gevent` to linter requirements and fixes newly exposed typing issues.
…y#3122) Adds `types-webob`, `types-greenlet` and `types-gevent` to linter requirements and fixes newly exposed typing issues.
Adds
types-webob,types-greenletandtypes-geventto linter requirements and fixes newly exposed typing issues.Fixes #2226