Loading pkgs/by-name/ni/nixos-rebuild-ng/package.nix +6 −3 Original line number Diff line number Diff line Loading @@ -134,14 +134,17 @@ python3Packages.buildPythonApplication rec { # NOTE: this is a passthru test rather than a build-time test because we # want to keep the build closures small linters = runCommand "${pname}-linters" { nativeBuildInputs = [ python-with-pkgs ]; } '' export MYPY_CACHE_DIR="$(mktemp -d)" export RUFF_CACHE_DIR="$(mktemp -d)" pushd ${src} echo -e "\x1b[32m## run mypy\x1b[0m" mypy ${src} mypy . echo -e "\x1b[32m## run ruff\x1b[0m" ruff check ${src} ruff check . echo -e "\x1b[32m## run ruff format\x1b[0m" ruff format --check ${src} ruff format --check . popd touch $out ''; Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/constants.py +1 −0 Original line number Diff line number Diff line # mypy: disable-error-code=comparison-overlap from typing import Final # Build-time flags Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +10 −11 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from typing import Any, ClassVar, Self, TypedDict, override from .process import Remote, run_wrapper type ImageVariants = list[str] type ImageVariants = dict[str, str] class NixOSRebuildError(Exception): Loading Loading @@ -77,7 +77,7 @@ def _get_hostname(target_host: Remote | None) -> str | None: @dataclass(frozen=True) class Flake: path: Path | str path: str attr: str _re: ClassVar = re.compile(r"^(?P<path>[^\#]*)\#?(?P<attr>[^\#\"]*)$") Loading @@ -86,10 +86,6 @@ class Flake: @override def __str__(self) -> str: if isinstance(self.path, Path): # https://github.com/NixOS/nixpkgs/issues/433726 return f"{self.path.absolute()}#{self.attr}" else: return f"{self.path}#{self.attr}" @classmethod Loading @@ -101,10 +97,7 @@ class Flake: f'nixosConfigurations."{attr or _get_hostname(target_host) or "default"}"' ) path = m.group("path") if ":" in path: return cls(path, nixos_attr) else: return cls(Path(path), nixos_attr) @classmethod def from_arg(cls, flake_arg: Any, target_host: Remote | None) -> Self | None: # noqa: ANN401 Loading @@ -125,6 +118,12 @@ class Flake: else: return None def resolve_path_if_exists(self) -> str: try: return str(Path(self.path).resolve(strict=True)) except FileNotFoundError: return self.path @dataclass(frozen=True) class Generation: Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +1 −1 Original line number Diff line number Diff line Loading @@ -545,7 +545,7 @@ def repl_flake(flake: Flake, flake_flags: Args | None = None) -> None: files(__package__).joinpath(FLAKE_REPL_TEMPLATE).read_text() ).substitute( flake=flake, flake_path=flake.path.resolve() if isinstance(flake.path, Path) else flake.path, flake_path=flake.resolve_path_if_exists(), flake_attr=flake.attr, bold="\033[1m", blue="\033[34;1m", Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ class LogFormatter(logging.Formatter): } @override def format(self, record: logging.LogRecord) -> str: def format(self, record: logging.LogRecord) -> Any: record.levelname = record.levelname.lower() formatter = self.formatters.get(record.levelno, self.formatters["DEFAULT"]) return formatter.format(record) Loading Loading
pkgs/by-name/ni/nixos-rebuild-ng/package.nix +6 −3 Original line number Diff line number Diff line Loading @@ -134,14 +134,17 @@ python3Packages.buildPythonApplication rec { # NOTE: this is a passthru test rather than a build-time test because we # want to keep the build closures small linters = runCommand "${pname}-linters" { nativeBuildInputs = [ python-with-pkgs ]; } '' export MYPY_CACHE_DIR="$(mktemp -d)" export RUFF_CACHE_DIR="$(mktemp -d)" pushd ${src} echo -e "\x1b[32m## run mypy\x1b[0m" mypy ${src} mypy . echo -e "\x1b[32m## run ruff\x1b[0m" ruff check ${src} ruff check . echo -e "\x1b[32m## run ruff format\x1b[0m" ruff format --check ${src} ruff format --check . popd touch $out ''; Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/constants.py +1 −0 Original line number Diff line number Diff line # mypy: disable-error-code=comparison-overlap from typing import Final # Build-time flags Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +10 −11 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from typing import Any, ClassVar, Self, TypedDict, override from .process import Remote, run_wrapper type ImageVariants = list[str] type ImageVariants = dict[str, str] class NixOSRebuildError(Exception): Loading Loading @@ -77,7 +77,7 @@ def _get_hostname(target_host: Remote | None) -> str | None: @dataclass(frozen=True) class Flake: path: Path | str path: str attr: str _re: ClassVar = re.compile(r"^(?P<path>[^\#]*)\#?(?P<attr>[^\#\"]*)$") Loading @@ -86,10 +86,6 @@ class Flake: @override def __str__(self) -> str: if isinstance(self.path, Path): # https://github.com/NixOS/nixpkgs/issues/433726 return f"{self.path.absolute()}#{self.attr}" else: return f"{self.path}#{self.attr}" @classmethod Loading @@ -101,10 +97,7 @@ class Flake: f'nixosConfigurations."{attr or _get_hostname(target_host) or "default"}"' ) path = m.group("path") if ":" in path: return cls(path, nixos_attr) else: return cls(Path(path), nixos_attr) @classmethod def from_arg(cls, flake_arg: Any, target_host: Remote | None) -> Self | None: # noqa: ANN401 Loading @@ -125,6 +118,12 @@ class Flake: else: return None def resolve_path_if_exists(self) -> str: try: return str(Path(self.path).resolve(strict=True)) except FileNotFoundError: return self.path @dataclass(frozen=True) class Generation: Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +1 −1 Original line number Diff line number Diff line Loading @@ -545,7 +545,7 @@ def repl_flake(flake: Flake, flake_flags: Args | None = None) -> None: files(__package__).joinpath(FLAKE_REPL_TEMPLATE).read_text() ).substitute( flake=flake, flake_path=flake.path.resolve() if isinstance(flake.path, Path) else flake.path, flake_path=flake.resolve_path_if_exists(), flake_attr=flake.attr, bold="\033[1m", blue="\033[34;1m", Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ class LogFormatter(logging.Formatter): } @override def format(self, record: logging.LogRecord) -> str: def format(self, record: logging.LogRecord) -> Any: record.levelname = record.levelname.lower() formatter = self.formatters.get(record.levelno, self.formatters["DEFAULT"]) return formatter.format(record) Loading