-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refined type annotations to reflect move to python>=3.7 (#683)
Co-authored-by: Samuel Williams <[email protected]>
- Loading branch information
1 parent
094d446
commit 7c3f6ad
Showing
11 changed files
with
330 additions
and
105 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from __future__ import annotations | ||
import pkg_resources as pkg | ||
import PyInstaller.__main__ as pyi | ||
import os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from __future__ import annotations | ||
import platform | ||
import subprocess as sps | ||
import sys | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
from __future__ import annotations | ||
from typing import Union, Dict, List, Tuple, Callable, Optional, Any, TYPE_CHECKING | ||
from typing_extensions import Literal, TypedDict, TypeAlias | ||
from bottle import Bottle | ||
|
||
# This business is slightly awkward, but needed for backward compatibility, | ||
# because Python < 3.7 doesn't have __future__/annotations, and <3.10 doesn't | ||
# support TypeAlias. | ||
# because Python <3.10 doesn't support TypeAlias, jinja2 may not be available | ||
# at runtime, and geventwebsocket.websocket doesn't have type annotations so | ||
# that direct imports will raise an error. | ||
if TYPE_CHECKING: | ||
from jinja2 import Environment | ||
try: | ||
from typing import TypeAlias # Introduced in Python 3.10 | ||
JinjaEnvironmentT: TypeAlias = Environment | ||
except ImportError: | ||
JinjaEnvironmentT = Environment # type: ignore | ||
JinjaEnvironmentT: TypeAlias = Environment | ||
from geventwebsocket.websocket import WebSocket | ||
WebSocketT = WebSocket | ||
WebSocketT: TypeAlias = WebSocket | ||
else: | ||
JinjaEnvironmentT = None | ||
WebSocketT = Any | ||
JinjaEnvironmentT: TypeAlias = Any | ||
WebSocketT: TypeAlias = Any | ||
|
||
OptionsDictT = Dict[ | ||
str, | ||
Optional[ | ||
Union[ | ||
str, bool, int, float, | ||
List[str], Tuple[int, int], Dict[str, Tuple[int, int]], | ||
Callable[..., Any], JinjaEnvironmentT | ||
] | ||
] | ||
] | ||
OptionsDictT = TypedDict( | ||
'OptionsDictT', | ||
{ | ||
'mode': Optional[Union[str, Literal[False]]], | ||
'host': str, | ||
'port': int, | ||
'block': bool, | ||
'jinja_templates': Optional[str], | ||
'cmdline_args': List[str], | ||
'size': Optional[Tuple[int, int]], | ||
'position': Optional[Tuple[int, int]], | ||
'geometry': Dict[str, Tuple[int, int]], | ||
'close_callback': Optional[Callable[..., Any]], | ||
'app_mode': bool, | ||
'all_interfaces': bool, | ||
'disable_cache': bool, | ||
'default_path': str, | ||
'app': Bottle, | ||
'shutdown_delay': float, | ||
'suppress_error': bool, | ||
'jinja_env': JinjaEnvironmentT, | ||
}, | ||
total=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters