Skip to content

Commit

Permalink
refactor: apply preview fixes for existing ruff rules, reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned committed Jun 5, 2024
1 parent 5ba210d commit 8ef6184
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 26 deletions.
18 changes: 9 additions & 9 deletions altair/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@


__all__ = (
"infer_vegalite_type",
"AltairDeprecationWarning",
"PluginRegistry",
"SchemaBase",
"Undefined",
"display_traceback",
"infer_encoding_types",
"sanitize_dataframe",
"infer_vegalite_type",
"parse_shorthand",
"sanitize_arrow_table",
"sanitize_dataframe",
"spec_to_html",
"parse_shorthand",
"use_signature",
"update_nested",
"display_traceback",
"AltairDeprecationWarning",
"SchemaBase",
"Undefined",
"PluginRegistry",
"use_signature",
)
2 changes: 1 addition & 1 deletion altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def to_list_if_array(val):
col = df[col_name]
bad_values = col.isnull() | np.isinf(col)
df[col_name] = col.astype(object).where(~bad_values, None)
elif dtype == object:
elif dtype == object: # noqa: E721
# Convert numpy arrays saved as objects to lists
# Arrays are not JSON serializable
col = df[col_name].astype(object).apply(to_list_if_array)
Expand Down
2 changes: 1 addition & 1 deletion altair/utils/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def split_into_equal_parts(n: int, p: int) -> List[int]:
for ch in column_heights:
param_names_columns.append(param_names[last_end_idx : last_end_idx + ch])
column_max_widths.append(
max([len(param_name) for param_name in param_names_columns[-1]])
max(len(param_name) for param_name in param_names_columns[-1])
)
last_end_idx = ch + last_end_idx

Expand Down
4 changes: 2 additions & 2 deletions altair/vegalite/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def disable_max_rows(self) -> PluginEnabler:
__all__ = (
"DataTransformerRegistry",
"MaxRowsError",
"check_data_type",
"curry",
"sanitize_dataframe",
"default_data_transformer",
"limit_rows",
"pipe",
"sample",
"sanitize_dataframe",
"to_csv",
"to_json",
"to_values",
"check_data_type",
)
6 changes: 3 additions & 3 deletions altair/vegalite/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@


__all__ = (
"DefaultRendererReturnType",
"Displayable",
"HTMLRenderer",
"RendererRegistry",
"default_renderer_base",
"json_renderer_base",
"RendererRegistry",
"HTMLRenderer",
"DefaultRendererReturnType",
)
5 changes: 1 addition & 4 deletions altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3840,10 +3840,7 @@ def _needs_name(subchart):
return False

# Variable parameters won't receive a views property.
if all(isinstance(p, core.VariableParameter) for p in subchart.params):
return False

return True
return not all(isinstance(p, core.VariableParameter) for p in subchart.params)


# Convert SelectionParameters to TopLevelSelectionParameters with a views property.
Expand Down
2 changes: 1 addition & 1 deletion altair/vegalite/v5/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
__all__ = (
"MaxRowsError",
"curry",
"data_transformers",
"default_data_transformer",
"limit_rows",
"pipe",
"sample",
"to_csv",
"to_json",
"to_values",
"data_transformers",
"vegafusion_data_transformer",
)
4 changes: 2 additions & 2 deletions tests/vegalite/v5/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def test_parameter_naming():
assert res

num = int(res[1])
assert prm1.param.name == f"param_{num+1}"
assert prm2.param.name == f"param_{num+2}"
assert prm1.param.name == f"param_{num + 1}"
assert prm2.param.name == f"param_{num + 2}"


def test_selection_expression():
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_schema_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def recursive_dict_update(schema: dict, root: dict, def_dict: dict) -> None:


def get_field_datum_value_defs(propschema: SchemaInfo, root: dict) -> dict:
def_dict: Dict[str, Optional[str]] = {k: None for k in ("field", "datum", "value")}
def_dict: Dict[str, Optional[str]] = dict.fromkeys(("field", "datum", "value"))
schema = propschema.schema
if propschema.is_reference() and "properties" in schema:
if "field" in schema["properties"]:
Expand Down
2 changes: 1 addition & 1 deletion tools/schemapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .utils import SchemaInfo


__all__ = ("SchemaBase", "Undefined", "SchemaInfo")
__all__ = ("SchemaBase", "SchemaInfo", "Undefined")
2 changes: 1 addition & 1 deletion tools/schemapi/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def split_into_equal_parts(n: int, p: int) -> List[int]:
for ch in column_heights:
param_names_columns.append(param_names[last_end_idx : last_end_idx + ch])
column_max_widths.append(
max([len(param_name) for param_name in param_names_columns[-1]])
max(len(param_name) for param_name in param_names_columns[-1])
)
last_end_idx = ch + last_end_idx

Expand Down

0 comments on commit 8ef6184

Please sign in to comment.