From e142d24bc73be95ea1e4270fd2d7404372e1badf Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 21 Feb 2024 10:04:19 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Update=20pre-commit=20(#1121)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- sphinx_needs/api/need.py | 2 +- sphinx_needs/config.py | 2 +- sphinx_needs/directives/needflow.py | 8 ++++---- sphinx_needs/utils.py | 8 ++------ 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a755133cc..97a1c2765 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.2.2 hooks: - id: ruff args: [--fix] diff --git a/pyproject.toml b/pyproject.toml index e089e1717..5d326fca0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,7 @@ markers = [ "jstest: marks tests as JavaScript test (deselect with '-m \"not jstest\"')", ] -[tool.ruff] +[tool.ruff.lint] extend-select = [ "B", # flake8-bugbear "C4", # flake8-comprehensions diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index 5a4eb9d7c..f376257eb 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -805,7 +805,7 @@ def _merge_global_options( config = NeedsSphinxConfig(app.config) for key, value in global_options.items(): # If key already exists in needs_info, this global_option got overwritten manually in current need - if key in needs_info and needs_info[key]: + if needs_info.get(key): continue if isinstance(value, tuple): diff --git a/sphinx_needs/config.py b/sphinx_needs/config.py index f7bd685ff..cbfb9efa8 100644 --- a/sphinx_needs/config.py +++ b/sphinx_needs/config.py @@ -47,7 +47,7 @@ def extra_options(self) -> dict[str, Callable[[str], Any]]: @property def warnings( - self + self, ) -> dict[str, str | Callable[[NeedsInfoType, SphinxLoggerAdapter], bool]]: """Warning handlers that are added by the user, then called at the end of the build. diff --git a/sphinx_needs/directives/needflow.py b/sphinx_needs/directives/needflow.py index 5f4df8d92..95856bcc2 100644 --- a/sphinx_needs/directives/needflow.py +++ b/sphinx_needs/directives/needflow.py @@ -398,7 +398,7 @@ def process_needflow( else: comment = "" - if "style_part" in link_type and link_type["style_part"]: + if link_type.get("style_part"): link_style = "[{style}]".format( style=link_type["style_part"] ) @@ -414,7 +414,7 @@ def process_needflow( else: comment = "" - if "style" in link_type and link_type["style"]: + if link_type.get("style"): link_style = "[{style}]".format( style=link_type["style"] ) @@ -429,12 +429,12 @@ def process_needflow( ]: continue - if "style_start" in link_type and link_type["style_start"]: + if link_type.get("style_start"): style_start = link_type["style_start"] else: style_start = "-" - if "style_end" in link_type and link_type["style_end"]: + if link_type.get("style_end"): style_end = link_type["style_end"] else: style_end = "->" diff --git a/sphinx_needs/utils.py b/sphinx_needs/utils.py index 502c9d734..d297eed86 100644 --- a/sphinx_needs/utils.py +++ b/sphinx_needs/utils.py @@ -576,11 +576,7 @@ def variant_handling( r"(:[\w':.\-\" ]+)$", variant_definition ) filter_string = re.sub(r"^\[|[:\]]$", "", filter_string) - filter_string = ( - needs_variants[filter_string] - if filter_string in needs_variants - else filter_string - ) + filter_string = needs_variants.get(filter_string, filter_string) try: # https://docs.python.org/3/library/functions.html?highlight=compile#compile filter_compiled = compile(filter_string, "", "eval") @@ -671,7 +667,7 @@ def clean_log(data: str) -> str: def node_match( - node_types: type[nodes.Element] | list[type[nodes.Element]] + node_types: type[nodes.Element] | list[type[nodes.Element]], ) -> Callable[[nodes.Node], bool]: """ Returns a condition function for doctuils.nodes.findall()