concoursetools 0.8.0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {concoursetools-0.8.0 → concoursetools-0.8.1}/PKG-INFO +7 -6
- {concoursetools-0.8.0 → concoursetools-0.8.1}/README.md +2 -2
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/__init__.py +1 -1
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/additional.py +4 -4
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/cli/docstring.py +4 -4
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/cli/parser.py +4 -11
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/colour.py +1 -1
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/importing.py +1 -1
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/metadata.py +1 -1
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/mocking.py +8 -10
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/resource.py +4 -4
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/testing.py +8 -11
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/version.py +2 -5
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools.egg-info/PKG-INFO +7 -6
- {concoursetools-0.8.0 → concoursetools-0.8.1}/pyproject.toml +11 -3
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_additional.py +1 -1
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_cli_parsing.py +1 -3
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_examples.py +23 -5
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_resource.py +18 -11
- {concoursetools-0.8.0 → concoursetools-0.8.1}/LICENSE.md +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/__main__.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/cli/__init__.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/cli/commands.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/dockertools.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/parsing.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/py.typed +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools/typing.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools.egg-info/SOURCES.txt +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools.egg-info/dependency_links.txt +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/concoursetools.egg-info/top_level.txt +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/setup.cfg +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/setup.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_cli_commands.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_dockertools.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_importing.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_metadata.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_parsing.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_testing.py +0 -0
- {concoursetools-0.8.0 → concoursetools-0.8.1}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: concoursetools
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: Easily create Concourse resource types in Python.
|
|
5
5
|
Author-email: GCHQ <oss@gchq.gov.uk>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -14,16 +14,17 @@ Classifier: Development Status :: 4 - Beta
|
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
16
|
Classifier: Natural Language :: English
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Topic :: Software Development
|
|
23
23
|
Classifier: Typing :: Typed
|
|
24
|
-
Requires-Python: >=3.
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE.md
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
|
|
28
29
|
<picture>
|
|
29
30
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/gchq/ConcourseTools/main/docs/source/_static/logo-dark.png">
|
|
@@ -31,9 +32,9 @@ License-File: LICENSE.md
|
|
|
31
32
|
<img alt="ConcourseTools logo" src="https://raw.githubusercontent.com/gchq/ConcourseTools/main/docs/source/_static/logo.png">
|
|
32
33
|
</picture>
|
|
33
34
|
|
|
34
|
-

|
|
35
36
|

|
|
36
|
-

|
|
37
38
|

|
|
38
39
|

|
|
39
40
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
<img alt="ConcourseTools logo" src="https://raw.githubusercontent.com/gchq/ConcourseTools/main/docs/source/_static/logo.png">
|
|
5
5
|
</picture>
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|

|
|
9
|
-

|
|
10
10
|

|
|
11
11
|

|
|
12
12
|
|
|
@@ -44,7 +44,7 @@ class DatetimeVersion(TypedVersion):
|
|
|
44
44
|
execution_date: datetime
|
|
45
45
|
|
|
46
46
|
@classmethod
|
|
47
|
-
def now(cls) ->
|
|
47
|
+
def now(cls) -> DatetimeVersion:
|
|
48
48
|
"""Return the version corresponding to now."""
|
|
49
49
|
return cls(datetime.now())
|
|
50
50
|
|
|
@@ -236,7 +236,7 @@ class MultiVersion(Version, Generic[SortableVersionT]):
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
@classmethod
|
|
239
|
-
def from_flat_dict(cls:
|
|
239
|
+
def from_flat_dict(cls: type[MultiVersion[SortableVersionT]], version_dict: VersionConfig) -> MultiVersion[SortableVersionT]:
|
|
240
240
|
"""
|
|
241
241
|
Load an instance from a dictionary representing the version.
|
|
242
242
|
|
|
@@ -382,7 +382,7 @@ class SelfOrganisingConcourseResource(ConcourseResource[SortableVersionT]):
|
|
|
382
382
|
|
|
383
383
|
class _PseudoConcourseResource(ConcourseResource[VersionT]):
|
|
384
384
|
|
|
385
|
-
def __new__(cls) ->
|
|
385
|
+
def __new__(cls) -> _PseudoConcourseResource[VersionT]:
|
|
386
386
|
raise TypeError(f"Cannot instantiate a {cls.__name__} type")
|
|
387
387
|
|
|
388
388
|
|
|
@@ -425,7 +425,7 @@ def combine_resource_types(resources: dict[str, type[ConcourseResource[VersionT]
|
|
|
425
425
|
A special Resource class which delegates to multiple other resource classes.
|
|
426
426
|
"""
|
|
427
427
|
@classmethod
|
|
428
|
-
def _from_resource_config(cls, resource_config: ResourceConfig) ->
|
|
428
|
+
def _from_resource_config(cls, resource_config: ResourceConfig) -> ConcourseResource[VersionT]:
|
|
429
429
|
try:
|
|
430
430
|
resource_key = resource_config.pop(param_key)
|
|
431
431
|
except KeyError as error:
|
|
@@ -32,7 +32,7 @@ class Docstring:
|
|
|
32
32
|
parameters: dict[str, str]
|
|
33
33
|
|
|
34
34
|
@classmethod
|
|
35
|
-
def from_object(cls, obj: object) ->
|
|
35
|
+
def from_object(cls, obj: object) -> Docstring:
|
|
36
36
|
"""
|
|
37
37
|
Parse an object with a docstring.
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ class Docstring:
|
|
|
42
42
|
return cls.from_string(raw_docstring)
|
|
43
43
|
|
|
44
44
|
@classmethod
|
|
45
|
-
def from_string(cls, raw_docstring: str) ->
|
|
45
|
+
def from_string(cls, raw_docstring: str) -> Docstring:
|
|
46
46
|
"""
|
|
47
47
|
Parse a docstring.
|
|
48
48
|
|
|
@@ -63,7 +63,7 @@ class Docstring:
|
|
|
63
63
|
return cls(first_line, description.strip(), parameters)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def _pair_up(data: list[str]) -> Generator[tuple[str, str]
|
|
66
|
+
def _pair_up(data: list[str]) -> Generator[tuple[str, str]]:
|
|
67
67
|
"""
|
|
68
68
|
Pair up a list of items.
|
|
69
69
|
|
|
@@ -76,6 +76,6 @@ def _pair_up(data: list[str]) -> Generator[tuple[str, str], None, None]:
|
|
|
76
76
|
"""
|
|
77
77
|
for i in range(0, len(data), 2):
|
|
78
78
|
try:
|
|
79
|
-
yield data[i], data[i+1]
|
|
79
|
+
yield data[i], data[i + 1]
|
|
80
80
|
except IndexError:
|
|
81
81
|
raise ValueError(f"Needed an even number of values, got {len(data)}")
|
|
@@ -10,20 +10,14 @@ from collections.abc import Callable, Generator
|
|
|
10
10
|
from dataclasses import dataclass
|
|
11
11
|
import inspect
|
|
12
12
|
import shutil
|
|
13
|
-
import sys
|
|
14
13
|
import textwrap
|
|
14
|
+
from types import UnionType
|
|
15
15
|
from typing import Any, Generic, TypeVar
|
|
16
16
|
|
|
17
17
|
from concoursetools import __version__
|
|
18
18
|
from concoursetools.cli.docstring import Docstring
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if _CURRENT_PYTHON_VERSION >= (3, 10):
|
|
23
|
-
from types import UnionType
|
|
24
|
-
_ANNOTATIONS_TO_TYPES: dict[type[Any] | UnionType | str, type] = {}
|
|
25
|
-
else:
|
|
26
|
-
_ANNOTATIONS_TO_TYPES: dict[type[Any] | Any | str, type] = {} # type: ignore[no-redef]
|
|
20
|
+
_ANNOTATIONS_TO_TYPES: dict[type[Any] | UnionType | str, type] = {}
|
|
27
21
|
|
|
28
22
|
CLIFunction = Callable[..., None]
|
|
29
23
|
CLIFunctionT = TypeVar("CLIFunctionT", bound=CLIFunction)
|
|
@@ -37,8 +31,7 @@ for type_ in _AVAILABLE_TYPES:
|
|
|
37
31
|
type_.__name__: type_,
|
|
38
32
|
f"{type_.__name__} | None": type_,
|
|
39
33
|
})
|
|
40
|
-
|
|
41
|
-
_ANNOTATIONS_TO_TYPES[type_ | None] = type_
|
|
34
|
+
_ANNOTATIONS_TO_TYPES[type_ | None] = type_
|
|
42
35
|
|
|
43
36
|
|
|
44
37
|
class _CLIParser(ABC):
|
|
@@ -377,7 +370,7 @@ class Parameter(ABC, Generic[T]):
|
|
|
377
370
|
...
|
|
378
371
|
|
|
379
372
|
@classmethod
|
|
380
|
-
def yield_from_function(cls, func: CLIFunction, allow_short: set[str]) -> Generator[Parameter[Any]
|
|
373
|
+
def yield_from_function(cls, func: CLIFunction, allow_short: set[str]) -> Generator[Parameter[Any]]:
|
|
381
374
|
"""
|
|
382
375
|
Yield parameters from a function.
|
|
383
376
|
|
|
@@ -77,7 +77,7 @@ def colour_print(*values: object, colour: str = MISSING_COLOUR, bold: bool = Fal
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
@contextmanager
|
|
80
|
-
def print_in_colour(colour: str, bold: bool = False, underline: bool = False) -> Generator[None
|
|
80
|
+
def print_in_colour(colour: str, bold: bool = False, underline: bool = False) -> Generator[None]:
|
|
81
81
|
"""
|
|
82
82
|
Print anything in colour within a :ref:`context manager <context-managers>`.
|
|
83
83
|
|
|
@@ -127,7 +127,7 @@ def import_py_file(import_path: str, file_path: Path) -> ModuleType:
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
@contextmanager
|
|
130
|
-
def edit_sys_path(prepend: Sequence[Path] = (), append: Sequence[Path] = ()) -> Generator[None
|
|
130
|
+
def edit_sys_path(prepend: Sequence[Path] = (), append: Sequence[Path] = ()) -> Generator[None]:
|
|
131
131
|
"""
|
|
132
132
|
Temporarily add to :data:`sys.path` within a context manager.
|
|
133
133
|
|
|
@@ -217,7 +217,7 @@ class BuildMetadata: # pylint: disable=invalid-name
|
|
|
217
217
|
return template.safe_substitute(possible_values) if ignore_missing else template.substitute(possible_values)
|
|
218
218
|
|
|
219
219
|
@classmethod
|
|
220
|
-
def from_env(cls) ->
|
|
220
|
+
def from_env(cls) -> BuildMetadata:
|
|
221
221
|
"""Return an instance populated from the environment."""
|
|
222
222
|
return cls(
|
|
223
223
|
BUILD_ID=os.environ["BUILD_ID"],
|
|
@@ -13,13 +13,11 @@ from pathlib import Path
|
|
|
13
13
|
import sys
|
|
14
14
|
from tempfile import TemporaryDirectory
|
|
15
15
|
from types import TracebackType
|
|
16
|
-
from typing import Any
|
|
16
|
+
from typing import Any
|
|
17
17
|
from unittest import mock
|
|
18
18
|
|
|
19
19
|
from concoursetools import BuildMetadata
|
|
20
20
|
|
|
21
|
-
T = TypeVar("T")
|
|
22
|
-
ContextManager = Generator[T, None, None]
|
|
23
21
|
FolderDict = dict[str, Any]
|
|
24
22
|
|
|
25
23
|
|
|
@@ -156,7 +154,7 @@ class TemporaryDirectoryState:
|
|
|
156
154
|
raise RuntimeError("Final state is not set whilst temporary directory is still open.")
|
|
157
155
|
return self._final_state
|
|
158
156
|
|
|
159
|
-
def __enter__(self) ->
|
|
157
|
+
def __enter__(self) -> TemporaryDirectoryState:
|
|
160
158
|
self._temp_dir = TemporaryDirectory(**self.temporary_directory_kwargs)
|
|
161
159
|
self._set_folder_from_dict(self.path, self.starting_state, encoding=self.encoding)
|
|
162
160
|
return self
|
|
@@ -202,7 +200,7 @@ class TemporaryDirectoryState:
|
|
|
202
200
|
first_chunk = rf.read(byte_limit)
|
|
203
201
|
folder_dict[item.name] = first_chunk
|
|
204
202
|
elif item.is_dir():
|
|
205
|
-
folder_dict[item.name] = self._get_folder_as_dict(item, max_depth=max_depth-1, encoding=encoding)
|
|
203
|
+
folder_dict[item.name] = self._get_folder_as_dict(item, max_depth=max_depth - 1, encoding=encoding)
|
|
206
204
|
return folder_dict
|
|
207
205
|
|
|
208
206
|
def _set_folder_from_dict(self, folder_path: Path, folder_dict: FolderDict, encoding: str | None = None) -> None:
|
|
@@ -278,7 +276,7 @@ class StringIOWrapper:
|
|
|
278
276
|
self.inner_io = StringIO()
|
|
279
277
|
|
|
280
278
|
@contextmanager
|
|
281
|
-
def capture_stdout_and_stderr(self) ->
|
|
279
|
+
def capture_stdout_and_stderr(self) -> Generator[StringIOWrapper]:
|
|
282
280
|
"""
|
|
283
281
|
Capture both :data:`~sys.stdout` and :data:`~sys.stderr`.
|
|
284
282
|
|
|
@@ -289,7 +287,7 @@ class StringIOWrapper:
|
|
|
289
287
|
yield self
|
|
290
288
|
|
|
291
289
|
@contextmanager
|
|
292
|
-
def capture_stderr(self) ->
|
|
290
|
+
def capture_stderr(self) -> Generator[StringIOWrapper]:
|
|
293
291
|
"""
|
|
294
292
|
Capture :data:`~sys.stderr`.
|
|
295
293
|
|
|
@@ -300,7 +298,7 @@ class StringIOWrapper:
|
|
|
300
298
|
|
|
301
299
|
|
|
302
300
|
@contextmanager
|
|
303
|
-
def mock_environ(new_environ: dict[str, str]) ->
|
|
301
|
+
def mock_environ(new_environ: dict[str, str]) -> Generator[None]:
|
|
304
302
|
"""
|
|
305
303
|
Mock :data:`os.environ` in a context manager.
|
|
306
304
|
|
|
@@ -317,7 +315,7 @@ def mock_environ(new_environ: dict[str, str]) -> ContextManager[None]:
|
|
|
317
315
|
|
|
318
316
|
|
|
319
317
|
@contextmanager
|
|
320
|
-
def mock_stdin(stdin: str) ->
|
|
318
|
+
def mock_stdin(stdin: str) -> Generator[None]:
|
|
321
319
|
"""
|
|
322
320
|
Mock :data:`~sys.stdin` in a context manager.
|
|
323
321
|
|
|
@@ -338,7 +336,7 @@ def mock_stdin(stdin: str) -> ContextManager[None]:
|
|
|
338
336
|
|
|
339
337
|
|
|
340
338
|
@contextmanager
|
|
341
|
-
def mock_argv(*args: str) ->
|
|
339
|
+
def mock_argv(*args: str) -> Generator[None]:
|
|
342
340
|
"""
|
|
343
341
|
Mock :data:`sys.argv` in a context manager.
|
|
344
342
|
|
|
@@ -275,7 +275,7 @@ class ConcourseResource(ABC, Generic[VersionT]):
|
|
|
275
275
|
_output(output)
|
|
276
276
|
|
|
277
277
|
@classmethod
|
|
278
|
-
def _parse_check_input(cls) -> tuple[
|
|
278
|
+
def _parse_check_input(cls) -> tuple[ConcourseResource[VersionT], VersionT | None]:
|
|
279
279
|
"""Parse input from the command line."""
|
|
280
280
|
check_payload = sys.stdin.read()
|
|
281
281
|
|
|
@@ -291,7 +291,7 @@ class ConcourseResource(ABC, Generic[VersionT]):
|
|
|
291
291
|
return resource, previous_version
|
|
292
292
|
|
|
293
293
|
@classmethod
|
|
294
|
-
def _parse_in_input(cls) -> tuple[
|
|
294
|
+
def _parse_in_input(cls) -> tuple[ConcourseResource[VersionT], VersionT, Path, Params]:
|
|
295
295
|
"""Parse input from the command line."""
|
|
296
296
|
in_payload = sys.stdin.read()
|
|
297
297
|
|
|
@@ -309,7 +309,7 @@ class ConcourseResource(ABC, Generic[VersionT]):
|
|
|
309
309
|
return resource, version, destination_dir, params
|
|
310
310
|
|
|
311
311
|
@classmethod
|
|
312
|
-
def _parse_out_input(cls) -> tuple[
|
|
312
|
+
def _parse_out_input(cls) -> tuple[ConcourseResource[VersionT], Path, Params]:
|
|
313
313
|
"""Parse input from the command line."""
|
|
314
314
|
out_payload = sys.stdin.read()
|
|
315
315
|
|
|
@@ -326,7 +326,7 @@ class ConcourseResource(ABC, Generic[VersionT]):
|
|
|
326
326
|
return resource, sources_dir, params
|
|
327
327
|
|
|
328
328
|
@classmethod
|
|
329
|
-
def _from_resource_config(cls, resource_config: ResourceConfig) ->
|
|
329
|
+
def _from_resource_config(cls, resource_config: ResourceConfig) -> ConcourseResource[VersionT]:
|
|
330
330
|
return cls(**resource_config)
|
|
331
331
|
|
|
332
332
|
|
|
@@ -19,7 +19,7 @@ from pathlib import Path
|
|
|
19
19
|
import secrets
|
|
20
20
|
import subprocess
|
|
21
21
|
from tempfile import TemporaryDirectory
|
|
22
|
-
from typing import Any, Generic
|
|
22
|
+
from typing import Any, Generic
|
|
23
23
|
|
|
24
24
|
from concoursetools import BuildMetadata, ConcourseResource, Version
|
|
25
25
|
from concoursetools.dockertools import MethodName, ScriptName, create_script_file
|
|
@@ -27,8 +27,6 @@ from concoursetools.mocking import StringIOWrapper, TemporaryDirectoryState, cre
|
|
|
27
27
|
from concoursetools.parsing import format_check_input, format_in_input, format_out_input, parse_metadata
|
|
28
28
|
from concoursetools.typing import Metadata, MetadataPair, Params, ResourceConfig, VersionConfig, VersionT
|
|
29
29
|
|
|
30
|
-
T = TypeVar("T")
|
|
31
|
-
ContextManager = Generator[T, None, None]
|
|
32
30
|
FolderDict = dict[str, Any]
|
|
33
31
|
|
|
34
32
|
|
|
@@ -90,7 +88,7 @@ class TestResourceWrapper(ABC, Generic[VersionT]):
|
|
|
90
88
|
"""
|
|
91
89
|
|
|
92
90
|
@contextmanager
|
|
93
|
-
def capture_debugging(self) ->
|
|
91
|
+
def capture_debugging(self) -> Generator[StringIOWrapper]:
|
|
94
92
|
"""
|
|
95
93
|
Redirect the resource debugging output within a context manager into a variable.
|
|
96
94
|
|
|
@@ -105,7 +103,7 @@ class TestResourceWrapper(ABC, Generic[VersionT]):
|
|
|
105
103
|
yield self._debugging_output
|
|
106
104
|
|
|
107
105
|
@contextmanager
|
|
108
|
-
def capture_directory_state(self, starting_state: FolderDict | None = None) ->
|
|
106
|
+
def capture_directory_state(self, starting_state: FolderDict | None = None) -> Generator[TemporaryDirectoryState]:
|
|
109
107
|
"""
|
|
110
108
|
Open a context manager to expose the internal state of the resource.
|
|
111
109
|
|
|
@@ -127,7 +125,7 @@ class TestResourceWrapper(ABC, Generic[VersionT]):
|
|
|
127
125
|
self._directory_state.starting_state = old_start_state
|
|
128
126
|
|
|
129
127
|
@contextmanager
|
|
130
|
-
def _forbid_methods(self, *methods: Callable[..., object]) ->
|
|
128
|
+
def _forbid_methods(self, *methods: Callable[..., object]) -> Generator[None]:
|
|
131
129
|
try:
|
|
132
130
|
for method in methods:
|
|
133
131
|
def new_method(*args: object, **kwargs: object) -> object:
|
|
@@ -514,9 +512,9 @@ class FileTestResourceWrapper(TestResourceWrapper[Version]):
|
|
|
514
512
|
return new_version_config, metadata_pairs
|
|
515
513
|
|
|
516
514
|
@classmethod
|
|
517
|
-
def from_assets_dir(cls: type[
|
|
515
|
+
def from_assets_dir(cls: type[FileTestResourceWrapper], inner_resource_config: ResourceConfig, assets_dir: Path,
|
|
518
516
|
directory_dict: FolderDict | None = None, one_off_build: bool = False,
|
|
519
|
-
instance_vars: dict[str, str] | None = None, **env_vars: str) ->
|
|
517
|
+
instance_vars: dict[str, str] | None = None, **env_vars: str) -> FileTestResourceWrapper:
|
|
520
518
|
"""
|
|
521
519
|
Create an instance from a single folder of asset files.
|
|
522
520
|
|
|
@@ -638,7 +636,7 @@ class FileConversionTestResourceWrapper(FileTestResourceWrapper, Generic[Version
|
|
|
638
636
|
return new_version, metadata
|
|
639
637
|
|
|
640
638
|
@contextmanager
|
|
641
|
-
def _temporarily_create_script_file(self, script_name: ScriptName, method_name: MethodName) ->
|
|
639
|
+
def _temporarily_create_script_file(self, script_name: ScriptName, method_name: MethodName) -> Generator[None]:
|
|
642
640
|
attribute_name = f"{script_name}_script"
|
|
643
641
|
try:
|
|
644
642
|
with TemporaryDirectory() as temp_dir:
|
|
@@ -958,8 +956,7 @@ def run_command(command: str, additional_args: list[str] | None = None, env: dic
|
|
|
958
956
|
cwd=cwd,
|
|
959
957
|
check=True,
|
|
960
958
|
input=stdin.encode() if stdin is not None else None,
|
|
961
|
-
|
|
962
|
-
stderr=subprocess.PIPE,
|
|
959
|
+
capture_output=True,
|
|
963
960
|
)
|
|
964
961
|
except subprocess.CalledProcessError as error:
|
|
965
962
|
error_message: bytes = error.stderr
|
|
@@ -13,6 +13,7 @@ from collections.abc import Callable, MutableMapping
|
|
|
13
13
|
from dataclasses import dataclass
|
|
14
14
|
from datetime import datetime
|
|
15
15
|
from enum import Enum
|
|
16
|
+
import inspect
|
|
16
17
|
from typing import Any, ClassVar, TypeVar, cast, get_type_hints
|
|
17
18
|
|
|
18
19
|
from concoursetools.typing import TypedVersionT, VersionConfig, VersionT
|
|
@@ -261,11 +262,7 @@ class TypedVersion(Version):
|
|
|
261
262
|
_un_flatten_functions: ClassVar[MutableMapping[type[Any], Callable[[type[Any], str], Any]]] = _TypeKeyDict()
|
|
262
263
|
|
|
263
264
|
def __init_subclass__(cls) -> None:
|
|
264
|
-
|
|
265
|
-
annotations = vars(cls)["__annotations__"] # avoid MRO lookup
|
|
266
|
-
except KeyError:
|
|
267
|
-
annotations = {}
|
|
268
|
-
|
|
265
|
+
annotations = inspect.get_annotations(cls)
|
|
269
266
|
if len(annotations) == 0:
|
|
270
267
|
raise TypeError("Can't instantiate dataclass TypedVersion without any fields")
|
|
271
268
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: concoursetools
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: Easily create Concourse resource types in Python.
|
|
5
5
|
Author-email: GCHQ <oss@gchq.gov.uk>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -14,16 +14,17 @@ Classifier: Development Status :: 4 - Beta
|
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
16
|
Classifier: Natural Language :: English
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Topic :: Software Development
|
|
23
23
|
Classifier: Typing :: Typed
|
|
24
|
-
Requires-Python: >=3.
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE.md
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
|
|
28
29
|
<picture>
|
|
29
30
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/gchq/ConcourseTools/main/docs/source/_static/logo-dark.png">
|
|
@@ -31,9 +32,9 @@ License-File: LICENSE.md
|
|
|
31
32
|
<img alt="ConcourseTools logo" src="https://raw.githubusercontent.com/gchq/ConcourseTools/main/docs/source/_static/logo.png">
|
|
32
33
|
</picture>
|
|
33
34
|
|
|
34
|
-

|
|
35
36
|

|
|
36
|
-

|
|
37
38
|

|
|
38
39
|

|
|
39
40
|
|
|
@@ -7,7 +7,7 @@ name = "concoursetools"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = "Easily create Concourse resource types in Python."
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
keywords = [
|
|
12
12
|
"concourse",
|
|
13
13
|
"ci",
|
|
@@ -18,11 +18,11 @@ classifiers = [
|
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
19
|
"License :: OSI Approved :: Apache Software License",
|
|
20
20
|
"Natural Language :: English",
|
|
21
|
-
"Programming Language :: Python :: 3.9",
|
|
22
21
|
"Programming Language :: Python :: 3.10",
|
|
23
22
|
"Programming Language :: Python :: 3.11",
|
|
24
23
|
"Programming Language :: Python :: 3.12",
|
|
25
24
|
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
26
|
"Topic :: Software Development",
|
|
27
27
|
"Typing :: Typed",
|
|
28
28
|
]
|
|
@@ -48,6 +48,14 @@ packages = [
|
|
|
48
48
|
version = {attr = "concoursetools.__version__"}
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
[tool.autopep8]
|
|
52
|
+
max_line_length = 150
|
|
53
|
+
ignore = ["E301", "E501"]
|
|
54
|
+
in-place = true
|
|
55
|
+
recursive = true
|
|
56
|
+
aggressive = 3
|
|
57
|
+
|
|
58
|
+
|
|
51
59
|
[tool.coverage.run]
|
|
52
60
|
command_line = "-m unittest discover"
|
|
53
61
|
source = ["concoursetools"]
|
|
@@ -70,7 +78,7 @@ force_sort_within_sections = true
|
|
|
70
78
|
|
|
71
79
|
|
|
72
80
|
[tool.mypy]
|
|
73
|
-
python_version = "3.
|
|
81
|
+
python_version = "3.13"
|
|
74
82
|
check_untyped_defs = true
|
|
75
83
|
disallow_untyped_defs = true
|
|
76
84
|
warn_redundant_casts = true
|
|
@@ -52,7 +52,7 @@ class FileVersion(Version):
|
|
|
52
52
|
return {"files": json.dumps(list(self.files))}
|
|
53
53
|
|
|
54
54
|
@classmethod
|
|
55
|
-
def from_flat_dict(cls, version_dict: VersionConfig) ->
|
|
55
|
+
def from_flat_dict(cls, version_dict: VersionConfig) -> FileVersion:
|
|
56
56
|
return cls(set(json.loads(version_dict["files"])))
|
|
57
57
|
|
|
58
58
|
|
|
@@ -9,7 +9,7 @@ import unittest
|
|
|
9
9
|
import unittest.mock
|
|
10
10
|
|
|
11
11
|
from concoursetools import __version__
|
|
12
|
-
from concoursetools.cli.parser import _ANNOTATIONS_TO_TYPES,
|
|
12
|
+
from concoursetools.cli.parser import _ANNOTATIONS_TO_TYPES, CLI, Docstring
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class ParsingTests(unittest.TestCase):
|
|
@@ -256,8 +256,6 @@ class AnnotationTests(unittest.TestCase):
|
|
|
256
256
|
self.assertEqual(_ANNOTATIONS_TO_TYPES[float], float)
|
|
257
257
|
|
|
258
258
|
def test_optional_types(self) -> None:
|
|
259
|
-
if _CURRENT_PYTHON_VERSION < (3, 10):
|
|
260
|
-
self.skipTest("Union types with '|' only valid for Python >= 3.10.")
|
|
261
259
|
self.assertEqual(_ANNOTATIONS_TO_TYPES[str | None], str)
|
|
262
260
|
self.assertEqual(_ANNOTATIONS_TO_TYPES[bool | None], bool)
|
|
263
261
|
self.assertEqual(_ANNOTATIONS_TO_TYPES[int | None], int)
|
|
@@ -7,20 +7,25 @@ import json
|
|
|
7
7
|
import os
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from tempfile import TemporaryDirectory
|
|
10
|
-
from typing import Any
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
11
11
|
import unittest
|
|
12
12
|
import unittest.mock
|
|
13
13
|
import urllib.parse
|
|
14
|
+
import warnings
|
|
14
15
|
|
|
15
16
|
try:
|
|
17
|
+
import boto3 # noqa: F401
|
|
18
|
+
import botocore # noqa: F401
|
|
16
19
|
from dateutil.tz import tzlocal
|
|
17
20
|
from moto import mock_aws
|
|
18
21
|
from moto.sagemaker.models import FakePipelineExecution
|
|
19
|
-
|
|
22
|
+
import requests # noqa: F401
|
|
23
|
+
import urllib3 # noqa: F401
|
|
20
24
|
except ImportError:
|
|
21
25
|
allowed_to_skip = ("CI" not in os.environ)
|
|
22
26
|
if allowed_to_skip:
|
|
23
27
|
raise unittest.SkipTest("Cannot proceed without example dependencies - see 'requirements-tests.txt'")
|
|
28
|
+
raise
|
|
24
29
|
|
|
25
30
|
from concoursetools.mocking import TestBuildMetadata
|
|
26
31
|
from concoursetools.testing import SimpleTestResourceWrapper
|
|
@@ -32,6 +37,19 @@ from examples.secrets import Resource as SecretsResource
|
|
|
32
37
|
from examples.secrets import SecretVersion
|
|
33
38
|
from examples.xkcd import ComicVersion, XKCDResource
|
|
34
39
|
|
|
40
|
+
if TYPE_CHECKING:
|
|
41
|
+
from moto.sagemaker.responses import TYPE_RESPONSE, SageMakerResponse
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def setUpModule() -> None:
|
|
45
|
+
"""Code to run before any single test in the module is run."""
|
|
46
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="botocore.auth")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def tearDownModule() -> None:
|
|
50
|
+
"""Code to run after every single test in the module has been run."""
|
|
51
|
+
warnings.filterwarnings("default", category=DeprecationWarning, module="botocore.auth")
|
|
52
|
+
|
|
35
53
|
|
|
36
54
|
class MockedTextResponse:
|
|
37
55
|
"""
|
|
@@ -45,11 +63,11 @@ class MockedTextResponse:
|
|
|
45
63
|
def text(self) -> str:
|
|
46
64
|
return self._data
|
|
47
65
|
|
|
48
|
-
def get(self, *args: object, **kwargs: object) ->
|
|
66
|
+
def get(self, *args: object, **kwargs: object) -> MockedTextResponse:
|
|
49
67
|
return self
|
|
50
68
|
|
|
51
69
|
@classmethod
|
|
52
|
-
def from_file(cls, file_path: str, status_code: int = 200) ->
|
|
70
|
+
def from_file(cls, file_path: str, status_code: int = 200) -> MockedTextResponse:
|
|
53
71
|
with open(file_path) as rf:
|
|
54
72
|
data = rf.read()
|
|
55
73
|
return cls(data, status_code)
|
|
@@ -63,7 +81,7 @@ class MockedJSONResponse:
|
|
|
63
81
|
self._json_data = json_data
|
|
64
82
|
self._status_code = status_code
|
|
65
83
|
|
|
66
|
-
def get(self, *args: object, **kwargs: object) ->
|
|
84
|
+
def get(self, *args: object, **kwargs: object) -> MockedJSONResponse:
|
|
67
85
|
return self
|
|
68
86
|
|
|
69
87
|
def json(self) -> Any:
|
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
import random
|
|
4
4
|
import shutil
|
|
5
5
|
import string
|
|
6
|
+
import sys
|
|
6
7
|
from tempfile import TemporaryDirectory
|
|
7
8
|
from unittest import SkipTest, TestCase
|
|
8
9
|
|
|
@@ -14,6 +15,8 @@ from concoursetools.testing import (ConversionTestResourceWrapper, DockerConvers
|
|
|
14
15
|
run_command)
|
|
15
16
|
from tests.resource import ConcourseMockResource, ConcourseMockVersion, TestResource, TestVersion
|
|
16
17
|
|
|
18
|
+
CONCOURSE_MOCK_RESOURCE_IMAGE = "concourse/mock-resource:0.14.1-20250809"
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
class SimpleWrapperTests(TestCase):
|
|
19
22
|
|
|
@@ -142,7 +145,7 @@ class JSONWrapperTests(TestCase):
|
|
|
142
145
|
def test_check_step_without_version(self) -> None:
|
|
143
146
|
with self.wrapper.capture_debugging() as debugging:
|
|
144
147
|
new_version_configs = self.wrapper.fetch_new_versions()
|
|
145
|
-
self.assertListEqual(new_version_configs, [{"ref": "61cbef"},
|
|
148
|
+
self.assertListEqual(new_version_configs, [{"ref": "61cbef"}, {"ref": "d74e01"}, {"ref": "7154fe"}])
|
|
146
149
|
self.assertEqual(debugging, "")
|
|
147
150
|
|
|
148
151
|
def test_in_step_no_directory_state(self) -> None:
|
|
@@ -298,7 +301,7 @@ class FileWrapperTests(TestCase):
|
|
|
298
301
|
"""Code to run before each test."""
|
|
299
302
|
self.temp_dir = TemporaryDirectory()
|
|
300
303
|
cli_commands.assets(self.temp_dir.name, resource_file="tests/resource.py",
|
|
301
|
-
class_name=TestResource.__name__, executable=
|
|
304
|
+
class_name=TestResource.__name__, executable=sys.executable)
|
|
302
305
|
|
|
303
306
|
config = {
|
|
304
307
|
"uri": "git://some-uri",
|
|
@@ -339,7 +342,7 @@ class FileWrapperTests(TestCase):
|
|
|
339
342
|
def test_check_step_without_version(self) -> None:
|
|
340
343
|
with self.wrapper.capture_debugging() as debugging:
|
|
341
344
|
new_version_configs = self.wrapper.fetch_new_versions()
|
|
342
|
-
self.assertListEqual(new_version_configs, [{"ref": "61cbef"},
|
|
345
|
+
self.assertListEqual(new_version_configs, [{"ref": "61cbef"}, {"ref": "d74e01"}, {"ref": "7154fe"}])
|
|
343
346
|
self.assertEqual(debugging, "")
|
|
344
347
|
|
|
345
348
|
def test_in_step_no_directory_state(self) -> None:
|
|
@@ -406,7 +409,7 @@ class FileConversionWrapperTests(TestCase):
|
|
|
406
409
|
"branch": "develop",
|
|
407
410
|
"private_key": "...",
|
|
408
411
|
}
|
|
409
|
-
self.wrapper = FileConversionTestResourceWrapper(TestResource, config, executable=
|
|
412
|
+
self.wrapper = FileConversionTestResourceWrapper(TestResource, config, executable=sys.executable)
|
|
410
413
|
|
|
411
414
|
def test_check_step_with_version_no_debugging(self) -> None:
|
|
412
415
|
version = TestVersion("61cbef")
|
|
@@ -538,7 +541,7 @@ class DockerWrapperTests(TestCase):
|
|
|
538
541
|
def test_check_step_without_version(self) -> None:
|
|
539
542
|
with self.wrapper.capture_debugging() as debugging:
|
|
540
543
|
new_version_configs = self.wrapper.fetch_new_versions()
|
|
541
|
-
self.assertListEqual(new_version_configs, [{"ref": "61cbef"},
|
|
544
|
+
self.assertListEqual(new_version_configs, [{"ref": "61cbef"}, {"ref": "d74e01"}, {"ref": "7154fe"}])
|
|
542
545
|
self.assertEqual(debugging, "")
|
|
543
546
|
|
|
544
547
|
def test_in_step_no_directory_state(self) -> None:
|
|
@@ -728,7 +731,12 @@ def _build_test_resource_docker_image() -> str:
|
|
|
728
731
|
except FileNotFoundError:
|
|
729
732
|
pass
|
|
730
733
|
|
|
731
|
-
|
|
734
|
+
# This pins the tag to the exact version of Python we're using, including alpha/beta
|
|
735
|
+
# '3.14.0b1 (main, May 9 2025, 23:49:24) [GCC 12.2.0]'
|
|
736
|
+
# ^^^^^^^^
|
|
737
|
+
tag, *_ = sys.version.split()
|
|
738
|
+
cli_commands.dockerfile(str(temp_dir), resource_file="concourse.py", class_name=TestResource.__name__,
|
|
739
|
+
tag=tag, dev=True)
|
|
732
740
|
|
|
733
741
|
stdout, _ = run_command("docker", ["build", ".", "-q"], cwd=temp_dir)
|
|
734
742
|
sha1_hash = stdout.strip()
|
|
@@ -736,7 +744,6 @@ def _build_test_resource_docker_image() -> str:
|
|
|
736
744
|
|
|
737
745
|
|
|
738
746
|
class ExternalDockerWrapperTests(TestCase):
|
|
739
|
-
image = "concourse/mock-resource"
|
|
740
747
|
|
|
741
748
|
@classmethod
|
|
742
749
|
def setUpClass(cls) -> None:
|
|
@@ -750,7 +757,7 @@ class ExternalDockerWrapperTests(TestCase):
|
|
|
750
757
|
"log": "Debug message",
|
|
751
758
|
"metadata": [{"name": "key", "value": "value"}],
|
|
752
759
|
}
|
|
753
|
-
self.wrapper = DockerTestResourceWrapper(config,
|
|
760
|
+
self.wrapper = DockerTestResourceWrapper(config, CONCOURSE_MOCK_RESOURCE_IMAGE)
|
|
754
761
|
|
|
755
762
|
def test_check_step_with_version_no_debugging(self) -> None:
|
|
756
763
|
version_config = {"version": "1", "privileged": "true"}
|
|
@@ -906,7 +913,8 @@ class ExternalDockerWrapperTests(TestCase):
|
|
|
906
913
|
])
|
|
907
914
|
|
|
908
915
|
expected_env_lines = {
|
|
909
|
-
self._format_debugging_message("env: PATH=/usr/local/sbin:/usr/local/bin:/usr/
|
|
916
|
+
self._format_debugging_message("env: PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin "),
|
|
917
|
+
self._format_debugging_message("env: SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt "),
|
|
910
918
|
self._format_debugging_message("env: HOSTNAME=resource"),
|
|
911
919
|
self._format_debugging_message("env: HOME=/root"),
|
|
912
920
|
}
|
|
@@ -923,7 +931,6 @@ class ExternalDockerWrapperTests(TestCase):
|
|
|
923
931
|
|
|
924
932
|
|
|
925
933
|
class ExternalDockerConversionWrapperTests(TestCase):
|
|
926
|
-
image = "concourse/mock-resource"
|
|
927
934
|
|
|
928
935
|
@classmethod
|
|
929
936
|
def setUpClass(cls) -> None:
|
|
@@ -937,7 +944,7 @@ class ExternalDockerConversionWrapperTests(TestCase):
|
|
|
937
944
|
"log": "Debug message",
|
|
938
945
|
"metadata": [{"name": "key", "value": "value"}],
|
|
939
946
|
}
|
|
940
|
-
self.wrapper = DockerConversionTestResourceWrapper(ConcourseMockResource, config,
|
|
947
|
+
self.wrapper = DockerConversionTestResourceWrapper(ConcourseMockResource, config, CONCOURSE_MOCK_RESOURCE_IMAGE)
|
|
941
948
|
|
|
942
949
|
def test_check_step_with_version_no_debugging(self) -> None:
|
|
943
950
|
version = ConcourseMockVersion(version=1, privileged=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|