-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add type signature for a WSGI Application to wsgiref. #725
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
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Type declaration for a WSGI Function in Python 2 | ||
# | ||
# wsgiref/typing.py doesn't exist and neither does WSGIApplication, it's a type | ||
# provided for type checking purposes. | ||
# | ||
# To correctly use this type stub, utilize the `TYPE_CHECKING` flag in | ||
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. utilize -> use |
||
# typing: | ||
# | ||
# from typing import TYPE_CHECKING | ||
# | ||
# if TYPE_CHECKING: | ||
# from wsgiref import WSGIFunction | ||
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. Change to |
||
# | ||
|
||
from typing import Callable, Iterable, List, Optional, Tuple, Type, Union | ||
from types import TracebackType | ||
|
||
_exc_info = Tuple[Optional[Type[BaseException]], | ||
Optional[BaseException], | ||
Optional[TracebackType]] | ||
WSGIApplication = Callable[[Dict[Union[unicode, str], Union[unicode, str]], | ||
Union[ | ||
Callable[[Union[unicode, str], List[Tuple[Union[unicode, str], Union[unicode, str]]]], Callable[[Union[unicode, str]], None]], | ||
Callable[[Union[unicode, str], List[Tuple[Union[unicode, str], Union[unicode, str]]], _exc_info], Callable[[Union[unicode, str]], None]] | ||
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. This is pretty unreadable. Maybe you can clear it up a bit using some more type aliases? (An added benefit might be that there are fewer differences between PY2 and PY3.) |
||
]], | ||
Iterable[Union[unicode, str]]] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Type declaration for a WSGI Function in Python 3 | ||
# | ||
# wsgiref/typing.py doesn't exist and neither does WSGIApplication, it's a type | ||
# provided for type checking purposes. | ||
# | ||
# To correctly use this type stub, utilize the `TYPE_CHECKING` flag in | ||
# typing: | ||
# | ||
# from typing import TYPE_CHECKING | ||
# | ||
# if TYPE_CHECKING: | ||
# from wsgiref import WSGIFunction | ||
# | ||
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. In the PY3 version (but not in the PY2 version) you should also tell users to use "forward reference" notation when using this (except in |
||
|
||
from typing import Callable, Iterable, List, Optional, Tuple, Type, Union | ||
from types import TracebackType | ||
|
||
_exc_info = Tuple[Optional[Type[BaseException]], | ||
Optional[BaseException], | ||
Optional[TracebackType]] | ||
WSGIApplication = Callable[[Dict[str, str], | ||
Union[ | ||
Callable[[str, List[Tuple[str, str]]], Callable[[Union[bytes, str]], None]], | ||
Callable[[str, List[Tuple[str, str]], _exc_info], Callable[[Union[bytes, str]], None]] | ||
]], | ||
Iterable[Union[bytes, str]]] |
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.
typing -> types