Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1319)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Sewell <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and chrisjsewell authored Oct 8, 2024
1 parent 0d5d316 commit 4120c18
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
rev: v0.6.9
hooks:
- id: ruff
args: [--fix]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ extend-select = [
"SIM", # flake8-simplify
"UP", # pyupgrade
]
extend-ignore = ["B904", "ISC001", "ICN001", "N818", "RUF005", "RUF013", "RUF012", "SIM108", "SIM118"]
extend-ignore = ["B904", "ISC001", "ICN001", "N818", "RUF012"]

[tool.mypy]
files = "sphinx_needs"
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def _merge_extra_options(
for key in needs_extra_options:
if key in extra_keys:
needs_info[key] = str(needs_kwargs[key])
elif key not in needs_info.keys():
elif key not in needs_info:
# Finally add all not used extra options with empty value to need_info.
# Needed for filters, which need to access these empty/not used options.
needs_info[key] = ""
Expand Down Expand Up @@ -829,14 +829,14 @@ def _merge_global_options(
# Set value, if filter has matched
needs_info[key] = single_value[0]
elif len(single_value) == 3 and (
key not in needs_info.keys() or len(str(needs_info[key])) > 0
key not in needs_info or len(str(needs_info[key])) > 0
):
# Otherwise set default, but only if no value was set before or value is "" and a default is defined
needs_info[key] = single_value[2]
else:
# If not value was set until now, we have to set an empty value, so that we are sure that each need
# has at least the key.
if key not in needs_info.keys():
if key not in needs_info:
needs_info[key] = ""


Expand Down
5 changes: 1 addition & 4 deletions sphinx_needs/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def wrapper(*args: list[object], **kwargs: dict[object, object]) -> Any:

runtime = end - start

if name is None:
mt_name = func.__name__
else:
mt_name = name
mt_name = func.__name__ if name is None else name

mt_id = f"{category}_{func.__name__}"

Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def create_back_links(needs: NeedsMutable, config: NeedsSphinxConfig) -> None:
if need_id_part and need_id_part in needs[need_id_main]["parts"]:
if (
option_back
not in needs[need_id_main]["parts"][need_id_part].keys()
not in needs[need_id_main]["parts"][need_id_part]
):
needs[need_id_main]["parts"][need_id_part][option_back] = [] # type: ignore[literal-required]
needs[need_id_main]["parts"][need_id_part][option_back].append( # type: ignore[literal-required]
Expand Down
5 changes: 1 addition & 4 deletions sphinx_needs/directives/needflow/_plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ def get_need_node_rep_for_plantuml(
node_colors.append(f"line:{color}")

# need parts style use default "rectangle"
if need_info["is_need"]:
node_style = need_info["type_style"]
else:
node_style = "rectangle"
node_style = need_info["type_style"] if need_info["is_need"] else "rectangle"

# node representation for plantuml
need_node_code = '{style} "{node_text}" as {id} [[{link}]] #{color}'.format(
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/needimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def run(self) -> Sequence[nodes.Node]:
raise CorruptedNeedsFile(
f"Key 'current_version' missing or corrupted in {correct_need_import_path}"
)
if version not in needs_import_list["versions"].keys():
if version not in needs_import_list["versions"]:
raise VersionNotFound(
f"Version {version} not found in needs import file {correct_need_import_path}"
)
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/directives/needservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def run(self) -> Sequence[nodes.Node]:

content.extend(self.content)

if "type" not in datum.keys():
if "type" not in datum:
# Use the first defined type, if nothing got defined by service (should not be the case)
need_type = need_types[0]["directive"]
else:
need_type = datum["type"]
del datum["type"]

if "title" not in datum.keys():
if "title" not in datum:
need_title = ""
else:
need_title = datum["title"]
Expand All @@ -102,7 +102,7 @@ def run(self) -> Sequence[nodes.Node]:
# We need to check if all given options from services are really available as configured
# extra_option or extra_link
missing_options = {}
for element in datum.keys():
for element in datum:
defined_options = list(self.__class__.option_spec.keys())
defined_options.append(
"content"
Expand Down
5 changes: 1 addition & 4 deletions sphinx_needs/functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ def register_func(need_function: DynamicFunction, name: str | None = None) -> No
if NEEDS_FUNCTIONS is None:
NEEDS_FUNCTIONS = {}

if name is None:
func_name = need_function.__name__
else:
func_name = name
func_name = need_function.__name__ if name is None else name

if func_name in NEEDS_FUNCTIONS:
# We can not throw an exception here, as using sphinx-needs in different sphinx-projects with the
Expand Down
9 changes: 3 additions & 6 deletions sphinx_needs/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def __init__(
}

def get_need_table(self) -> nodes.table:
if self.layout["grid"] not in self.grids.keys():
if self.layout["grid"] not in self.grids:
raise SphinxNeedLayoutException(
"Unknown layout-grid: {}. Supported are {}".format(
self.layout["grid"], ", ".join(self.grids.keys())
Expand Down Expand Up @@ -630,10 +630,7 @@ def meta_all(
]

if exclude is None or not isinstance(exclude, list):
if defaults:
exclude = default_excludes
else:
exclude = []
exclude = default_excludes if defaults else []
elif defaults:
exclude += default_excludes

Expand All @@ -642,7 +639,7 @@ def meta_all(
link_names += [x["option"] + "_back" for x in self.needs_config.extra_links]
exclude += link_names
data_container = nodes.inline()
for data in self.need.keys():
for data in self.need:
if data in exclude:
continue

Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def check_configuration(_app: Sphinx, config: Config) -> None:
if (
option not in extra_options
and option not in link_types
and option not in NEED_DEFAULT_OPTIONS.keys()
and option not in NEED_DEFAULT_OPTIONS
):
raise NeedsConfigException(
f"Variant option `{option}` is not added in either extra options or extra links. "
Expand Down
4 changes: 2 additions & 2 deletions sphinx_needs/needsfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(
def update_or_add_version(self, version: str) -> None:
from sphinx_needs.needs import __version__

if version not in self.needs_list["versions"].keys():
if version not in self.needs_list["versions"]:
self.needs_list["versions"][version] = {
"needs_amount": 0,
"needs": {},
Expand All @@ -147,7 +147,7 @@ def update_or_add_version(self, version: str) -> None:
if not self.needs_config.reproducible_json:
self.needs_list["versions"][version]["created"] = ""

if "needs" not in self.needs_list["versions"][version].keys():
if "needs" not in self.needs_list["versions"][version]:
self.needs_list["versions"][version]["needs"] = {}

if not self.needs_config.reproducible_json:
Expand Down
10 changes: 7 additions & 3 deletions sphinx_needs/services/config/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
"max_content_lines",
"id_prefix",
]
GITHUB_DATA = (
["status", "tags"] + EXTRA_DATA_OPTIONS + EXTRA_LINK_OPTIONS + EXTRA_IMAGE_OPTIONS
)
GITHUB_DATA = [
"status",
"tags",
*EXTRA_DATA_OPTIONS,
*EXTRA_LINK_OPTIONS,
*EXTRA_IMAGE_OPTIONS,
]
GITHUB_DATA_STR = (
'"'
+ '","'.join(EXTRA_DATA_OPTIONS + EXTRA_LINK_OPTIONS + EXTRA_IMAGE_OPTIONS)
Expand Down
11 changes: 4 additions & 7 deletions sphinx_needs/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
if "gh_type" in kwargs:
self.gh_type = kwargs["gh_type"]

if self.gh_type not in self.gh_type_config.keys():
if self.gh_type not in self.gh_type_config:
raise KeyError(
'github type "{}" not supported. Use: {}'.format(
self.gh_type, ", ".join(self.gh_type_config.keys())
Expand Down Expand Up @@ -131,11 +131,8 @@ def _send(
self.log.info(f"Service {self.name} requesting data for query: {query}")

auth: tuple[str, str] | None
if self.username:
# TODO token can be None
auth = (self.username, self.token) # type: ignore
else:
auth = None
# TODO token can be None
auth = (self.username, self.token) if self.username else None # type: ignore

resp = requests.get(url, params=params, auth=auth, headers=headers)

Expand Down Expand Up @@ -387,7 +384,7 @@ def _add_given_options(
"""
for key, value in options.items():
# Check if given option is not already handled and is not part of the service internal options
if key not in element_data.keys() and key not in GITHUB_DATA:
if key not in element_data and key not in GITHUB_DATA:
element_data[key] = value


Expand Down

0 comments on commit 4120c18

Please sign in to comment.