diff --git a/altair/utils/__init__.py b/altair/utils/__init__.py index dba1e1f81..1e2be13a6 100644 --- a/altair/utils/__init__.py +++ b/altair/utils/__init__.py @@ -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", ) diff --git a/altair/utils/core.py b/altair/utils/core.py index 29839f705..95b382aa3 100644 --- a/altair/utils/core.py +++ b/altair/utils/core.py @@ -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) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 01170c6a6..d31b9ff0c 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -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 diff --git a/altair/vegalite/data.py b/altair/vegalite/data.py index fbeda0fee..6db60a693 100644 --- a/altair/vegalite/data.py +++ b/altair/vegalite/data.py @@ -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", ) diff --git a/altair/vegalite/display.py b/altair/vegalite/display.py index 1f3a13b46..d146c53c7 100644 --- a/altair/vegalite/display.py +++ b/altair/vegalite/display.py @@ -8,10 +8,10 @@ __all__ = ( + "DefaultRendererReturnType", "Displayable", + "HTMLRenderer", + "RendererRegistry", "default_renderer_base", "json_renderer_base", - "RendererRegistry", - "HTMLRenderer", - "DefaultRendererReturnType", ) diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index 9164d0bbf..839b93651 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -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. diff --git a/altair/vegalite/v5/data.py b/altair/vegalite/v5/data.py index 1e47db526..8846efb83 100644 --- a/altair/vegalite/v5/data.py +++ b/altair/vegalite/v5/data.py @@ -35,6 +35,7 @@ __all__ = ( "MaxRowsError", "curry", + "data_transformers", "default_data_transformer", "limit_rows", "pipe", @@ -42,6 +43,5 @@ "to_csv", "to_json", "to_values", - "data_transformers", "vegafusion_data_transformer", ) diff --git a/tests/vegalite/v5/test_params.py b/tests/vegalite/v5/test_params.py index 90dffe9f2..d9f61b8c9 100644 --- a/tests/vegalite/v5/test_params.py +++ b/tests/vegalite/v5/test_params.py @@ -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(): diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 8abe847d6..5527f1a9b 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -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"]: diff --git a/tools/schemapi/__init__.py b/tools/schemapi/__init__.py index f287ad3fb..fc62cce6c 100644 --- a/tools/schemapi/__init__.py +++ b/tools/schemapi/__init__.py @@ -6,4 +6,4 @@ from .utils import SchemaInfo -__all__ = ("SchemaBase", "Undefined", "SchemaInfo") +__all__ = ("SchemaBase", "SchemaInfo", "Undefined") diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 7b4460b6a..9ae557fbe 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -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