Skip to content

Commit 96c1326

Browse files
committed
Add type hints for poetry dependency with hash
1 parent 8d59f9a commit 96c1326

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

conda_lock/pypi_solver.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
from pathlib import Path
66
from posixpath import expandvars
7-
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Tuple, Union
7+
from typing import TYPE_CHECKING, Dict, FrozenSet, List, Literal, Optional, Tuple, Union
88
from urllib.parse import urldefrag, urlsplit, urlunsplit
99

1010
from clikit.api.io.flags import VERY_VERBOSE
1111
from clikit.io import ConsoleIO, NullIO
1212
from packaging.tags import compatible_tags, cpython_tags, mac_platforms
1313
from packaging.version import Version
1414

15+
from conda_lock._vendor.poetry.core.semver import VersionConstraint
1516
from conda_lock.interfaces.vendored_poetry import (
1617
Chooser,
1718
Env,
@@ -280,9 +281,33 @@ def parse_pip_requirement(requirement: str) -> Optional[Dict[str, str]]:
280281

281282

282283
class PoetryDependencyWithHash(PoetryDependency):
283-
def __init__(self, *args, hash: Optional[str] = None, **kwargs) -> None:
284+
def __init__(
285+
self,
286+
name, # type: str
287+
constraint, # type: Union[str, VersionConstraint]
288+
optional=False, # type: bool
289+
category="main", # type: str
290+
allows_prereleases=False, # type: bool
291+
extras=None, # type: Optional[Union[List[str], FrozenSet[str]]]
292+
source_type=None, # type: Optional[str]
293+
source_url=None, # type: Optional[str]
294+
source_reference=None, # type: Optional[str]
295+
source_resolved_reference=None, # type: Optional[str]
296+
hash: Optional[str] = None,
297+
) -> None:
298+
super().__init__(
299+
name,
300+
constraint,
301+
optional=optional,
302+
category=category,
303+
allows_prereleases=allows_prereleases,
304+
extras=extras, # type: ignore # upstream type hint is wrong
305+
source_type=source_type,
306+
source_url=source_url,
307+
source_reference=source_reference,
308+
source_resolved_reference=source_resolved_reference,
309+
)
284310
self.hash = hash
285-
super().__init__(*args, **kwargs)
286311

287312
def get_hash_model(self) -> Optional[HashModel]:
288313
if self.hash:

0 commit comments

Comments
 (0)