Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ def render_lock_spec( # noqa: C901
editable: Sequence[str],
) -> None:
"""Combine source files into a single lock specification"""
kinds: Set[Literal["pixi.toml", "raw"]] = set(kind) # ty: ignore[invalid-assignment]
kinds: Set[Literal["pixi.toml", "raw"]] = set(kind)
if len(kinds) == 0:
raise ValueError("No kind specified. Add `--kind=pixi.toml` or `--kind=raw`.")
if not kinds <= {"pixi.toml", "raw"}:
Expand Down
10 changes: 6 additions & 4 deletions conda_lock/conda_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ def _get_pkgs_dirs(


def _reconstruct_fetch_actions(
conda: PathLike, platform: str, dry_run_install: DryRunInstall
) -> DryRunInstall:
conda: PathLike,
platform: str,
dry_run_install: DryRunInstall | dict[str, dict[str, list[Any]]],
) -> DryRunInstall | dict[str, dict[str, list[Any]]]:
"""
Conda may choose to link a previously downloaded distribution from pkgs_dirs rather
than downloading a fresh one. Find the repodata record in existing distributions
Expand Down Expand Up @@ -271,7 +273,7 @@ def solve_specs_for_arch(
channels: Sequence[Channel],
specs: list[str],
platform: str,
) -> DryRunInstall:
) -> DryRunInstall | dict[str, dict[str, list[Any]]]:
"""
Solve conda specifications for the given platform

Expand Down Expand Up @@ -393,7 +395,7 @@ def update_specs_for_arch(
update: list[str],
platform: str,
channels: Sequence[Channel],
) -> DryRunInstall:
) -> DryRunInstall | dict[str, dict[str, list[Any]]]:
"""
Update a previous solution for the given platform

Expand Down
2 changes: 1 addition & 1 deletion conda_lock/content_hash_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class EmptyDict(TypedDict):
pass


HashableVirtualPackageRepresentation: "TypeAlias" = dict[
HashableVirtualPackageRepresentation = dict[
PlatformSubdirStr, SubdirMetadata | EmptyDict
]

Expand Down
8 changes: 6 additions & 2 deletions conda_lock/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@


try:
from conda.plugins import hookimpl # type: ignore[unused-ignore]
from conda.plugins.types import CondaSubcommand # type: ignore[unused-ignore]
from conda.plugins import (
hookimpl, # type: ignore[unused-ignore]
)
from conda.plugins.types import (
CondaSubcommand, # type: ignore[unused-ignore]
)

HAVE_CONDA = True
except ImportError:
Expand Down
8 changes: 3 additions & 5 deletions conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def _get_stripped_url(link: Link) -> str:
clean_netloc = f"{parsed_url.hostname}"
if parsed_url.port is not None:
clean_netloc = f"{clean_netloc}:{parsed_url.port}"
return urlunsplit( # ty: ignore[invalid-return-type]
return urlunsplit(
(
parsed_url.scheme,
clean_netloc,
Expand Down Expand Up @@ -583,7 +583,7 @@ def solve_pypi(
input = ArgvInput()
input.set_stream(sys.stdin)
io = IO(input, StreamOutput(sys.stdout), StreamOutput(sys.stderr))
VERY_VERBOSE: Verbosity = Verbosity.VERY_VERBOSE # ty: ignore[invalid-assignment] # pyright: ignore[reportAssignmentType]
VERY_VERBOSE: Verbosity = Verbosity.VERY_VERBOSE # pyright: ignore[reportAssignmentType]
io.set_verbosity(VERY_VERBOSE)
else:
io = NullIO()
Expand Down Expand Up @@ -692,6 +692,4 @@ def _strip_auth(url: str) -> str:
# Remove everything before and including the last '@' character in the part
# between 'scheme://' and the subsequent '/'.
netloc = parts.netloc.split("@")[-1]
return urlunsplit( # ty: ignore[invalid-return-type]
(parts.scheme, netloc, parts.path, parts.query, parts.fragment)
)
return urlunsplit((parts.scheme, netloc, parts.path, parts.query, parts.fragment))
42 changes: 25 additions & 17 deletions conda_lock/src_parser/meta_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class UndefinedNeverFail(jinja2.Undefined):

all_undefined_names: list[str | None] = []

def __init__( # type: ignore
def __init__(
self,
hint=None,
obj=jinja2.utils.missing,
name=None,
exc=jinja2.exceptions.UndefinedError,
hint: Any = None,
obj: Any = jinja2.utils.missing,
name: Any = None,
exc: Any = jinja2.exceptions.UndefinedError,
) -> None:
jinja2.Undefined.__init__(self, hint, obj, name, exc)

Expand All @@ -54,20 +54,12 @@ def __init__( # type: ignore

# Accessing an attribute of an Undefined variable
# results in another Undefined variable.
def __getattr__(self, k: str) -> "UndefinedNeverFail":
def __getattr__(self, name: str) -> "UndefinedNeverFail":
try:
return object.__getattr__(self, k) # type: ignore
return object.__getattr__(self, name) # type: ignore
except AttributeError:
assert self._undefined_name is not None
return self._return_undefined(self._undefined_name + "." + k)

# Unlike the methods above, Python requires that these
# few methods must always return the correct type
__str__ = __repr__ = lambda self: self._return_value("") # type: ignore
__unicode__ = lambda self: self._return_value("") # noqa: E731
__int__ = lambda self: self._return_value(0) # type: ignore # noqa: E731
__float__ = lambda self: self._return_value(0.0) # type: ignore # noqa: E731
__nonzero__ = lambda self: self._return_value(False) # noqa: E731
return self._return_undefined(self._undefined_name + "." + name)

def _return_undefined(self, result_name: str) -> "UndefinedNeverFail":
# Record that this undefined variable was actually used.
Expand All @@ -79,11 +71,27 @@ def _return_undefined(self, result_name: str) -> "UndefinedNeverFail":
exc=self._undefined_exception,
)

def _return_value(self, value=None): # type: ignore
def _return_value(self, value: Any = None) -> Any:
# Record that this undefined variable was actually used.
UndefinedNeverFail.all_undefined_names.append(self._undefined_name)
return value

# Unlike the methods above, Python requires that these
# few methods must always return the correct type
def __repr__(self) -> str:
return self._return_value("")

__str__ = __repr__
__unicode__ = lambda self: self._return_value("") # noqa: E731

def __int__(self) -> Any:
return self._return_value(0)

def __float__(self) -> Any:
return self._return_value(0.0)

__nonzero__ = lambda self: self._return_value(False) # noqa: E731


def parse_meta_yaml_file(
meta_yaml_file: pathlib.Path,
Expand Down
Loading
Loading