Skip to content

Commit f11025c

Browse files
author
koliver_kv
committed
refactor: run ruff format on the tools folder
1 parent 6465aab commit f11025c

File tree

5 files changed

+18
-61
lines changed

5 files changed

+18
-61
lines changed

tools/dependencies-table.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,11 @@ def main() -> None:
5252
if package["name"] in dependencies
5353
}
5454

55-
table = {
56-
format_dependency(dependency): descriptions[dependency]
57-
for dependency in sorted(dependencies)
58-
}
55+
table = {format_dependency(dependency): descriptions[dependency] for dependency in sorted(dependencies)}
5956

6057
width = max(len(name) for name in table)
6158
width2 = max(len(description) for description in table.values())
62-
separator = LINE_FORMAT.format(
63-
name="=" * width, width=width, description="=" * width2
64-
)
59+
separator = LINE_FORMAT.format(name="=" * width, width=width, description="=" * width2)
6560

6661
print(separator)
6762

tools/generate-demo-project.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Python script for generating a demo project."""
2+
23
import shutil
34
import sys
45
from pathlib import Path
@@ -8,30 +9,19 @@
89
from cookiecutter.main import cookiecutter
910

1011

11-
FOLDER_TYPE: click.Path = click.Path(
12-
dir_okay=True,
13-
file_okay=False,
14-
resolve_path=True,
15-
path_type=Path
16-
)
12+
FOLDER_TYPE: click.Path = click.Path(dir_okay=True, file_okay=False, resolve_path=True, path_type=Path)
1713

1814

19-
def generate_demo_project(
20-
repo_folder: Path,
21-
demos_cache_folder: Path,
22-
demo_name: str
23-
) -> Path:
15+
def generate_demo_project(repo_folder: Path, demos_cache_folder: Path, demo_name: str) -> Path:
2416
"""Generates a demo project and returns its root path."""
2517
demos_cache_folder.mkdir(exist_ok=True)
2618
_remove_any_existing_demo(demos_cache_folder)
2719
cookiecutter(
2820
template=str(repo_folder),
2921
no_input=True,
30-
extra_context={
31-
"project_name": demo_name
32-
},
22+
extra_context={"project_name": demo_name},
3323
overwrite_if_exists=True,
34-
output_dir=str(demos_cache_folder)
24+
output_dir=str(demos_cache_folder),
3525
)
3626
return demos_cache_folder / demo_name
3727

@@ -46,11 +36,7 @@ def _remove_any_existing_demo(parent_path: Path) -> None:
4636
@click.option("--repo-folder", "-r", required=True, type=FOLDER_TYPE)
4737
@click.option("--demos-cache-folder", "-c", required=True, type=FOLDER_TYPE)
4838
@click.option("--demo-name", "-d", required=True, type=str)
49-
def main(
50-
repo_folder: Path,
51-
demos_cache_folder: Path,
52-
demo_name: str
53-
) -> None:
39+
def main(repo_folder: Path, demos_cache_folder: Path, demo_name: str) -> None:
5440
"""Updates the poetry.lock file."""
5541
try:
5642
generate_demo_project(repo_folder=repo_folder, demos_cache_folder=demos_cache_folder, demo_name=demo_name)

tools/prepare-github-release.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
def git(*args: str, **kwargs: Any) -> str:
1515
try:
16-
process = subprocess.run(
17-
["git", *args], check=True, capture_output=True, text=True
18-
)
16+
process = subprocess.run(["git", *args], check=True, capture_output=True, text=True)
1917
return process.stdout
2018
except subprocess.CalledProcessError as error:
2119
print(error.stdout, end="")

tools/publish-github-release.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ def publish_release(*, owner: str, repository_name: str, token: str, tag: str) -
1313
try:
1414
[pull_request] = list(repository.pull_requests(head=f"{owner}:release-{tag}"))
1515
except ValueError:
16-
raise RuntimeError(
17-
f"there should be exactly one pull request for {owner}:release-{tag}"
18-
)
16+
raise RuntimeError(f"there should be exactly one pull request for {owner}:release-{tag}")
1917

2018
pull_request = repository.pull_request(pull_request.number)
2119

2220
try:
2321
[*_, commit] = pull_request.commits()
2422
except ValueError:
25-
raise RuntimeError(
26-
f"there should be at least one commit associated with #{pull_request.number}"
27-
)
23+
raise RuntimeError(f"there should be at least one commit associated with #{pull_request.number}")
2824

2925
try:
3026
[release] = [release for release in repository.releases() if release.draft]

tools/sync-poetry-with-demo.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module used to sync the poetry.lock file with one generated using a demo project."""
2+
23
import shutil
34
import sys
45
from pathlib import Path
@@ -8,34 +9,21 @@
89
from loguru import logger
910

1011

11-
FOLDER_TYPE: click.Path = click.Path(
12-
dir_okay=True,
13-
file_okay=False,
14-
resolve_path=True,
15-
path_type=Path
16-
)
12+
FOLDER_TYPE: click.Path = click.Path(dir_okay=True, file_okay=False, resolve_path=True, path_type=Path)
1713

1814

19-
def sync_poetry_with_demo(
20-
template_folder: Path,
21-
demos_cache_folder: Path,
22-
demo_name: str
23-
) -> None:
15+
def sync_poetry_with_demo(template_folder: Path, demos_cache_folder: Path, demo_name: str) -> None:
2416
demo_root: Path = demos_cache_folder / demo_name
2517
demo_poetry_lock_path: Path = _find_poetry_lock_path(demo_root)
2618
output_poetry_lock_path: Path = _find_poetry_lock_path(template_folder)
2719

2820
_copy_poetry_lock_from_demo(
29-
demo_poetry_lock_path=demo_poetry_lock_path,
30-
output_poetry_lock_path=output_poetry_lock_path
21+
demo_poetry_lock_path=demo_poetry_lock_path, output_poetry_lock_path=output_poetry_lock_path
3122
)
3223
logger.info(f"Copied demo from {demo_poetry_lock_path=} to {output_poetry_lock_path=}.")
3324

3425

35-
def _copy_poetry_lock_from_demo(
36-
demo_poetry_lock_path: Path,
37-
output_poetry_lock_path: Path
38-
) -> None:
26+
def _copy_poetry_lock_from_demo(demo_poetry_lock_path: Path, output_poetry_lock_path: Path) -> None:
3927
"""Copies over the poetry.lock file from the provided demo project root."""
4028
shutil.copy(
4129
src=demo_poetry_lock_path,
@@ -53,17 +41,11 @@ def _find_poetry_lock_path(search_root: Path) -> Path:
5341
@click.option("--template-folder", "-t", required=True, type=FOLDER_TYPE)
5442
@click.option("--demos-cache-folder", "-c", required=True, type=FOLDER_TYPE)
5543
@click.option("--demo-name", "-d", required=True, type=str)
56-
def main(
57-
template_folder: Path,
58-
demos_cache_folder: Path,
59-
demo_name: str
60-
) -> None:
44+
def main(template_folder: Path, demos_cache_folder: Path, demo_name: str) -> None:
6145
"""Updates the poetry.lock file."""
6246
try:
6347
sync_poetry_with_demo(
64-
template_folder=template_folder,
65-
demos_cache_folder=demos_cache_folder,
66-
demo_name=demo_name
48+
template_folder=template_folder, demos_cache_folder=demos_cache_folder, demo_name=demo_name
6749
)
6850
except Exception as error:
6951
click.secho(f"error: {error}", fg="red")

0 commit comments

Comments
 (0)