Skip to content

Commit

Permalink
yarn_v1: making Yarn v1 externally invisible
Browse files Browse the repository at this point in the history
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 <aovchinn@redhat.com>
  • Loading branch information
a-ovchinnikov committed Dec 16, 2024
1 parent 9530971 commit 6d2a106
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
16 changes: 1 addition & 15 deletions cachi2/core/models/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -239,7 +231,6 @@ class YarnClassicPackageInput(_PackageInputBase):
NpmPackageInput,
PipPackageInput,
RpmPackageInput,
YarnClassicPackageInput,
YarnPackageInput,
],
# https://pydantic-docs.helpmanual.io/usage/types/#discriminated-unions-aka-tagged-unions
Expand Down Expand Up @@ -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)]
2 changes: 1 addition & 1 deletion cachi2/core/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/models/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,23 @@ 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'",
],
),
(
'[{"type": "idk"}]',
[
"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'",
],
),
(
'{"packages": [{"type": "idk"}]}',
[
"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
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
)
Expand Down

0 comments on commit 6d2a106

Please sign in to comment.