diff --git a/compose_generator/compose_generator.py b/compose_generator/compose_generator.py index cbec5dd..cdd8c8c 100644 --- a/compose_generator/compose_generator.py +++ b/compose_generator/compose_generator.py @@ -1,3 +1,4 @@ +"""Top level generic entity for creating a compose""" from dataclasses import dataclass from .protocols import ( @@ -20,6 +21,7 @@ class ComposeGenerator: :param requestor: an object to request a new composed :param fetcher: an object to fetch a compose once it's ready """ + configurations_generator: ComposeConfigurationsGenerator requestor: ComposeRequester fetcher: ComposeFetcher diff --git a/compose_generator/odcs_compose_generator.py b/compose_generator/odcs_compose_generator.py index 3af29db..4b0179d 100644 --- a/compose_generator/odcs_compose_generator.py +++ b/compose_generator/odcs_compose_generator.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 +"""Initialize and use a compose generator using ODCS""" + +from .compose_generator import ComposeGenerator +from .odcs_configurations_generator import ODCSConfigurationsGenerator from .odcs_fetcher import ODCSFetcher from .odcs_requester import ODCSRequester -from .odcs_configurations_generator import ODCSConfigurationsGenerator -from .compose_generator import ComposeGenerator def main(): diff --git a/compose_generator/odcs_configurations_generator.py b/compose_generator/odcs_configurations_generator.py index 17a1d43..c0e39cf 100644 --- a/compose_generator/odcs_configurations_generator.py +++ b/compose_generator/odcs_configurations_generator.py @@ -1,3 +1,4 @@ +"""Configurations generator for ODCS compose""" from dataclasses import dataclass from .protocols import ComposeConfigurations, ComposeConfigurationsGenerator @@ -18,6 +19,7 @@ class ODCSConfigurationsGenerator(ComposeConfigurationsGenerator): :param container_data: data loaded from container.yaml :param content_sets_data: data loaded from content_sets.yaml """ + container_data: dict content_sets_data: dict diff --git a/compose_generator/odcs_fetcher.py b/compose_generator/odcs_fetcher.py index 4a83172..51307a3 100644 --- a/compose_generator/odcs_fetcher.py +++ b/compose_generator/odcs_fetcher.py @@ -1,3 +1,4 @@ +"""Fetch ready ODCS compose""" from dataclasses import dataclass from pathlib import Path @@ -9,6 +10,7 @@ class ODCSResultReference(ComposeReference): """ Reference to a locally-stored compose result """ + compose_path: Path @@ -17,5 +19,6 @@ class ODCSFetcher(ComposeFetcher): """ Fetch ODCS compose based on a remote compose-reference and store it locally """ + def __call__(self, request_reference: ComposeReference) -> ODCSResultReference: raise NotImplementedError() diff --git a/compose_generator/odcs_requester.py b/compose_generator/odcs_requester.py index 3175cb8..a5292c8 100644 --- a/compose_generator/odcs_requester.py +++ b/compose_generator/odcs_requester.py @@ -1,3 +1,4 @@ +"""Request a new ODCS compose""" from dataclasses import dataclass from .protocols import ComposeConfigurations, ComposeReference, ComposeRequester @@ -8,6 +9,7 @@ class ODCSRequestReference(ComposeReference): """ Reference to a remotely-stored compose data """ + compose_url: str @@ -17,5 +19,6 @@ class ODCSRequester(ComposeRequester): Request a new ODCS compose based on compose configurations and return a reference to the remote compose location. """ + def __call__(self, configs: ComposeConfigurations) -> ODCSRequestReference: raise NotImplementedError() diff --git a/compose_generator/protocols.py b/compose_generator/protocols.py index f7687cd..5dc385d 100644 --- a/compose_generator/protocols.py +++ b/compose_generator/protocols.py @@ -1,5 +1,8 @@ +"""compose generator protocols""" from typing import Protocol +# pylint: disable=too-few-public-methods + class ComposeConfigurations(Protocol): """ @@ -11,6 +14,7 @@ class ComposeConfigurationsGenerator(Protocol): """ Generate compose configurations """ + def __call__(self) -> ComposeConfigurations: pass @@ -25,6 +29,7 @@ class ComposeRequester(Protocol): """ Given compose configurations, return a remote compose reference """ + def __call__(self, configs: ComposeConfigurations) -> ComposeReference: pass diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..45c5dfb --- /dev/null +++ b/format.sh @@ -0,0 +1,11 @@ +#!/bin/bash -ex + +main() { + local pkgs=("tests" "compose_generator") + pipenv run isort --profile black "${pkgs[@]}" + pipenv run black "${pkgs[@]}" +} + +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + main "$@" +fi diff --git a/tests/test_static_check.py b/tests/test_static_check.py new file mode 100644 index 0000000..6ed98f9 --- /dev/null +++ b/tests/test_static_check.py @@ -0,0 +1,25 @@ +"""Static checks""" +from subprocess import run +from typing import Final + +PKGS: Final[list[str]] = ["tests", "compose_generator"] + + +def test_mypy() -> None: + """Static Type check""" + run(["mypy"] + PKGS, check=True) + + +def test_isort() -> None: + """Imports formatting check""" + run(["isort", "--check", "--profile", "black"] + PKGS, check=True) + + +def test_black() -> None: + """Formatting check""" + run(["black", "--check"] + PKGS, check=True) + + +def test_pylint() -> None: + """Lint check""" + run(["pylint"] + PKGS, check=True)