Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = C901, E203, E266, E501, E731, W503
ignore = C901, E203, E266, E501, E704, E731, W503
select = B,C,E,F,W,T4
exclude = node_modules,metadata_test.py
per-file-ignores =
Expand Down
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ disable=fixme,
unnecessary-lambda-assignment,
broad-exception-raised,
consider-using-generator,
too-many-ancestors
too-many-ancestors,
too-many-positional-arguments


# Enable the message, report, category or checker with the given id(s). You can
Expand Down
2 changes: 1 addition & 1 deletion components/dash-core-components/.flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = C901, E203, E231, E266, E501, E731, W503
ignore = C901, E203, E231, E266, E501, E704, E731, W503
select = B,C,E,F,W,T4
per-file-ignores =
tests/*: E722, F811
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,13 @@ def resize(n_clicks, style):
initial_height = (
360
if (initial_responsive and (height is None or is_responsive is True))
else 450
if height is None
else height
else 450 if height is None else height
)

resize_height = (
260
if (resize_responsive and (height is None or is_responsive is True))
else initial_height
if height is None
else height
else initial_height if height is None else height
)

# 500px card minus (100px header + 20px padding) minus (20px padding on container) -> 360px left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def test_mspl001_dcc_components_platter(platter_app, dash_dcc):
dash_dcc.percy_snapshot("gallery")

dash_dcc.find_element("#dropdown").click()
dash_dcc.find_element(".dash-dropdown-content .dash-dropdown-search").send_keys("北")
dash_dcc.find_element(".dash-dropdown-content .dash-dropdown-search").send_keys(
"北"
)
dash_dcc.percy_snapshot("gallery - chinese character")

text_input = dash_dcc.find_element("#textinput")
Expand Down
2 changes: 1 addition & 1 deletion components/dash-table/.flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = C901, E203, E231, E266, E501, E731, W503
ignore = C901, E203, E231, E266, E501, E704, E731, W503
select = B,C,E,F,W,T4
per-file-ignores =
tests/*: E722, F811
4 changes: 1 addition & 3 deletions components/dash-table/dash_table_base/Format.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ def groups(self, groups):
groups = (
groups
if isinstance(groups, list)
else [groups]
if isinstance(groups, int)
else None
else [groups] if isinstance(groups, int) else None
)

if not isinstance(groups, list):
Expand Down
4 changes: 2 additions & 2 deletions components/dash-table/tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def null_decorator(f):
def decorate(f):
fspec = inspect.getfullargspec(f)

for (appargs, closureargs, p) in precinfo:
for appargs, closureargs, p in precinfo:
for apparg in appargs:
if apparg not in fspec.args:
raise PreconditionError(
Expand All @@ -78,7 +78,7 @@ def decorate(f):
@wraps(f)
def g(*a, **kw):
args = inspect.getcallargs(f, *a, **kw)
for (appargs, _, p) in precinfo:
for appargs, _, p in precinfo:
if not p(*[args[aa] for aa in appargs]):
raise PreconditionError(
"Precondition failed in call {!r}{}:\n {!s}\n".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_data(timestamp, current, previous):

modified = False
if len(current) == len(previous):
for (i, datum) in enumerate(current):
for i, datum in enumerate(current):
previous_datum = previous[i]

if datum["Unnamed: 0"] != previous_datum["Unnamed: 0"]:
Expand Down
60 changes: 36 additions & 24 deletions components/dash-table/tests/selenium/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,38 @@ def test_filt002_sensitivity(test, filter_case_options, column_case_filter_optio
dict(
id="a",
name="a",
filter_options=dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None,
filter_options=(
dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None
),
type="any",
),
dict(
id="b",
name="b",
filter_options=dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None,
filter_options=(
dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None
),
type="text",
),
dict(
id="c",
name="c",
filter_options=dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None,
filter_options=(
dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None
),
type="numeric",
),
],
filter_action="native",
filter_options=dict(case=filter_case_options)
if filter_case_options is not None
else None,
filter_options=(
dict(case=filter_case_options) if filter_case_options is not None else None
),
style_cell=dict(width=100, min_width=100, max_width=100),
)

Expand Down Expand Up @@ -221,9 +227,11 @@ def test_filt003_sensitivity(test, filter_case_options, column_case_filter_optio
dict(
id="a",
name="a",
filter_options=dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None,
filter_options=(
dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None
),
type="any",
),
dict(
Expand All @@ -235,16 +243,18 @@ def test_filt003_sensitivity(test, filter_case_options, column_case_filter_optio
dict(
id="c",
name="c",
filter_options=dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None,
filter_options=(
dict(case=column_case_filter_options)
if column_case_filter_options is not None
else None
),
type="numeric",
),
],
filter_action="native",
filter_options=dict(case=filter_case_options)
if filter_case_options is not None
else None,
filter_options=(
dict(case=filter_case_options) if filter_case_options is not None else None
),
style_cell=dict(width=100, min_width=100, max_width=100),
)

Expand Down Expand Up @@ -341,9 +351,11 @@ def test_filt004_placeholder(
),
],
filter_action="native",
filter_options=dict(placeholder_text=table_placeholder_setting)
if table_placeholder_setting is not None
else None,
filter_options=(
dict(placeholder_text=table_placeholder_setting)
if table_placeholder_setting is not None
else None
),
)

test.start_server(get_app(props))
Expand Down
8 changes: 5 additions & 3 deletions components/dash-table/tests/selenium/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def test_head001_renames_only_row(test, row):

for i in range(3):
wait.until(
lambda: target.column("rows").get_text(i) == "modified"
if row == i
else title[i],
lambda: (
target.column("rows").get_text(i) == "modified"
if row == i
else title[i]
),
3,
)

Expand Down
10 changes: 6 additions & 4 deletions components/dash-table/tests/selenium/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ def get_mixed_markdown_table():
data = [
{
"not-markdown-column": "this is not a markdown cell",
"markdown-column": """```javascript
"markdown-column": (
"""```javascript
console.warn("this is a markdown cell")```"""
if i % 2 == 0
else """```javascript
if i % 2 == 0
else """```javascript
console.log("logging things")
console.warn("this is a markdown cell")
```""",
```"""
),
"also-not-markdown-column": str(i),
"also-also-not-markdown-column": "this is also also not a markdown cell",
}
Expand Down
10 changes: 6 additions & 4 deletions components/dash-table/tests/selenium/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ def generate_mixed_markdown_data(rows=100):
data=[
{
"not-markdown-column": "this is not a markdown cell",
"markdown-column": """```javascript
"markdown-column": (
"""```javascript
console.warn("this is a markdown cell")
```"""
if i % 2 == 0
else """```javascript
if i % 2 == 0
else """```javascript
console.log("logging things")
console.warn("this is a markdown cell")
```""",
```"""
),
"also-not-markdown-column": i,
"also-also-not-markdown-column": "this is also also not a markdown cell",
}
Expand Down
8 changes: 5 additions & 3 deletions dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,11 @@ def _setup_background_callback(
func,
func_args if func_args else func_kwargs,
background.get("cache_args_to_ignore", []),
None
if cache_ignore_triggered
else callback_ctx.get("triggered_inputs", []),
(
None
if cache_ignore_triggered
else callback_ctx.get("triggered_inputs", [])
),
callback_key=background_key,
)
job_fn = callback_manager.func_registry.get(background_key)
Expand Down
6 changes: 3 additions & 3 deletions dash/_callback_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from ._get_app import get_app
from ._utils import AttributeDict, stringify_id

context_value: contextvars.ContextVar[
typing.Dict[str, typing.Any]
] = contextvars.ContextVar("callback_context")
context_value: contextvars.ContextVar[typing.Dict[str, typing.Any]] = (
contextvars.ContextVar("callback_context")
)
context_value.set({})


Expand Down
1 change: 1 addition & 0 deletions dash/_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
structure

"""

from .exceptions import InvalidCallbackReturnValue
from ._utils import AttributeDict, stringify_id

Expand Down
1 change: 0 additions & 1 deletion dash/_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def _custom_formatargvalues(
formatvarkw=lambda name: "**" + name,
formatvalue=lambda value: "=" + repr(value),
):

"""Copied from inspect.formatargvalues, modified to place function
arguments on separate lines"""

Expand Down
8 changes: 2 additions & 6 deletions dash/_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,14 @@
title=(
title
if title is not None
else CONFIG.title
if CONFIG.title != "Dash"
else page["name"]
else CONFIG.title if CONFIG.title != "Dash" else page["name"]
),
)
page.update(
description=(
description
if description
else CONFIG.description
if CONFIG.description
else ""
else CONFIG.description if CONFIG.description else ""

Check warning on line 324 in dash/_pages.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested conditional expression into an independent statement.

See more on https://sonarcloud.io/project/issues?id=plotly_dash&issues=AaF-AkhYrATBMaubWXyI&open=AaF-AkhYrATBMaubWXyI&pullRequest=4089
),
order=order,
supplied_order=order,
Expand Down
6 changes: 3 additions & 3 deletions dash/_shared_storage/_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def __init__(self, directory: str, chunk_size: int = _CHUNK_SIZE):
self._chunk_size = chunk_size
self._lock = threading.RLock()
self._keys: Dict[str, int] = {} # key -> chunk_num
self._chunks: Dict[
int, Dict[str, Any]
] = {} # chunk_num -> {key: [value, expire_at]}
self._chunks: Dict[int, Dict[str, Any]] = (
{}
) # chunk_num -> {key: [value, expire_at]}
self._loaded = False
os.makedirs(self._dir, exist_ok=True)

Expand Down
1 change: 1 addition & 0 deletions dash/_shared_storage/_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
``run_in_executor`` call in the process. It polls without waiting and sleeps on
the loop between polls instead.
"""

import asyncio
import threading
from typing import Callable
Expand Down
15 changes: 5 additions & 10 deletions dash/_shared_storage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,13 @@ def poll(self, timeout: float = 0.0) -> List[Tuple[int, Any]]:
at least one. Raises ``SharedStorageGap`` if the buffer overran."""

@abc.abstractmethod
def iter_with_seq(self) -> Iterator[Any]:
...
def iter_with_seq(self) -> Iterator[Any]: ...

@abc.abstractmethod
def aiter_with_seq(self) -> AsyncIterator[Any]:
...
def aiter_with_seq(self) -> AsyncIterator[Any]: ...

@abc.abstractmethod
def close(self) -> None:
...
def close(self) -> None: ...

def __iter__(self) -> Iterator[Any]:
for _seq, message in self.iter_with_seq():
Expand Down Expand Up @@ -128,8 +125,7 @@ def close(self) -> None:
"""Release this worker's handle on the backend. Idempotent."""

@abc.abstractmethod
def get(self, key: str, default: Any = None) -> Any:
...
def get(self, key: str, default: Any = None) -> Any: ...

@abc.abstractmethod
def set(self, key: str, value: Any, ttl: Optional[float] = None) -> None:
Expand All @@ -142,8 +138,7 @@ def set(self, key: str, value: Any, ttl: Optional[float] = None) -> None:
"""

@abc.abstractmethod
def delete(self, key: str) -> None:
...
def delete(self, key: str) -> None: ...

@abc.abstractmethod
def publish(self, topic: str, message: Any, ttl: Optional[float] = None) -> None:
Expand Down
1 change: 1 addition & 0 deletions dash/_shared_storage/diskcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
and every key of the topic expires together once nobody has published to or
polled it for that long, so abandoned topics leave the cache.
"""

import time
from typing import Any, Optional

Expand Down
Loading
Loading