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
14 changes: 12 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ on:
branches:
- main
paths:
- ".pre-commit-config.yaml"
- ".github/workflows/tests.yml"
- "conda_self/**"
- "pixi.lock"
- "pyproject.toml"
- "recipe/**"
- "tests/**"
pull_request:
branches:
- main
paths:
- ".pre-commit-config.yaml"
- ".github/workflows/tests.yml"
- "conda_self/**"
- "pixi.lock"
Expand All @@ -32,6 +32,16 @@ concurrency:
cancel-in-progress: true

jobs:
typecheck:
name: Type check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: prefix-dev/setup-pixi@f00437f565399d418b0acc85936d12c1fb668347 # v0.10.1
with:
environments: typecheck
- run: pixi run --environment typecheck typecheck

tests:
name: ${{ matrix.os }}, py${{ matrix.python-version }}, ${{ matrix.channel }}
runs-on: ${{ matrix.os }}
Expand Down
13 changes: 8 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# disable autofixing PRs, commenting "pre-commit.ci autofix" on a pull request triggers a autofix
ci:
autofix_prs: false
# GitHub Actions runs ty because pre-commit.ci does not provide Pixi.
skip: [ty]
# generally speaking we ignore all vendored code as well as tests data
# TODO: Restore index and solver exclude lines before merge
exclude: |
Expand Down Expand Up @@ -41,11 +43,6 @@ repos:
args: [--fix]
# compatible replacement for black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v2.3.1' # Use the sha / tag you want to point at
hooks:
- id: mypy
exclude: ^docs/.*$
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.38.0
hooks:
Expand All @@ -57,6 +54,12 @@ repos:
- id: check-useless-excludes
- repo: local
hooks:
- id: ty
name: ty
entry: pixi run --environment typecheck typecheck
language: system
pass_filenames: false
always_run: true
- id: git-diff
name: git diff
entry: git diff --exit-code
Expand Down
4 changes: 3 additions & 1 deletion conda_self/health_checks/base_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def fix(prefix: str, args: Namespace, confirm: ConfirmCallback) -> int:
)
if not context.quiet:
print(f"Saving snapshot to {snapshot_file}")
snapshot_file.write_text(explicit_exporter.export(env))
export = explicit_exporter.export
assert export is not None
snapshot_file.write_text(export(env))
except CondaValueError:
if not context.quiet:
print(
Expand Down
2 changes: 1 addition & 1 deletion conda_self/package_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# This is required for reading entry point info from an extracted package
# ref: https://packaging.python.org/en/latest/specifications/entry-points/#file-format
class CaseSensitiveConfigParser(configparser.ConfigParser):
optionxform = staticmethod(str) # type: ignore
optionxform = staticmethod(str)


class PackageInfo:
Expand Down
7 changes: 5 additions & 2 deletions conda_self/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conda.core.prefix_data import PrefixData
from conda.models.prefix_graph import PrefixGraph

from .constants import PERMANENT_PACKAGES
from .constants import PERMANENT_PACKAGES, SELF_PERMANENT_PACKAGES_SETTING
from .exceptions import NoDistInfoDirFound
from .package_info import PackageInfo

Expand All @@ -22,7 +22,10 @@ def permanent_dependencies(add_plugins: bool = False) -> set[str]:
installed = list(PrefixData(sys.prefix, interoperability=True).iter_records())
prefix_graph = PrefixGraph(installed)

protect = [*PERMANENT_PACKAGES, *context.plugins.self_permanent_packages]
protect = [
*PERMANENT_PACKAGES,
*getattr(context.plugins, SELF_PERMANENT_PACKAGES_SETTING),
]

if add_plugins:
for record in installed:
Expand Down
9 changes: 4 additions & 5 deletions conda_self/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from os.path import dirname, isfile
from typing import TYPE_CHECKING

from boltons.setutils import IndexedSet
from conda import CondaError, CondaExitZero, CondaMultiError
from conda.base.constants import EXPLICIT_MARKER
from conda.base.context import context
Expand All @@ -30,7 +29,7 @@

def records_from_snapshot(
prefix: str, snapshot_content: list[str]
) -> tuple[IndexedSet, tuple[MatchSpec, ...]]:
) -> tuple[tuple[PackageRecord, ...], tuple[MatchSpec, ...]]:
"""Return package records for the snapshot and MatchSpecs to install or relink."""
entries = tuple(line for line in snapshot_content if line != EXPLICIT_MARKER)
try:
Expand Down Expand Up @@ -149,9 +148,9 @@ def records_from_snapshot(
for index, record in zip(unresolved_indices, fetched_records, strict=True):
records[index] = record

return IndexedSet(record for record in records if record is not None), tuple(
unresolved_specs
)
return tuple(
dict.fromkeys(record for record in records if record is not None)
), tuple(unresolved_specs)


def names_from_explicit(path: Path) -> set[str]:
Expand Down
Loading