Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent 25f3245 commit 9c7a078
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 49 deletions.
4 changes: 2 additions & 2 deletions performance/performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def start(
print(f" Project = {source_tmp_path}")
print(f" Build = {project_path}")
if debug:
print(f' Call: {" ".join(params)} ')
print(f" Call: {' '.join(params)} ")

if debug:
subprocess.run(params)
Expand Down Expand Up @@ -298,7 +298,7 @@ def series(
proc = subprocess.Popen(["snakeviz", f"profile/{p}.prof"])
procs.append(proc)

print(f"\nKilling snakeviz server in {len(procs)*5} secs.")
print(f"\nKilling snakeviz server in {len(procs) * 5} secs.")
time.sleep(len(procs) * 5)
for proc in procs:
proc.kill()
Expand Down
8 changes: 4 additions & 4 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def _make_hashed_id(
hashed = hashlib.sha1(hashable_content.encode("UTF-8")).hexdigest().upper()
if config.id_from_title:
hashed = full_title.upper().replace(" ", "_") + "_" + hashed
return f"{type_prefix}{hashed[:config.id_length]}"
return f"{type_prefix}{hashed[: config.id_length]}"


def _split_list_with_dyn_funcs(
Expand All @@ -740,9 +740,9 @@ def _split_list_with_dyn_funcs(
return []

if not isinstance(text, str):
assert isinstance(text, list) and all(
isinstance(x, str) for x in text
), "text must be a string or a list of strings"
assert isinstance(text, list) and all(isinstance(x, str) for x in text), (
"text must be a string or a list of strings"
)
return text

result: list[str] = []
Expand Down
10 changes: 5 additions & 5 deletions sphinx_needs/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def measure_time_func(
def _print_timing_results(app: Sphinx) -> None:
for value in TIME_MEASUREMENTS.values():
print(value["name"])
print(f' amount: {value["amount"]}')
print(f' overall: {value["overall"]:2f}')
print(f' avg: {value["avg"]:2f}')
print(f' max: {value["max"]:2f}')
print(f' min: {value["min"]:2f} \n')
print(f" amount: {value['amount']}")
print(f" overall: {value['overall']:2f}")
print(f" avg: {value['avg']:2f}")
print(f" max: {value['max']:2f}")
print(f" min: {value['min']:2f} \n")


def _store_timing_results_json(app: Sphinx, build_data: dict[str, Any]) -> None:
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/diagrams_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def calculate_link(
builder = app.builder
try:
if need_info["is_external"]:
assert (
need_info["external_url"] is not None
), "external_url must be set for external needs"
assert need_info["external_url"] is not None, (
"external_url must be set for external needs"
)
link = need_info["external_url"]
# check if need_info["external_url"] is relative path
parsed_url = urlparse(need_info["external_url"])
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/needflow/_plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def process_needflow_plantuml(
)

if found_needs:
plantuml_block_text = ".. plantuml::\n" "\n" " @startuml" " @enduml"
plantuml_block_text = ".. plantuml::\n\n @startuml @enduml"
puml_node = plantuml(plantuml_block_text)
# TODO if an alt is not set then sphinxcontrib.plantuml uses the plantuml source code as alt text.
# I think this is not great, but currently setting a more sensible default breaks some tests
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/directives/needgantt.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run(self) -> Sequence[nodes.Node]:
timeline_options = ["daily", "weekly", "monthly"]
if timeline and timeline not in timeline_options:
raise NeedGanttException(
"Given scale value {} is invalid. Please use: " "{}".format(
"Given scale value {} is invalid. Please use: {}".format(
timeline, ",".join(timeline_options)
)
)
Expand Down Expand Up @@ -178,7 +178,7 @@ def process_needgantt(
no_plantuml(node)
continue

plantuml_block_text = ".. plantuml::\n" "\n" " @startgantt" " @endgantt"
plantuml_block_text = ".. plantuml::\n\n @startgantt @endgantt"
puml_node = plantuml(plantuml_block_text)

# Add source origin
Expand Down Expand Up @@ -321,7 +321,7 @@ def process_needgantt(
start_with_links = need[link_type] # type: ignore[literal-required]
for start_with_link in start_with_links:
start_need = all_needs_dict[start_with_link]
gantt_constraint = "[{}] {} at [{}]'s " "{}\n".format(
gantt_constraint = "[{}] {} at [{}]'s {}\n".format(

Check warning on line 324 in sphinx_needs/directives/needgantt.py

View check run for this annotation

Codecov / codecov/patch

sphinx_needs/directives/needgantt.py#L324

Added line #L324 was not covered by tests
need["id"], keyword, start_need["id"], start_end_sync
)
puml_node["uml"] += gantt_constraint
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 @@ -128,7 +128,7 @@ def run(self) -> Sequence[nodes.Node]:
f"Schema validation errors detected in file {correct_need_import_path}:"
)
for error in errors.schema:
logger.info(f' {error.message} -> {".".join(error.path)}')
logger.info(f" {error.message} -> {'.'.join(error.path)}")

if version is None:
try:
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/directives/needlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def process_needlist(
if need_info["hide"]:
para += title
elif need_info["is_external"]:
assert (
need_info["external_url"] is not None
), "External need without URL"
assert need_info["external_url"] is not None, (
"External need without URL"
)
ref = nodes.reference("", "")

ref["refuri"] = check_and_calc_base_url_rel_path(
Expand Down
4 changes: 3 additions & 1 deletion sphinx_needs/directives/needpie.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def process_needpie(
# execute filter_func code
if ff_result:
args = ff_result.args.split(",") if ff_result.args else []
args_context = {f"arg{index+1}": arg for index, arg in enumerate(args)}
args_context = {
f"arg{index + 1}": arg for index, arg in enumerate(args)
}

sizes = []
ff_result.func(needs=need_list, results=sizes, **args_context)
Expand Down
4 changes: 2 additions & 2 deletions sphinx_needs/directives/needsequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def process_needsequence(
no_plantuml(node)
continue

plantuml_block_text = ".. plantuml::\n" "\n" " @startuml" " @enduml"
plantuml_block_text = ".. plantuml::\n\n @startuml @enduml"
puml_node = plantuml(plantuml_block_text)

# Add source origin
Expand Down Expand Up @@ -161,7 +161,7 @@ def process_needsequence(
need = all_needs_dict[need_id.strip()]
except KeyError:
raise NeedSequenceException(
"Given {} in needsequence unknown." " File {}" ":{}".format(
"Given {} in needsequence unknown. File {}:{}".format(
need_id,
current_needsequence["docname"],
current_needsequence["lineno"],
Expand Down
4 changes: 2 additions & 2 deletions sphinx_needs/external_needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ def load_external_needs(
# render jinja content
mem_template = get_target_template(target_url)
cal_target_url = mem_template.render(**{"need": need})
need_params["external_url"] = f'{source["base_url"]}/{cal_target_url}'
need_params["external_url"] = f"{source['base_url']}/{cal_target_url}"
else:
need_params["external_url"] = (
f'{source["base_url"]}/{need.get("docname", "__error__")}.html#{need["id"]}'
f"{source['base_url']}/{need.get('docname', '__error__')}.html#{need['id']}"
)

# check if external needs already exist
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/filter_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def process_filters(
args = []
if ff_result.args:
args = ff_result.args.split(",")
args_context = {f"arg{index+1}": arg for index, arg in enumerate(args)}
args_context = {f"arg{index + 1}": arg for index, arg in enumerate(args)}

# Decorate function to allow time measurments
filter_func = measure_time_func(
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/needsfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def load_json(self, file: str) -> None:
if errors.schema:
self.log.info(f"Schema validation errors detected in file {file}:")
for error in errors.schema:
self.log.info(f' {error.message} -> {".".join(error.path)}')
self.log.info(f" {error.message} -> {'.'.join(error.path)}")

with open(file) as needs_file:
try:
Expand Down
10 changes: 5 additions & 5 deletions sphinx_needs/roles/need_incoming.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def process_need_incoming(
try:
target_need = all_needs[back_link]
if needs_config.show_link_title:
link_text = f'{target_need["title"]}'
link_text = f"{target_need['title']}"

Check warning on line 47 in sphinx_needs/roles/need_incoming.py

View check run for this annotation

Codecov / codecov/patch

sphinx_needs/roles/need_incoming.py#L47

Added line #L47 was not covered by tests

if needs_config.show_link_id:
link_text += f' ({target_need["id"]})'
link_text += f" ({target_need['id']})"

Check warning on line 50 in sphinx_needs/roles/need_incoming.py

View check run for this annotation

Codecov / codecov/patch

sphinx_needs/roles/need_incoming.py#L50

Added line #L50 was not covered by tests
else:
link_text = target_need["id"]

Expand All @@ -70,9 +70,9 @@ def process_need_incoming(
node_need_backref["reftarget"],
)
else:
assert (
target_need["external_url"] is not None
), "External URL must not be set"
assert target_need["external_url"] is not None, (
"External URL must not be set"
)
new_node_ref = nodes.reference(
target_need["id"], target_need["id"]
)
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/roles/need_outgoing.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def process_need_outgoing(
node_need_ref["reftarget"],
)
else:
assert (
target_need["external_url"] is not None
), "External URL must be set"
assert target_need["external_url"] is not None, (
"External URL must be set"
)
new_node_ref = nodes.reference(
target_need["id"], target_need["id"]
)
Expand Down
6 changes: 3 additions & 3 deletions sphinx_needs/roles/need_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def process_need_ref(
node_need_ref["reftarget"],
)
else:
assert (
target_need["external_url"] is not None
), "external_url must be set for external needs"
assert target_need["external_url"] is not None, (
"external_url must be set for external needs"
)
new_node_ref = nodes.reference(target_need["id"], target_need["id"])
new_node_ref["refuri"] = check_and_calc_base_url_rel_path(
target_need["external_url"], fromdocname
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def request_from_directive(
if "errors" in response:
create_warning(
directive,
"GitHub service query error: {}\n" "Used query: {}".format(
"GitHub service query error: {}\nUsed query: {}".format(
response["errors"][0]["message"], query
),
)
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/services/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get(self, name: str) -> BaseService:
return self.services[name]
else:
raise NeedsServiceException(
"Service {} could not be found. " "Available services are {}".format(
"Service {} could not be found. Available services are {}".format(
name, ", ".join(self.services)
)
)
Expand Down
12 changes: 6 additions & 6 deletions sphinx_needs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def row_col_maker(

if make_ref:
if need_info["is_external"]:
assert (
need_info["external_url"] is not None
), "external_url must be set for external needs"
assert need_info["external_url"] is not None, (
"external_url must be set for external needs"
)
ref_col["refuri"] = check_and_calc_base_url_rel_path(
need_info["external_url"], fromdocname
)
Expand All @@ -169,9 +169,9 @@ def row_col_maker(
elif ref_lookup:
temp_need = all_needs[link_id]
if temp_need["is_external"]:
assert (
temp_need["external_url"] is not None
), "external_url must be set for external needs"
assert temp_need["external_url"] is not None, (
"external_url must be set for external needs"
)
ref_col["refuri"] = check_and_calc_base_url_rel_path(
temp_need["external_url"], fromdocname
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_service_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_build(test_app, snapshot):
prefix = " [docutils]" if version_info >= (8, 0) else ""
expected_warnings = [
f'{Path(str(app.srcdir)) / "index.rst"}:4: WARNING: "query" or "specific" missing as option for github service. [needs.github]',
f'{Path(str(app.srcdir)) / "index.rst"}:23: WARNING: Bullet list ends without a blank line; unexpected unindent.{prefix}',
f"{Path(str(app.srcdir)) / 'index.rst'}:23: WARNING: Bullet list ends without a blank line; unexpected unindent.{prefix}",
f"{Path(str(app.srcdir)) / 'index.rst'}:22: WARNING: GitHub: API rate limit exceeded (twice). Stop here. [needs.github]",
]

Expand Down

0 comments on commit 9c7a078

Please sign in to comment.