fix mypy errors
Some checks failed
build / test (pull_request) Failing after 27s

This commit is contained in:
Jörg Thalheim 2023-08-23 12:32:06 +02:00
parent 7b7a367ff4
commit 59e31b3c56
3 changed files with 27 additions and 37 deletions

View File

@ -5,11 +5,17 @@
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, ... }: {
perSystem = { self', pkgs, ... }: {
treefmt.projectRootFile = "flake.nix";
treefmt.flakeCheck = true;
treefmt.flakeFormatter = true;
treefmt.programs.shellcheck.enable = true;
treefmt.programs.mypy.enable = true;
treefmt.programs.mypy.directories = {
"pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.testDependencies;
};
treefmt.settings.formatter.nix = {
command = "sh";
options = [
@ -38,4 +44,3 @@
};
};
}

View File

@ -1,22 +1,18 @@
import argparse
import sys
from types import ModuleType
from typing import Optional
from . import admin, secrets, update
from . import admin, config, secrets, update
from .errors import ClanError
from .ssh import cli as ssh_cli
argcomplete = None
argcomplete: Optional[ModuleType] = None
try:
import argcomplete
import argcomplete # type: ignore[no-redef]
except ImportError:
pass
config = None
try:
from . import config
except ImportError: # jsonschema not installed
pass
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
def main() -> None:
@ -26,9 +22,8 @@ def main() -> None:
parser_admin = subparsers.add_parser("admin", help="administrate a clan")
admin.register_parser(parser_admin)
if config:
parser_config = subparsers.add_parser("config", help="set nixos configuration")
config.register_parser(parser_config)
parser_config = subparsers.add_parser("config", help="set nixos configuration")
config.register_parser(parser_config)
parser_ssh = subparsers.add_parser("ssh", help="ssh to a remote machine")
ssh_cli.register_parser(parser_ssh)

View File

@ -3,7 +3,6 @@
, black
, bubblewrap
, installShellFiles
, mypy
, nix
, openssh
, pytest
@ -31,7 +30,6 @@ let
pytest
pytest-cov
pytest-subprocess
mypy
openssh
stdenv.cc
];
@ -60,27 +58,17 @@ python3.pkgs.buildPythonPackage {
];
propagatedBuildInputs = dependencies;
passthru.tests = {
clan-mypy = runCommand "clan-mypy" { } ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
${checkPython}/bin/mypy .
touch $out
'';
clan-pytest = runCommand "clan-tests"
{
nativeBuildInputs = [ age zerotierone bubblewrap sops nix openssh rsync stdenv.cc ];
} ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
NIX_STATE_DIR=$TMPDIR/nix ${checkPython}/bin/python -m pytest -s ./tests
touch $out
'';
};
passthru.tests.clan-pytest = runCommand "clan-tests"
{
nativeBuildInputs = [ age zerotierone bubblewrap sops nix openssh rsync stdenv.cc ];
} ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
NIX_STATE_DIR=$TMPDIR/nix ${checkPython}/bin/python -m pytest -s ./tests
touch $out
'';
passthru.devDependencies = [
ruff
@ -89,6 +77,8 @@ python3.pkgs.buildPythonPackage {
wheel
] ++ testDependencies;
passthru.testDependencies = testDependencies;
makeWrapperArgs = [
"--set CLAN_FLAKE ${self}"
];