-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix some typing issues #2841
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
Merged
Merged
fix some typing issues #2841
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
import base64 | ||
import traceback | ||
from urllib.parse import urlparse | ||
from typing import Any, Callable, Dict, Optional, Union | ||
from typing import Any, Callable, Dict, Optional, Union, List | ||
|
||
import flask | ||
|
||
|
@@ -175,11 +175,13 @@ def _do_skip(error): | |
|
||
# werkzeug<2.1.0 | ||
if hasattr(tbtools, "get_current_traceback"): | ||
return tbtools.get_current_traceback(skip=_get_skip(error)).render_full() | ||
return tbtools.get_current_traceback( # type: ignore | ||
skip=_get_skip(error) | ||
).render_full() | ||
|
||
if hasattr(tbtools, "DebugTraceback"): | ||
# pylint: disable=no-member | ||
return tbtools.DebugTraceback( | ||
return tbtools.DebugTraceback( # type: ignore | ||
error, skip=_get_skip(error) | ||
).render_debugger_html(True, secret, True) | ||
|
||
|
@@ -378,41 +380,47 @@ class Dash: | |
_plotlyjs_url: str | ||
STARTUP_ROUTES: list = [] | ||
|
||
server: flask.Flask | ||
|
||
def __init__( # pylint: disable=too-many-statements | ||
self, | ||
name=None, | ||
server=True, | ||
assets_folder="assets", | ||
pages_folder="pages", | ||
use_pages=None, | ||
assets_url_path="assets", | ||
assets_ignore="", | ||
assets_external_path=None, | ||
eager_loading=False, | ||
include_assets_files=True, | ||
include_pages_meta=True, | ||
url_base_pathname=None, | ||
requests_pathname_prefix=None, | ||
routes_pathname_prefix=None, | ||
serve_locally=True, | ||
compress=None, | ||
meta_tags=None, | ||
index_string=_default_index, | ||
external_scripts=None, | ||
external_stylesheets=None, | ||
suppress_callback_exceptions=None, | ||
prevent_initial_callbacks=False, | ||
show_undo_redo=False, | ||
extra_hot_reload_paths=None, | ||
plugins=None, | ||
title="Dash", | ||
update_title="Updating...", | ||
long_callback_manager=None, | ||
background_callback_manager=None, | ||
add_log_handler=True, | ||
hooks: Union[RendererHooks, None] = None, | ||
name: Optional[str] = None, | ||
server: Union[bool, flask.Flask] = True, | ||
assets_folder: str = "assets", | ||
pages_folder: str = "pages", | ||
use_pages: Optional[bool] = None, | ||
assets_url_path: str = "assets", | ||
assets_ignore: str = "", | ||
assets_external_path: Optional[str] = None, | ||
eager_loading: bool = False, | ||
include_assets_files: bool = True, | ||
include_pages_meta: bool = True, | ||
url_base_pathname: Optional[str] = None, | ||
requests_pathname_prefix: Optional[str] = None, | ||
routes_pathname_prefix: Optional[str] = None, | ||
serve_locally: bool = True, | ||
compress: Optional[bool] = None, | ||
meta_tags: Optional[List[Dict[str, Any]]] = None, | ||
index_string: str = _default_index, | ||
external_scripts: Optional[List[Union[str, Dict[str, Any]]]] = None, | ||
external_stylesheets: Optional[List[Union[str, Dict[str, Any]]]] = None, | ||
Comment on lines
+403
to
+406
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. Those |
||
suppress_callback_exceptions: Optional[bool] = None, | ||
prevent_initial_callbacks: bool = False, | ||
show_undo_redo: bool = False, | ||
extra_hot_reload_paths: Optional[List[str]] = None, | ||
plugins: Optional[list] = None, | ||
title: str = "Dash", | ||
update_title: str = "Updating...", | ||
long_callback_manager: Optional[ | ||
Any | ||
] = None, # Type should be specified if possible | ||
background_callback_manager: Optional[ | ||
Any | ||
] = None, # Type should be specified if possible | ||
Comment on lines
+414
to
+419
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. Both of those should be of type |
||
add_log_handler: bool = True, | ||
hooks: Optional[RendererHooks] = None, | ||
routing_callback_inputs: Optional[Dict[str, Union[Input, State]]] = None, | ||
description=None, | ||
description: Optional[str] = None, | ||
on_error: Optional[Callable[[Exception], Any]] = None, | ||
**obsolete, | ||
): | ||
|
@@ -428,7 +436,7 @@ def __init__( # pylint: disable=too-many-statements | |
name = getattr(server, "name", caller_name) | ||
elif isinstance(server, bool): | ||
name = name if name else caller_name | ||
self.server = flask.Flask(name) if server else None | ||
self.server = flask.Flask(name) if server else None # type: ignore | ||
else: | ||
raise ValueError("server must be a Flask app or a boolean") | ||
|
||
|
@@ -440,7 +448,7 @@ def __init__( # pylint: disable=too-many-statements | |
name=name, | ||
assets_folder=os.path.join( | ||
flask.helpers.get_root_path(name), assets_folder | ||
), | ||
), # type: ignore | ||
assets_url_path=assets_url_path, | ||
assets_ignore=assets_ignore, | ||
assets_external_path=get_combined_config( | ||
|
@@ -546,7 +554,9 @@ def __init__( # pylint: disable=too-many-statements | |
if not self.logger.handlers and add_log_handler: | ||
self.logger.addHandler(logging.StreamHandler(stream=sys.stdout)) | ||
|
||
if isinstance(plugins, patch_collections_abc("Iterable")): | ||
if plugins is not None and isinstance( | ||
plugins, patch_collections_abc("Iterable") | ||
): | ||
for plugin in plugins: | ||
plugin.plug(self) | ||
|
||
|
@@ -1961,7 +1971,7 @@ def run( | |
port="8050", | ||
proxy=None, | ||
debug=None, | ||
jupyter_mode: JupyterDisplayMode = None, | ||
jupyter_mode: Optional[JupyterDisplayMode] = None, | ||
jupyter_width="100%", | ||
jupyter_height=650, | ||
jupyter_server_url=None, | ||
|
@@ -2096,7 +2106,7 @@ def run( | |
port = int(port) | ||
assert port in range(1, 65536) | ||
except Exception as e: | ||
e.args = [f"Expecting an integer from 1 to 65535, found port={repr(port)}"] | ||
e.args = (f"Expecting an integer from 1 to 65535, found port={repr(port)}",) | ||
raise | ||
|
||
# so we only see the "Running on" message once with hot reloading | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we can add
server: flask.Flask
here.