From 014db6f039bc964520c9cb1ceb3c5ef50e8248fb Mon Sep 17 00:00:00 2001 From: CasperWA Date: Wed, 14 Feb 2024 06:32:45 +0000 Subject: [PATCH] Update `pre-commit` hooks --- .pre-commit-config.yaml | 4 ++-- optimade_client/__init__.py | 1 + optimade_client/exceptions.py | 16 ++++++++++------ optimade_client/logger.py | 1 + optimade_client/subwidgets/provider_database.py | 10 ++++------ optimade_client/subwidgets/sort_selector.py | 6 +++--- optimade_client/warnings.py | 16 ++++++++++------ tests/test_utils.py | 1 + 8 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d937198..c074409b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: exclude: README.md - repo: https://github.com/ambv/black - rev: 23.12.0 + rev: 24.2.0 hooks: - id: black name: Blacken @@ -26,7 +26,7 @@ repos: language: system - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 args: [--count, --show-source, --statistics] diff --git a/optimade_client/__init__.py b/optimade_client/__init__.py index 516bf57c..9394fa32 100644 --- a/optimade_client/__init__.py +++ b/optimade_client/__init__.py @@ -3,6 +3,7 @@ VoilĂ /Jupyter client for searching through OPTIMADE databases. """ + from .informational import OptimadeClientFAQ, HeaderDescription, OptimadeLog from .query_provider import OptimadeQueryProviderWidget from .query_filter import OptimadeQueryFilterWidget diff --git a/optimade_client/exceptions.py b/optimade_client/exceptions.py index 140a0d04..531abf90 100644 --- a/optimade_client/exceptions.py +++ b/optimade_client/exceptions.py @@ -11,13 +11,17 @@ class OptimadeClientError(Exception): def __init__(self, *args: Tuple[Any]): LOGGER.error( "%s raised.\nError message: %s\nAbout this exception: %s", - args[0].__class__.__name__ - if args and isinstance(args[0], Exception) - else self.__class__.__name__, + ( + args[0].__class__.__name__ + if args and isinstance(args[0], Exception) + else self.__class__.__name__ + ), str(args[0]) if args else "", - args[0].__doc__ - if args and isinstance(args[0], Exception) - else self.__doc__, + ( + args[0].__doc__ + if args and isinstance(args[0], Exception) + else self.__doc__ + ), ) super().__init__(*args) diff --git a/optimade_client/logger.py b/optimade_client/logger.py index fafdf171..71bdda8f 100644 --- a/optimade_client/logger.py +++ b/optimade_client/logger.py @@ -1,4 +1,5 @@ """Logging to both file and widget""" + import logging from logging.handlers import RotatingFileHandler import os diff --git a/optimade_client/subwidgets/provider_database.py b/optimade_client/subwidgets/provider_database.py index b9c7b068..6fac549f 100644 --- a/optimade_client/subwidgets/provider_database.py +++ b/optimade_client/subwidgets/provider_database.py @@ -303,9 +303,7 @@ def _set_child_dbs( new_data.insert(0, ("", [(first_choice, None)])) self.child_dbs.grouping = new_data - def _update_child_dbs( - self, data: List[dict], skip_dbs: List[str] = None - ) -> Tuple[ + def _update_child_dbs(self, data: List[dict], skip_dbs: List[str] = None) -> Tuple[ List[str], List[List[Union[str, List[Tuple[str, LinksResourceAttributes]]]]], ]: @@ -510,9 +508,9 @@ def _query( # pylint: disable=too-many-locals,too-many-branches,too-many-statem queries = {key: value[0] for key, value in queries.items()} if "filter" in queries: - queries[ - "filter" - ] = f"( {queries['filter']} ) AND ( {filter_value} )" + queries["filter"] = ( + f"( {queries['filter']} ) AND ( {filter_value} )" + ) else: queries["filter"] = filter_value diff --git a/optimade_client/subwidgets/sort_selector.py b/optimade_client/subwidgets/sort_selector.py index 8a342bb9..78e6b960 100644 --- a/optimade_client/subwidgets/sort_selector.py +++ b/optimade_client/subwidgets/sort_selector.py @@ -183,9 +183,9 @@ def _change_order(self, change: dict) -> None: """ descending: bool = change["new"] self.order = Order.DESCENDING if descending else Order.ASCENDING - self.order_select.description = ( - self.order_select.tooltip - ) = self.order.name.capitalize() + self.order_select.description = self.order_select.tooltip = ( + self.order.name.capitalize() + ) self.order_select.icon = self._get_order_icon() self._toggle_sort_availability() diff --git a/optimade_client/warnings.py b/optimade_client/warnings.py index f6bda8f4..fb573919 100644 --- a/optimade_client/warnings.py +++ b/optimade_client/warnings.py @@ -9,12 +9,16 @@ class OptimadeClientWarning(Warning): def __init__(self, *args: Tuple[Any]): LOGGER.warning( "%s warned.\nWarning message: %s\nAbout this warning: %s", - args[0].__class__.__name__ - if args and isinstance(args[0], Exception) - else self.__class__.__name__, + ( + args[0].__class__.__name__ + if args and isinstance(args[0], Exception) + else self.__class__.__name__ + ), str(args[0]) if args else "", - args[0].__doc__ - if args and isinstance(args[0], Exception) - else self.__doc__, + ( + args[0].__doc__ + if args and isinstance(args[0], Exception) + else self.__doc__ + ), ) super().__init__(*args) diff --git a/tests/test_utils.py b/tests/test_utils.py index a05bd2ed..c9a8caad 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ """Test root utils.py functions""" + # pylint: disable=import-error