diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e289783be..94b21a2cd 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -58,6 +58,7 @@ jobs: run: make lint - name: Commit code formatting changes + if: always() id: commit run: | if [[ `git status --porcelain --untracked-files=no` ]]; then diff --git a/src/pandas_profiling/model/correlations.py b/src/pandas_profiling/model/correlations.py index 7698e85e6..305a62ffd 100644 --- a/src/pandas_profiling/model/correlations.py +++ b/src/pandas_profiling/model/correlations.py @@ -24,9 +24,7 @@ def compute(config: Settings, df: Sized, summary: dict) -> Optional[Sized]: class Auto(Correlation): @staticmethod @multimethod - def compute( - config: Settings, df: Sized, summary: dict - ) -> Optional[Sized]: + def compute(config: Settings, df: Sized, summary: dict) -> Optional[Sized]: raise NotImplementedError() diff --git a/src/pandas_profiling/model/pandas/correlations_pandas.py b/src/pandas_profiling/model/pandas/correlations_pandas.py index b88581b27..f5b8c4aa4 100644 --- a/src/pandas_profiling/model/pandas/correlations_pandas.py +++ b/src/pandas_profiling/model/pandas/correlations_pandas.py @@ -158,9 +158,7 @@ def pandas_phik_compute( @Auto.compute.register(Settings, pd.DataFrame, dict) def pandas_auto_compute( - config: Settings, - df: pd.DataFrame, - summary: dict + config: Settings, df: pd.DataFrame, summary: dict ) -> Optional[pd.DataFrame]: threshold = config.categorical_maximum_correlation_distinct diff --git a/src/pandas_profiling/model/pandas/describe_categorical_pandas.py b/src/pandas_profiling/model/pandas/describe_categorical_pandas.py index 6dbebbfda..55eb7a1d7 100644 --- a/src/pandas_profiling/model/pandas/describe_categorical_pandas.py +++ b/src/pandas_profiling/model/pandas/describe_categorical_pandas.py @@ -54,13 +54,22 @@ def counter_to_series(counter: Counter) -> pd.Series: def unicode_summary_vc(vc: pd.Series) -> dict: try: - from tangled_up_in_unicode import block, block_abbr, category, category_long, script + from tangled_up_in_unicode import ( # type: ignore + block, + block_abbr, + category, + category_long, + script, + ) except ImportError: - from unicodedata import category - block = lambda char: "(unknown)" - block_abbr = lambda char: "(unknown)" - category_long = lambda char: "(unknown)" - script = lambda char: "(unknown)" + from unicodedata import category as _category # pylint: disable=import-error + + category = _category # type: ignore + char_handler = lambda char: "(unknown)" # noqa: E731 + block = char_handler + block_abbr = char_handler + category_long = char_handler + script = char_handler # Unicode Character Summaries (category and script name) character_counts = get_character_counts_vc(vc) diff --git a/src/pandas_profiling/report/presentation/core/dropdown.py b/src/pandas_profiling/report/presentation/core/dropdown.py index 4d5140518..6a14ffbbf 100644 --- a/src/pandas_profiling/report/presentation/core/dropdown.py +++ b/src/pandas_profiling/report/presentation/core/dropdown.py @@ -1,12 +1,25 @@ from typing import Any, Callable -from pandas_profiling.report.presentation.core.item_renderer import ItemRenderer from pandas_profiling.report.presentation.core.container import Container +from pandas_profiling.report.presentation.core.item_renderer import ItemRenderer from pandas_profiling.report.presentation.core.renderable import Renderable + class Dropdown(ItemRenderer): - def __init__(self, name: str, id: str, items: list, item: Container, anchor_id: str, **kwargs): - super().__init__("dropdown", {"name": name, "id": id, "items": items, "item": item, "anchor_id": anchor_id,}, **kwargs) + def __init__( + self, name: str, id: str, items: list, item: Container, anchor_id: str, **kwargs + ): + super().__init__( + "dropdown", + { + "name": name, + "id": id, + "items": items, + "item": item, + "anchor_id": anchor_id, + }, + **kwargs + ) def __repr__(self) -> str: return "Dropdown" diff --git a/src/pandas_profiling/report/presentation/flavours/flavours.py b/src/pandas_profiling/report/presentation/flavours/flavours.py index df4e39fcd..fdf3689a0 100644 --- a/src/pandas_profiling/report/presentation/flavours/flavours.py +++ b/src/pandas_profiling/report/presentation/flavours/flavours.py @@ -92,8 +92,8 @@ def get_widget_renderable_mapping() -> Dict[Type[Renderable], Type[Renderable]]: Alerts, Collapse, Container, - Duplicate, Dropdown, + Duplicate, FrequencyTable, FrequencyTableSmall, Image, @@ -108,8 +108,8 @@ def get_widget_renderable_mapping() -> Dict[Type[Renderable], Type[Renderable]]: WidgetAlerts, WidgetCollapse, WidgetContainer, - WidgetDuplicate, WidgetDropdown, + WidgetDuplicate, WidgetFrequencyTable, WidgetFrequencyTableSmall, WidgetHTML, diff --git a/src/pandas_profiling/report/presentation/flavours/widget/__init__.py b/src/pandas_profiling/report/presentation/flavours/widget/__init__.py index 65f082213..034feb5c4 100644 --- a/src/pandas_profiling/report/presentation/flavours/widget/__init__.py +++ b/src/pandas_profiling/report/presentation/flavours/widget/__init__.py @@ -3,12 +3,10 @@ from pandas_profiling.report.presentation.flavours.widget.container import ( WidgetContainer, ) +from pandas_profiling.report.presentation.flavours.widget.dropdown import WidgetDropdown from pandas_profiling.report.presentation.flavours.widget.duplicate import ( WidgetDuplicate, ) -from pandas_profiling.report.presentation.flavours.widget.dropdown import ( - WidgetDropdown, -) from pandas_profiling.report.presentation.flavours.widget.frequency_table import ( WidgetFrequencyTable, ) diff --git a/src/pandas_profiling/report/presentation/flavours/widget/dropdown.py b/src/pandas_profiling/report/presentation/flavours/widget/dropdown.py index 2131b970f..6f130704e 100644 --- a/src/pandas_profiling/report/presentation/flavours/widget/dropdown.py +++ b/src/pandas_profiling/report/presentation/flavours/widget/dropdown.py @@ -6,26 +6,26 @@ class WidgetDropdown(Dropdown): def render(self) -> widgets.VBox: dropdown = widgets.Dropdown( - options=self.content["items"], - description=self.content["name"] + options=self.content["items"], description=self.content["name"] ) titles = [] item = self.content["item"].content["items"] - for i in item: + for i in item: titles.append(i.name) item = self.content["item"].render() + def change_view(widg: dict) -> None: - if(dropdown.value == ""): + if dropdown.value == "": item.selected_index = None else: for i in range(len(titles)): - if(titles[i] == dropdown.value): + if titles[i] == dropdown.value: item.selected_index = i break - dropdown.observe(change_view, names=["value"]) + dropdown.observe(change_view, names=["value"]) - if(self.content["item"] != None): + if self.content["item"] is not None: return widgets.VBox([dropdown, item]) else: return widgets.Vbox([dropdown]) diff --git a/src/pandas_profiling/report/structure/report.py b/src/pandas_profiling/report/structure/report.py index 31c164ac8..612a127e9 100644 --- a/src/pandas_profiling/report/structure/report.py +++ b/src/pandas_profiling/report/structure/report.py @@ -60,12 +60,6 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list: """ templs = [] - # dropdown = Dropdown( - # name="variables-dropdown", - # id="variables-dropdown", - # items=list(dataframe_summary["variables"]), - # ) - # templs.append(dropdown) descriptions = config.variables.descriptions show_description = config.show_variable_description @@ -105,8 +99,7 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list: template_variables.update(summary) # Per type template variables - render_map_type = render_map.get( - summary["type"], render_map["Unsupported"]) + render_map_type = render_map.get(summary["type"], render_map["Unsupported"]) template_variables.update(render_map_type(config, template_variables)) # Ignore these @@ -117,8 +110,7 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list: bottom = None if "bottom" in template_variables and template_variables["bottom"] is not None: - btn = ToggleButton( - "Toggle details", anchor_id=template_variables["varid"]) + btn = ToggleButton("Toggle details", anchor_id=template_variables["varid"]) bottom = Collapse(btn, template_variables["bottom"]) var = Variable( @@ -186,8 +178,7 @@ def get_sample_items(sample: dict) -> List[Sample]: List of sample items to show in the interface. """ items = [ - Sample(sample=obj.data, name=obj.name, - anchor_id=obj.id, caption=obj.caption) + Sample(sample=obj.data, name=obj.name, anchor_id=obj.id, caption=obj.caption) for obj in sample ] return items @@ -275,14 +266,12 @@ def get_report_structure(config: Settings, summary: dict) -> Root: section_items.append( Container( scatter_items, - sequence_type="tabs" if len( - scatter_items) <= 10 else "select", + sequence_type="tabs" if len(scatter_items) <= 10 else "select", name="Interactions", anchor_id="interactions", ), ) - corr = get_correlation_items(config, summary) if corr is not None: section_items.append(corr)