diff --git a/components/polylith/bricks/base.py b/components/polylith/bricks/base.py index d9bb70a6..3b1725ad 100644 --- a/components/polylith/bricks/base.py +++ b/components/polylith/bricks/base.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import List from polylith.bricks import component from polylith.bricks.brick import create_brick @@ -11,5 +12,5 @@ def create_base(path: Path, namespace: str, package: str) -> None: create_test(path, bases_dir, namespace, package) -def get_bases_data(path: Path, ns: str) -> list[dict]: +def get_bases_data(path: Path, ns: str) -> List[dict]: return component.get_components_data(path, ns, bases_dir) diff --git a/components/polylith/bricks/component.py b/components/polylith/bricks/component.py index 5105aeeb..14118802 100644 --- a/components/polylith/bricks/component.py +++ b/components/polylith/bricks/component.py @@ -1,9 +1,10 @@ from pathlib import Path +from typing import List +from polylith import workspace from polylith.bricks.brick import create_brick from polylith.repo import components_dir from polylith.test import create_test -from polylith import workspace def create_component(path: Path, namespace: str, package: str) -> None: @@ -25,7 +26,7 @@ def get_component_dirs(root: Path, top_dir, ns) -> list: def get_components_data( root: Path, ns: str, top_dir: str = components_dir -) -> list[dict]: +) -> List[dict]: dirs = get_component_dirs(root, top_dir, ns) return [{"name": d.name} for d in dirs] diff --git a/components/polylith/diff/__init__.py b/components/polylith/diff/__init__.py index 609b547a..632746bf 100644 --- a/components/polylith/diff/__init__.py +++ b/components/polylith/diff/__init__.py @@ -1,4 +1,3 @@ -from polylith.diff import collect -from polylith.diff import report +from polylith.diff import collect, report __all__ = ["collect", "report"] diff --git a/components/polylith/diff/collect.py b/components/polylith/diff/collect.py index 979eebf0..44051ecb 100644 --- a/components/polylith/diff/collect.py +++ b/components/polylith/diff/collect.py @@ -1,30 +1,30 @@ import subprocess from pathlib import Path -from typing import Union +from typing import List, Union from polylith import repo, workspace -def _get_changed(folder: str, changed_files: list[Path]) -> set: +def _get_changed(folder: str, changed_files: List[Path]) -> set: return {p.parent.name for p in changed_files if folder in p.as_posix()} -def _get_changed_bricks(root: Path, top_dir: str, changed_files: list[Path]) -> list: +def _get_changed_bricks(root: Path, top_dir: str, changed_files: List[Path]) -> list: namespace = workspace.parser.get_namespace_from_config(root) d = f"{top_dir}/{namespace}" return sorted(_get_changed(d, changed_files)) -def get_changed_components(root: Path, changed_files: list[Path]) -> list: +def get_changed_components(root: Path, changed_files: List[Path]) -> list: return _get_changed_bricks(root, repo.components_dir, changed_files) -def get_changed_bases(root: Path, changed_files: list[Path]) -> list: +def get_changed_bases(root: Path, changed_files: List[Path]) -> list: return _get_changed_bricks(root, repo.bases_dir, changed_files) -def get_changed_projects(changed_files: list[Path]) -> list: +def get_changed_projects(changed_files: List[Path]) -> list: res = _get_changed(repo.projects_dir, changed_files) filtered = {p for p in res if p != repo.projects_dir} return sorted(filtered) @@ -41,7 +41,7 @@ def get_latest_tag(root: Path) -> Union[str, None]: return next((tag for tag in res.stdout.decode("utf-8").split()), None) -def get_files(tag: str) -> list[Path]: +def get_files(tag: str) -> List[Path]: res = subprocess.run( ["git", "diff", tag, "--stat", "--name-only"], capture_output=True, diff --git a/components/polylith/diff/report.py b/components/polylith/diff/report.py index 0bb05770..4a261056 100644 --- a/components/polylith/diff/report.py +++ b/components/polylith/diff/report.py @@ -1,3 +1,5 @@ +from typing import List + from rich import box from rich.columns import Columns from rich.console import Console @@ -22,7 +24,7 @@ def brick_status(brick, bricks) -> str: def print_diff_details( - projects_data: list[dict], bases: list[str], components: list[str] + projects_data: List[dict], bases: List[str], components: List[str] ) -> None: console = Console(theme=info_theme) table = Table(box=box.SIMPLE_HEAD) @@ -43,7 +45,7 @@ def print_diff_details( console.print(table, overflow="ellipsis") -def print_detected_changes_in_projects(projects: list[str]) -> None: +def print_detected_changes_in_projects(projects: List[str]) -> None: if not projects: return @@ -53,9 +55,7 @@ def print_detected_changes_in_projects(projects: list[str]) -> None: console.print(f"[data]:gear: Changes found in [/][proj]{project}[/]") -def print_diff_summary( - tag: str, bases: list[str], components: list[str] -) -> None: +def print_diff_summary(tag: str, bases: List[str], components: List[str]) -> None: console = Console(theme=info_theme) console.print(Padding(f"[data]Diff: based on the {tag} tag[/]", (1, 0, 1, 0))) diff --git a/components/polylith/dirs/dirs.py b/components/polylith/dirs/dirs.py index 443fe98f..e80fb6e9 100644 --- a/components/polylith/dirs/dirs.py +++ b/components/polylith/dirs/dirs.py @@ -1,6 +1,6 @@ from pathlib import Path -from polylith.files import create_file +from polylith.files import create_file keep_file_name = ".keep" diff --git a/components/polylith/info/__init__.py b/components/polylith/info/__init__.py index 65a280aa..4b274296 100644 --- a/components/polylith/info/__init__.py +++ b/components/polylith/info/__init__.py @@ -1,4 +1,8 @@ from polylith.info.collect import get_bricks_in_projects from polylith.info.report import print_bricks_in_projects, print_workspace_summary -__all__ = ["get_bricks_in_projects", "print_bricks_in_projects", "print_workspace_summary"] +__all__ = [ + "get_bricks_in_projects", + "print_bricks_in_projects", + "print_workspace_summary", +] diff --git a/components/polylith/info/collect.py b/components/polylith/info/collect.py index a9d90911..e5362daa 100644 --- a/components/polylith/info/collect.py +++ b/components/polylith/info/collect.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import List from polylith import workspace from polylith.bricks import base, component @@ -6,8 +7,8 @@ def get_matching_bricks( - paths: list[Path], bricks: list[str], namespace: str -) -> list[str]: + paths: List[Path], bricks: List[str], namespace: str +) -> List[str]: paths_in_namespace = (p.name for p in paths if p.parent.name == namespace) res = set(bricks).intersection(paths_in_namespace) @@ -15,7 +16,7 @@ def get_matching_bricks( return sorted(list(res)) -def get_project_bricks(project_packages: list[dict], components, bases, namespace: str): +def get_project_bricks(project_packages: List[dict], components, bases, namespace: str): paths = parse_package_paths(project_packages) components_in_project = get_matching_bricks(paths, components, namespace) @@ -24,7 +25,7 @@ def get_project_bricks(project_packages: list[dict], components, bases, namespac return {"components": components_in_project, "bases": bases_in_project} -def get_bricks_in_projects(root: Path) -> list[dict]: +def get_bricks_in_projects(root: Path) -> List[dict]: namespace = workspace.parser.get_namespace_from_config(root) packages_for_projects = get_packages_for_projects(root) diff --git a/components/polylith/info/report.py b/components/polylith/info/report.py index 7974b53f..dca22612 100644 --- a/components/polylith/info/report.py +++ b/components/polylith/info/report.py @@ -1,3 +1,5 @@ +from typing import List + from rich import box from rich.columns import Columns from rich.console import Console @@ -22,7 +24,7 @@ def brick_status(brick, bricks) -> str: def print_bricks_in_projects( - projects_data: list[dict], bases_data: list[dict], components_data: list[dict] + projects_data: List[dict], bases_data: List[dict], components_data: List[dict] ) -> None: if not components_data and not bases_data: return @@ -50,7 +52,7 @@ def print_bricks_in_projects( def print_workspace_summary( - projects_data: list[dict], bases_data: list[dict], components_data: list[dict] + projects_data: List[dict], bases_data: List[dict], components_data: List[dict] ) -> None: console = Console(theme=info_theme) diff --git a/components/polylith/poetry/commands/create_project.py b/components/polylith/poetry/commands/create_project.py index ba421867..2c473b0e 100644 --- a/components/polylith/poetry/commands/create_project.py +++ b/components/polylith/poetry/commands/create_project.py @@ -1,7 +1,7 @@ from cleo.helpers import option from poetry.console.commands.command import Command -from polylith.poetry.commands.create import create from polylith import project +from polylith.poetry.commands.create import create command_name = "poly create project" diff --git a/components/polylith/project/__init__.py b/components/polylith/project/__init__.py index 83a32583..dbc55152 100644 --- a/components/polylith/project/__init__.py +++ b/components/polylith/project/__init__.py @@ -1,5 +1,5 @@ from polylith.project.create import create_project -from polylith.project.get import get_project_names, get_packages_for_projects +from polylith.project.get import get_packages_for_projects, get_project_names from polylith.project.parser import parse_package_paths __all__ = [ diff --git a/components/polylith/project/create.py b/components/polylith/project/create.py index df5b2c3e..3a236f17 100644 --- a/components/polylith/project/create.py +++ b/components/polylith/project/create.py @@ -2,8 +2,8 @@ import tomlkit from polylith import repo -from polylith.repo import projects_dir from polylith.dirs import create_dir +from polylith.repo import projects_dir template = """\ [tool.poetry] diff --git a/components/polylith/project/get.py b/components/polylith/project/get.py index 6f06d893..1e90e96b 100644 --- a/components/polylith/project/get.py +++ b/components/polylith/project/get.py @@ -1,11 +1,12 @@ from collections.abc import Generator from pathlib import Path +from typing import List import tomlkit from polylith.repo import default_toml -def get_project_package_includes(data) -> list[dict]: +def get_project_package_includes(data) -> List[dict]: return data["tool"]["poetry"]["packages"] @@ -22,19 +23,19 @@ def get_project_files(root: Path) -> Generator: return root.glob(f"projects/**/{default_toml}") -def get_toml_files(root: Path) -> list[tomlkit.TOMLDocument]: +def get_toml_files(root: Path) -> List[tomlkit.TOMLDocument]: project_files = get_project_files(root) return [get_toml(p) for p in project_files] -def get_project_names(root: Path) -> list[str]: +def get_project_names(root: Path) -> List[str]: tomls = get_toml_files(root) return [get_project_name(d) for d in tomls] -def get_packages_for_projects(root: Path) -> list[dict]: +def get_packages_for_projects(root: Path) -> List[dict]: tomls = get_toml_files(root) return [ diff --git a/components/polylith/project/parser.py b/components/polylith/project/parser.py index 7a6d206e..820b36fa 100644 --- a/components/polylith/project/parser.py +++ b/components/polylith/project/parser.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import List def to_path(package: dict) -> Path: @@ -8,7 +9,7 @@ def to_path(package: dict) -> Path: return Path(f"{from_path}/{include}") if from_path else Path(include) -def parse_package_paths(packages: list[dict]) -> list[Path]: +def parse_package_paths(packages: List[dict]) -> List[Path]: sorted_packages = sorted(packages, key=lambda p: (p["from"], p["include"])) return [to_path(p) for p in sorted_packages] diff --git a/components/polylith/readme/readme.py b/components/polylith/readme/readme.py index ec3b692b..99965b94 100644 --- a/components/polylith/readme/readme.py +++ b/components/polylith/readme/readme.py @@ -2,7 +2,6 @@ from polylith import log, repo - template = """\ # A Python Polylith repo diff --git a/development/david.py b/development/david.py index 7330a55c..4b4506e2 100644 --- a/development/david.py +++ b/development/david.py @@ -1,7 +1,6 @@ from pathlib import Path from polylith import ( - poetry_plugin, bricks, development, diff, @@ -11,6 +10,7 @@ interface, log, poetry, + poetry_plugin, project, readme, repo,