enable more linting
This commit is contained in:
parent
7ae02d86af
commit
26e3e3872c
@ -16,13 +16,14 @@ find = {}
|
|||||||
test_driver = ["py.typed"]
|
test_driver = ["py.typed"]
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
target-version = "py311"
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
|
||||||
select = ["E", "F", "I", "U", "N"]
|
select = ["E", "F", "I", "U", "N", "RUF"]
|
||||||
ignore = ["E501"]
|
ignore = ["E501"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.10"
|
python_version = "3.11"
|
||||||
warn_redundant_casts = true
|
warn_redundant_casts = true
|
||||||
disallow_untyped_calls = true
|
disallow_untyped_calls = true
|
||||||
disallow_untyped_defs = true
|
disallow_untyped_defs = true
|
||||||
|
@ -50,7 +50,7 @@ def merge(a: dict, b: dict, path: list[str] = []) -> dict:
|
|||||||
for key in b:
|
for key in b:
|
||||||
if key in a:
|
if key in a:
|
||||||
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
||||||
merge(a[key], b[key], path + [str(key)])
|
merge(a[key], b[key], [*path, str(key)])
|
||||||
elif isinstance(a[key], list) and isinstance(b[key], list):
|
elif isinstance(a[key], list) and isinstance(b[key], list):
|
||||||
a[key].extend(b[key])
|
a[key].extend(b[key])
|
||||||
elif a[key] != b[key]:
|
elif a[key] != b[key]:
|
||||||
|
@ -14,7 +14,7 @@ async def add_flake(path: Path) -> Dict[str, CmdOut]:
|
|||||||
# TODO: Make this atomic
|
# TODO: Make this atomic
|
||||||
lines: set = set()
|
lines: set = set()
|
||||||
if user_history_file().exists():
|
if user_history_file().exists():
|
||||||
with open(user_history_file(), "r") as f:
|
with open(user_history_file()) as f:
|
||||||
lines = set(f.readlines())
|
lines = set(f.readlines())
|
||||||
lines.add(str(path))
|
lines.add(str(path))
|
||||||
with open(user_history_file(), "w") as f:
|
with open(user_history_file(), "w") as f:
|
||||||
|
@ -9,7 +9,7 @@ def list_history() -> list[Path]:
|
|||||||
if not user_history_file().exists():
|
if not user_history_file().exists():
|
||||||
return []
|
return []
|
||||||
# read path lines from history file
|
# read path lines from history file
|
||||||
with open(user_history_file(), "r") as f:
|
with open(user_history_file()) as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
return [Path(line.strip()) for line in lines]
|
return [Path(line.strip()) for line in lines]
|
||||||
|
|
||||||
|
@ -49,23 +49,22 @@ def deploy_nixos(hosts: HostGroup, clan_dir: Path) -> None:
|
|||||||
if target_user:
|
if target_user:
|
||||||
target_host = f"{target_user}@{target_host}"
|
target_host = f"{target_user}@{target_host}"
|
||||||
extra_args = h.meta.get("extra_args", [])
|
extra_args = h.meta.get("extra_args", [])
|
||||||
cmd = (
|
cmd = [
|
||||||
["nixos-rebuild", "switch"]
|
"nixos-rebuild",
|
||||||
+ extra_args
|
"switch",
|
||||||
+ [
|
*extra_args,
|
||||||
"--fast",
|
"--fast",
|
||||||
"--option",
|
"--option",
|
||||||
"keep-going",
|
"keep-going",
|
||||||
"true",
|
"true",
|
||||||
"--option",
|
"--option",
|
||||||
"accept-flake-config",
|
"accept-flake-config",
|
||||||
"true",
|
"true",
|
||||||
"--build-host",
|
"--build-host",
|
||||||
"",
|
"",
|
||||||
"--flake",
|
"--flake",
|
||||||
f"{path}#{flake_attr}",
|
f"{path}#{flake_attr}",
|
||||||
]
|
]
|
||||||
)
|
|
||||||
if target_host:
|
if target_host:
|
||||||
cmd.extend(["--target-host", target_host])
|
cmd.extend(["--target-host", target_host])
|
||||||
ret = h.run(cmd, check=False)
|
ret = h.run(cmd, check=False)
|
||||||
|
@ -12,7 +12,7 @@ from .errors import ClanError
|
|||||||
|
|
||||||
@deal.raises(ClanError)
|
@deal.raises(ClanError)
|
||||||
def nix_command(flags: list[str]) -> list[str]:
|
def nix_command(flags: list[str]) -> list[str]:
|
||||||
return ["nix", "--extra-experimental-features", "nix-command flakes"] + flags
|
return ["nix", "--extra-experimental-features", "nix-command flakes", *flags]
|
||||||
|
|
||||||
|
|
||||||
def nix_flake_show(flake_url: str | Path) -> list[str]:
|
def nix_flake_show(flake_url: str | Path) -> list[str]:
|
||||||
@ -68,19 +68,17 @@ def nix_eval(flags: list[str]) -> list[str]:
|
|||||||
)
|
)
|
||||||
if os.environ.get("IN_NIX_SANDBOX"):
|
if os.environ.get("IN_NIX_SANDBOX"):
|
||||||
with tempfile.TemporaryDirectory() as nix_store:
|
with tempfile.TemporaryDirectory() as nix_store:
|
||||||
return (
|
return [
|
||||||
default_flags
|
*default_flags,
|
||||||
+ [
|
"--override-input",
|
||||||
"--override-input",
|
"nixpkgs",
|
||||||
"nixpkgs",
|
str(nixpkgs_source()),
|
||||||
str(nixpkgs_source()),
|
# --store is required to prevent this error:
|
||||||
# --store is required to prevent this error:
|
# error: cannot unlink '/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh': Operation not permitted
|
||||||
# error: cannot unlink '/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh': Operation not permitted
|
"--store",
|
||||||
"--store",
|
nix_store,
|
||||||
nix_store,
|
*flags,
|
||||||
]
|
]
|
||||||
+ flags
|
|
||||||
)
|
|
||||||
return default_flags + flags
|
return default_flags + flags
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +94,7 @@ def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
|
|||||||
[
|
[
|
||||||
"shell",
|
"shell",
|
||||||
"--inputs-from",
|
"--inputs-from",
|
||||||
f"{str(nixpkgs_flake())}",
|
f"{nixpkgs_flake()!s}",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
+ wrapped_packages
|
+ wrapped_packages
|
||||||
|
@ -28,7 +28,7 @@ def upload_secrets(machine: Machine) -> None:
|
|||||||
" ".join(["ssh"] + ssh_cmd[2:]),
|
" ".join(["ssh"] + ssh_cmd[2:]),
|
||||||
"-az",
|
"-az",
|
||||||
"--delete",
|
"--delete",
|
||||||
f"{str(tempdir)}/",
|
f"{tempdir!s}/",
|
||||||
f"{host.user}@{host.host}:{machine.secrets_upload_directory}/",
|
f"{host.user}@{host.host}:{machine.secrets_upload_directory}/",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -456,7 +456,8 @@ class Host:
|
|||||||
else:
|
else:
|
||||||
bash_cmd += cmd
|
bash_cmd += cmd
|
||||||
# FIXME we assume bash to be present here? Should be documented...
|
# FIXME we assume bash to be present here? Should be documented...
|
||||||
ssh_cmd = self.ssh_cmd(verbose_ssh=verbose_ssh) + [
|
ssh_cmd = [
|
||||||
|
*self.ssh_cmd(verbose_ssh=verbose_ssh),
|
||||||
"--",
|
"--",
|
||||||
f"{sudo}bash -c {quote(bash_cmd)} -- {' '.join(map(quote, bash_args))}",
|
f"{sudo}bash -c {quote(bash_cmd)} -- {' '.join(map(quote, bash_args))}",
|
||||||
]
|
]
|
||||||
@ -497,7 +498,7 @@ class Host:
|
|||||||
if verbose_ssh or self.verbose_ssh:
|
if verbose_ssh or self.verbose_ssh:
|
||||||
ssh_opts.extend(["-v"])
|
ssh_opts.extend(["-v"])
|
||||||
|
|
||||||
return ["ssh", ssh_target] + ssh_opts
|
return ["ssh", ssh_target, *ssh_opts]
|
||||||
|
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
@ -21,7 +21,8 @@ def ssh(
|
|||||||
"-p",
|
"-p",
|
||||||
password,
|
password,
|
||||||
]
|
]
|
||||||
_ssh_args = ssh_args + [
|
_ssh_args = [
|
||||||
|
*ssh_args,
|
||||||
"ssh",
|
"ssh",
|
||||||
"-o",
|
"-o",
|
||||||
"UserKnownHostsFile=/dev/null",
|
"UserKnownHostsFile=/dev/null",
|
||||||
@ -29,7 +30,7 @@ def ssh(
|
|||||||
"StrictHostKeyChecking=no",
|
"StrictHostKeyChecking=no",
|
||||||
f"{user}@{host}",
|
f"{user}@{host}",
|
||||||
]
|
]
|
||||||
cmd = nix_shell(packages, ["torify"] + password_args + _ssh_args)
|
cmd = nix_shell(packages, ["torify", *password_args, *_ssh_args])
|
||||||
subprocess.run(cmd)
|
subprocess.run(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,9 +117,9 @@ class BuildVmTask(BaseTask):
|
|||||||
cmd.run(
|
cmd.run(
|
||||||
nix_build(
|
nix_build(
|
||||||
[
|
[
|
||||||
f'{clan_dir}#clanInternals.machines."{system}"."{machine}".config.system.clan.vm.create'
|
f'{clan_dir}#clanInternals.machines."{system}"."{machine}".config.system.clan.vm.create',
|
||||||
|
*self.nix_options,
|
||||||
]
|
]
|
||||||
+ self.nix_options
|
|
||||||
),
|
),
|
||||||
name="buildvm",
|
name="buildvm",
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ markers = ["impure", "with_core"]
|
|||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
plugins = ["deal.mypy"]
|
plugins = ["deal.mypy"]
|
||||||
python_version = "3.10"
|
python_version = "3.11"
|
||||||
warn_redundant_casts = true
|
warn_redundant_casts = true
|
||||||
disallow_untyped_calls = true
|
disallow_untyped_calls = true
|
||||||
disallow_untyped_defs = true
|
disallow_untyped_defs = true
|
||||||
@ -53,7 +53,7 @@ module = "setuptools.*"
|
|||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
target-version = "py311"
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
select = ["E", "F", "I", "U", "N", "RUF"]
|
||||||
select = ["E", "F", "I", "N"]
|
|
||||||
ignore = ["E501", "E402"]
|
ignore = ["E501", "E402"]
|
||||||
|
@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
|
|||||||
class Cli:
|
class Cli:
|
||||||
def run(self, args: list[str]) -> argparse.Namespace:
|
def run(self, args: list[str]) -> argparse.Namespace:
|
||||||
parser = create_parser(prog="clan")
|
parser = create_parser(prog="clan")
|
||||||
cmd = shlex.join(["clan"] + args)
|
cmd = shlex.join(["clan", *args])
|
||||||
log.debug(f"$ {cmd}")
|
log.debug(f"$ {cmd}")
|
||||||
log.debug(f"Caller {get_caller()}")
|
log.debug(f"Caller {get_caller()}")
|
||||||
parsed = parser.parse_args(args)
|
parsed = parser.parse_args(args)
|
||||||
|
@ -47,8 +47,8 @@ def test_set_some_option(
|
|||||||
example_options,
|
example_options,
|
||||||
"--settings-file",
|
"--settings-file",
|
||||||
out_file.name,
|
out_file.name,
|
||||||
|
*args,
|
||||||
]
|
]
|
||||||
+ args
|
|
||||||
)
|
)
|
||||||
json_out = json.loads(open(out_file.name).read())
|
json_out = json.loads(open(out_file.name).read())
|
||||||
assert json_out == expected
|
assert json_out == expected
|
||||||
|
@ -15,7 +15,7 @@ def test_flake_history_append(
|
|||||||
api: TestClient, test_flake: FlakeForTest, temporary_home: Path
|
api: TestClient, test_flake: FlakeForTest, temporary_home: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
response = api.post(
|
response = api.post(
|
||||||
f"/api/flake/history?flake_dir={str(test_flake.path)}",
|
f"/api/flake/history?flake_dir={test_flake.path!s}",
|
||||||
json={},
|
json={},
|
||||||
)
|
)
|
||||||
assert response.status_code == 200, response.json()
|
assert response.status_code == 200, response.json()
|
||||||
@ -34,7 +34,7 @@ def test_flake_history_list(
|
|||||||
|
|
||||||
# add the test_flake
|
# add the test_flake
|
||||||
response = api.post(
|
response = api.post(
|
||||||
f"/api/flake/history?flake_dir={str(test_flake.path)}",
|
f"/api/flake/history?flake_dir={test_flake.path!s}",
|
||||||
json={},
|
json={},
|
||||||
)
|
)
|
||||||
assert response.status_code == 200, response.text
|
assert response.status_code == 200, response.text
|
||||||
|
@ -11,7 +11,7 @@ scripts = { clan-vm-manager = "clan_vm_manager:main" }
|
|||||||
clan_vm_manager = ["*.glade"]
|
clan_vm_manager = ["*.glade"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.10"
|
python_version = "3.11"
|
||||||
warn_redundant_casts = true
|
warn_redundant_casts = true
|
||||||
disallow_untyped_calls = true
|
disallow_untyped_calls = true
|
||||||
disallow_untyped_defs = true
|
disallow_untyped_defs = true
|
||||||
@ -22,7 +22,7 @@ module = "gi.*"
|
|||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
target-version = "py311"
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
select = ["E", "F", "I", "N", "RUF", "U"]
|
||||||
select = ["E", "F", "I", "N"]
|
|
||||||
ignore = ["E501", "E402", "N802"]
|
ignore = ["E501", "E402", "N802"]
|
||||||
|
Loading…
Reference in New Issue
Block a user