Skip to content

Commit 1473c9b

Browse files
authored
Force using keyword-only arguments where types are the same (#2277)
* Force using keyword-only arguments where types are the same * Fix
1 parent fcff9a9 commit 1473c9b

File tree

8 files changed

+29
-19
lines changed

8 files changed

+29
-19
lines changed

images/pyspark-notebook/setup_spark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def version_array(ver: str) -> tuple[int, int, int, str]:
5555

5656

5757
def download_spark(
58+
*,
5859
spark_version: str,
5960
hadoop_version: str,
6061
scala_version: str,

tagging/apps/apply_tags.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
def apply_tags(config: Config) -> None:
1818
LOGGER.info(f"Tagging image: {config.image}")
1919

20-
file_prefix = get_file_prefix_for_platform(config.platform, config.variant)
20+
file_prefix = get_file_prefix_for_platform(
21+
platform=config.platform, variant=config.variant
22+
)
2123
filename = f"{file_prefix}-{config.image}.txt"
2224
tags = (config.tags_dir / filename).read_text().splitlines()
2325

tagging/apps/merge_tags.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def read_local_tags_from_files(config: Config) -> tuple[list[str], set[str]]:
2626
for platform in ALL_PLATFORMS:
2727
LOGGER.info(f"Reading tags for platform: {platform}")
2828

29-
file_prefix = get_file_prefix_for_platform(platform, config.variant)
29+
file_prefix = get_file_prefix_for_platform(
30+
platform=platform, variant=config.variant
31+
)
3032
filename = f"{file_prefix}-{config.image}.txt"
3133
path = config.tags_dir / filename
3234
if not path.exists():

tagging/apps/write_manifest.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
MARKDOWN_LINE_BREAK = "<br />"
2323

2424

25-
def get_build_history_line(config: Config, filename: str, container: Container) -> str:
25+
def get_build_history_line(config: Config, container: Container, filename: str) -> str:
2626
LOGGER.info(f"Calculating build history line for image: {config.image}")
2727

2828
taggers = get_taggers(config.image)
@@ -48,19 +48,19 @@ def get_build_history_line(config: Config, filename: str, container: Container)
4848

4949

5050
def write_build_history_line(
51-
config: Config, filename: str, container: Container
51+
config: Config, container: Container, filename: str
5252
) -> None:
5353
LOGGER.info(f"Writing tags for image: {config.image}")
5454

5555
path = config.hist_lines_dir / f"{filename}.txt"
5656
path.parent.mkdir(parents=True, exist_ok=True)
57-
build_history_line = get_build_history_line(config, filename, container)
57+
build_history_line = get_build_history_line(config, container, filename)
5858
path.write_text(build_history_line)
5959

6060
LOGGER.info(f"Build history line written to: {path}")
6161

6262

63-
def get_manifest(config: Config, commit_hash_tag: str, container: Container) -> str:
63+
def get_manifest(config: Config, container: Container, commit_hash_tag: str) -> str:
6464
LOGGER.info(f"Calculating manifest file for image: {config.image}")
6565

6666
manifests = get_manifests(config.image)
@@ -87,13 +87,13 @@ def get_manifest(config: Config, commit_hash_tag: str, container: Container) ->
8787

8888

8989
def write_manifest(
90-
config: Config, filename: str, commit_hash_tag: str, container: Container
90+
config: Config, container: Container, *, filename: str, commit_hash_tag: str
9191
) -> None:
9292
LOGGER.info(f"Writing manifest file for image: {config.image}")
9393

9494
path = config.manifests_dir / f"{filename}.md"
9595
path.parent.mkdir(parents=True, exist_ok=True)
96-
manifest = get_manifest(config, commit_hash_tag, container)
96+
manifest = get_manifest(config, container, commit_hash_tag)
9797
path.write_text(manifest)
9898

9999
LOGGER.info(f"Manifest file wrtitten to: {path}")
@@ -107,8 +107,10 @@ def write_all(config: Config) -> None:
107107
filename = f"{file_prefix}-{config.image}-{commit_hash_tag}"
108108

109109
with DockerRunner(config.full_image()) as container:
110-
write_build_history_line(config, filename, container)
111-
write_manifest(config, filename, commit_hash_tag, container)
110+
write_build_history_line(config, container, filename)
111+
write_manifest(
112+
config, container, filename=filename, commit_hash_tag=commit_hash_tag
113+
)
112114

113115
LOGGER.info(f"All files written for image: {config.image}")
114116

tagging/utils/get_prefix.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
DEFAULT_VARIANT = "default"
66

77

8-
def get_file_prefix_for_platform(platform: str, variant: str) -> str:
8+
def get_file_prefix_for_platform(*, platform: str, variant: str) -> str:
99
return f"{platform}-{variant}"
1010

1111

12-
def get_tag_prefix_for_platform(platform: str, variant: str) -> str:
12+
def _get_tag_prefix_for_platform(*, platform: str, variant: str) -> str:
1313
if variant == DEFAULT_VARIANT:
1414
return platform
1515
return f"{platform}-{variant}"
1616

1717

1818
def get_file_prefix(variant: str) -> str:
1919
platform = get_platform()
20-
return get_file_prefix_for_platform(platform, variant)
20+
return get_file_prefix_for_platform(platform=platform, variant=variant)
2121

2222

2323
def get_tag_prefix(variant: str) -> str:
2424
platform = get_platform()
25-
return get_tag_prefix_for_platform(platform, variant)
25+
return _get_tag_prefix_for_platform(platform=platform, variant=variant)

tests/by_image/base-notebook/test_healthcheck.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
def get_healthy_status(
1414
container: TrackedContainer,
15+
*,
1516
env: list[str] | None,
1617
cmd: list[str] | None,
1718
user: str | None,
@@ -84,7 +85,7 @@ def test_healthy(
8485
cmd: list[str] | None,
8586
user: str | None,
8687
) -> None:
87-
assert get_healthy_status(container, env, cmd, user) == "healthy"
88+
assert get_healthy_status(container, env=env, cmd=cmd, user=user) == "healthy"
8889

8990

9091
@pytest.mark.parametrize(
@@ -117,7 +118,7 @@ def test_healthy_with_proxy(
117118
cmd: list[str] | None,
118119
user: str | None,
119120
) -> None:
120-
assert get_healthy_status(container, env, cmd, user) == "healthy"
121+
assert get_healthy_status(container, env=env, cmd=cmd, user=user) == "healthy"
121122

122123

123124
@pytest.mark.parametrize(
@@ -140,5 +141,5 @@ def test_not_healthy(
140141
cmd: list[str] | None,
141142
) -> None:
142143
assert (
143-
get_healthy_status(container, env, cmd, user=None) != "healthy"
144+
get_healthy_status(container, env=env, cmd=cmd, user=None) != "healthy"
144145
), "Container should not be healthy for this testcase"

tests/by_image/docker-stacks-foundation/test_run_hooks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_run_hooks_empty_dir(container: TrackedContainer) -> None:
7070

7171
def run_source_in_dir(
7272
container: TrackedContainer,
73+
*,
7374
subdir: str,
7475
command_suffix: str = "",
7576
no_failure: bool = True,

tests/utils/tracked_container.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33
import logging
4-
from typing import Any
4+
from typing import Any, LiteralString
55

66
import docker
77
from docker.models.containers import Container
@@ -85,6 +85,7 @@ def exec_cmd(self, cmd: str, **kwargs: Any) -> str:
8585
def run_and_wait(
8686
self,
8787
timeout: int,
88+
*,
8889
no_warnings: bool = True,
8990
no_errors: bool = True,
9091
no_failure: bool = True,
@@ -123,7 +124,7 @@ def get_warnings(logs: str) -> list[str]:
123124
return TrackedContainer._lines_starting_with(logs, "WARNING")
124125

125126
@staticmethod
126-
def _lines_starting_with(logs: str, pattern: str) -> list[str]:
127+
def _lines_starting_with(logs: str, pattern: LiteralString) -> list[str]:
127128
return [line for line in logs.splitlines() if line.startswith(pattern)]
128129

129130
def remove(self) -> None:

0 commit comments

Comments
 (0)