From 91fce1fdd18d92e152955c1b1edaad0ee70862c4 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 31 Dec 2022 20:07:38 +0100 Subject: [PATCH] Make Dependency a TypeAlias The _BaseDependency class is never used except for inheritance. --- conda_lock/src_parser/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conda_lock/src_parser/__init__.py b/conda_lock/src_parser/__init__.py index 8ce156e41..601114fc2 100644 --- a/conda_lock/src_parser/__init__.py +++ b/conda_lock/src_parser/__init__.py @@ -61,7 +61,7 @@ def for_platform(self, platform: str) -> bool: return self.platform is None or platform in self.platform -class Dependency(StrictModel): +class _BaseDependency(StrictModel): name: str manager: Literal["conda", "pip"] = "conda" optional: bool = False @@ -70,17 +70,20 @@ class Dependency(StrictModel): selectors: Selectors = Selectors() -class VersionedDependency(Dependency): +class VersionedDependency(_BaseDependency): version: str build: Optional[str] = None conda_channel: Optional[str] = None -class URLDependency(Dependency): +class URLDependency(_BaseDependency): url: str hashes: List[str] +Dependency = Union[VersionedDependency, URLDependency] + + class Package(StrictModel): url: str hash: str