From 6d2a10612fd1ecd8b723680073d49cb3a696d50f Mon Sep 17 00:00:00 2001 From: Alexey Ovchinnikov Date: Mon, 16 Dec 2024 14:50:42 -0600 Subject: [PATCH] yarn_v1: making Yarn v1 externally invisible With the introduction of automated yarn packages dispatch it does not make sense to keep user-visible yarn-classic references. This commit removes all public mentions of it. Signed-off-by: Alexey Ovchinnikov --- cachi2/core/models/input.py | 16 +--------------- cachi2/core/resolver.py | 2 +- tests/unit/models/test_input.py | 2 +- tests/unit/test_cli.py | 6 +++--- tests/unit/test_resolver.py | 1 - 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/cachi2/core/models/input.py b/cachi2/core/models/input.py index 5a4a39269..805b95d27 100644 --- a/cachi2/core/models/input.py +++ b/cachi2/core/models/input.py @@ -52,9 +52,7 @@ def show_error(error: "ErrorDict") -> str: # Supported package managers -PackageManagerType = Literal[ - "bundler", "generic", "gomod", "npm", "pip", "rpm", "yarn", "yarn-classic" -] +PackageManagerType = Literal["bundler", "generic", "gomod", "npm", "pip", "rpm", "yarn"] Flag = Literal[ "cgo-disable", "dev-package-managers", "force-gomod-tidy", "gomod-vendor", "gomod-vendor-check" @@ -225,12 +223,6 @@ class YarnPackageInput(_PackageInputBase): type: Literal["yarn"] -class YarnClassicPackageInput(_PackageInputBase): - """Accepted input for a yarn classic package.""" - - type: Literal["yarn-classic"] - - PackageInput = Annotated[ Union[ BundlerPackageInput, @@ -239,7 +231,6 @@ class YarnClassicPackageInput(_PackageInputBase): NpmPackageInput, PipPackageInput, RpmPackageInput, - YarnClassicPackageInput, YarnPackageInput, ], # https://pydantic-docs.helpmanual.io/usage/types/#discriminated-unions-aka-tagged-unions @@ -341,10 +332,5 @@ def yarn_packages(self) -> list[YarnPackageInput]: """Get the yarn packages specified for this request.""" return self._packages_by_type(YarnPackageInput) - @property - def yarn_classic_packages(self) -> list[YarnClassicPackageInput]: - """Get the yarn classic packages specified for this request.""" - return self._packages_by_type(YarnClassicPackageInput) - def _packages_by_type(self, pkgtype: type[T]) -> list[T]: return [package for package in self.packages if isinstance(package, pkgtype)] diff --git a/cachi2/core/resolver.py b/cachi2/core/resolver.py index d28210f74..f9cc2c469 100644 --- a/cachi2/core/resolver.py +++ b/cachi2/core/resolver.py @@ -37,7 +37,7 @@ def resolve_packages(request: Request) -> RequestOutput: This function performs the operations in a working copy of the source directory in case a package manager that can make unwanted modifications will be used. """ - if request.yarn_packages or request.yarn_classic_packages: + if request.yarn_packages: original_source_dir = request.source_dir with TemporaryDirectory(".cachi2-source-copy", dir=".") as temp_dir: diff --git a/tests/unit/models/test_input.py b/tests/unit/models/test_input.py index ebfe54f10..d0bd75d47 100644 --- a/tests/unit/models/test_input.py +++ b/tests/unit/models/test_input.py @@ -155,7 +155,7 @@ def test_valid_packages(self, input_data: dict[str, Any], expect_data: dict[str, ), pytest.param( {"type": "go-package"}, - r"Input tag 'go-package' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn-classic', 'yarn'", + r"Input tag 'go-package' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn'", id="incorrect_type_tag", ), pytest.param( diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index 320c75b3e..f43572fbd 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -358,7 +358,7 @@ def test_specify_packages( [ "Error: InvalidInput: 1 validation error for user input", "packages -> 0", - "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn-classic', 'yarn'", + "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn'", ], ), ( @@ -366,7 +366,7 @@ def test_specify_packages( [ "Error: InvalidInput: 1 validation error for user input", "packages -> 0", - "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn-classic', 'yarn'", + "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn'", ], ), ( @@ -374,7 +374,7 @@ def test_specify_packages( [ "Error: InvalidInput: 1 validation error for user input", "packages -> 0", - "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn-classic', 'yarn'", + "Input tag 'idk' found using 'type' does not match any of the expected tags: 'bundler', 'generic', 'gomod', 'npm', 'pip', 'rpm', 'yarn'", ], ), # Missing package type diff --git a/tests/unit/test_resolver.py b/tests/unit/test_resolver.py index 21fa35363..c27afbdf3 100644 --- a/tests/unit/test_resolver.py +++ b/tests/unit/test_resolver.py @@ -104,7 +104,6 @@ def fetch(req: Request) -> RequestOutput: "packages, copy_exists", [ ([{"type": "yarn"}], True), - ([{"type": "yarn-classic"}], True), ([{"type": "gomod"}, {"type": "pip"}, {"type": "npm"}], False), ], )