diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e29280fc4..896dcc98b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index defdbe2d0..4cc2b45a9 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -248,7 +248,7 @@ def republish_metadata_error(self, entity_name, version): if 'Item "Republish repository metadata"' and 'is disabled' in error.args[0]: return True return 'No error was found, metadata unexpectedly was able to be published.' - + def promote(self, entity_name, version_name, lce_name): """Promotes the selected version of content view to given environment. :return: dict with new content view version table row; contains keys diff --git a/airgun/views/contentviewfilter.py b/airgun/views/contentviewfilter.py index 07435786a..eac75055c 100644 --- a/airgun/views/contentviewfilter.py +++ b/airgun/views/contentviewfilter.py @@ -99,7 +99,7 @@ class CVFEditableEntry(EditableEntry): def __init__(self, parent, locator=None, name=None, logger=None): """Supports initialization via ``locator=`` or ``name=``""" - if locator and name or not locator and not name: + if (locator and name) or (not locator and not name): raise TypeError('Please specify either locator or name') locator = ( locator diff --git a/airgun/views/redhat_repository.py b/airgun/views/redhat_repository.py index 80d5f8c9d..827a66336 100644 --- a/airgun/views/redhat_repository.py +++ b/airgun/views/redhat_repository.py @@ -194,7 +194,9 @@ def items(self, name=None, label=None): items = [] for index, _ in enumerate(self.browser.elements(self.ITEMS, parent=self)): item = self.ITEM_WIDGET(self, f'{self.ITEMS}[{index + 1}]') - if name is not None and item.name != name or label is not None and item.label != label: + if (name is not None and item.name != name) or ( + label is not None and item.label != label + ): continue items.append(item) return items diff --git a/airgun/widgets.py b/airgun/widgets.py index 39616aa73..92395cf24 100644 --- a/airgun/widgets.py +++ b/airgun/widgets.py @@ -460,7 +460,7 @@ class MultiSelect(GenericLocatorWidget): def __init__(self, parent, locator=None, id=None, logger=None): """Supports initialization via ``locator=`` or ``id=``""" - if locator and id or not locator and not id: + if (locator and id) or (not locator and not id): raise TypeError('Please specify either locator or id') locator = locator or f".//div[@id='{id}']" super().__init__(parent, locator, logger) @@ -558,7 +558,7 @@ class PF4MultiSelect(GenericLocatorWidget): def __init__(self, parent, locator=None, id=None, logger=None): """Supports initialization via ``locator=`` or ``id=``""" - if locator and id or not locator and not id: + if (locator and id) or (not locator and not id): raise TypeError('Please specify either locator or id') locator = locator or f".//div[@id='{id}']" super().__init__(parent, locator, logger) @@ -1165,7 +1165,7 @@ class FilteredDropdown(GenericLocatorWidget): def __init__(self, parent, id=None, locator=None, logger=None): """Supports initialization via ``id=`` or ``locator=``""" - if locator and id or not locator and not id: + if (locator and id) or (not locator and not id): raise ValueError('Please specify either locator or id') locator = locator or f".//div[contains(@id, '{id}')]" super().__init__(parent, locator, logger) @@ -1239,11 +1239,8 @@ class CustomParameter(Table): def __init__(self, parent, **kwargs): """Supports initialization via ``locator=`` or ``id=``""" - if ( - kwargs.get('locator') - and kwargs.get('id') - or not kwargs.get('locator') - and not kwargs.get('id') + if (kwargs.get('locator') and kwargs.get('id')) or ( + not kwargs.get('locator') and not kwargs.get('id') ): raise ValueError('Please specify either locator or id') locator = kwargs.get('locator') or f".//table[@id='{kwargs.pop('id')}']" @@ -1618,7 +1615,7 @@ class EditableEntry(GenericLocatorWidget): def __init__(self, parent, locator=None, name=None, logger=None): """Supports initialization via ``locator=`` or ``name=``""" - if locator and name or not locator and not name: + if (locator and name) or (not locator and not name): raise TypeError('Please specify either locator or name') locator = locator or f".//dt[normalize-space(.)='{name}']/following-sibling::dd[1]" super().__init__(parent, locator, logger) @@ -1778,7 +1775,7 @@ class ReadOnlyEntry(GenericLocatorWidget): def __init__(self, parent, locator=None, name=None, logger=None): """Supports initialization via ``locator=`` or ``name=``""" - if locator and name or not locator and not name: + if (locator and name) or (not locator and not name): raise TypeError('Please specify either locator or name') locator = locator or self.BASE_LOCATOR.format(name) super().__init__(parent, locator, logger) diff --git a/pyproject.toml b/pyproject.toml index 489e948ba..0ec9baf05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ select = [ "T100", # Trace found: {name} used "T20", # flake8-print "TRY004", # Prefer TypeError exception for invalid type - "TRY302", # Remove exception handler; error is immediately re-raised + "TRY203", # Remove exception handler; error is immediately re-raised "PLR0911", # Too many return statements ({returns} > {max_returns}) "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable "PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target