nixbot

builds

failed treefmt-check checks.x86_64-linux.treefmt · build #186 · raw

1treefmt v2.5.0ERRO formatter | ruff-check: failed to apply with options '[check --fix]': exit status 123S107 Possible hardcoded password assigned to function default: "token"4 --> checks/hermes-desktop-connections/test.py:21:305 |621 | def run(script, *args, token="tok-1"):7 | ^^^^^^^822 | return subprocess.run(923 | [script, "--url", URL, *args],10 |1112SIM112 Use capitalized environment variable `WITHREMOTES` instead of `withRemotes`13 --> checks/hermes-desktop-connections/test.py:49:2714 |1549 | with_remotes = os.environ["withRemotes"]16 | ^^^^^^^^^^^^^1750 | office_only = os.environ["officeOnly"]1851 | enforcing = os.environ["enforcing"]19 |20help: Replace `withRemotes` with `WITHREMOTES`2122SIM112 Use capitalized environment variable `OFFICEONLY` instead of `officeOnly`23 --> checks/hermes-desktop-connections/test.py:50:2624 |2549 | with_remotes = os.environ["withRemotes"]2650 | office_only = os.environ["officeOnly"]27 | ^^^^^^^^^^^^2851 | enforcing = os.environ["enforcing"]29 |30help: Replace `officeOnly` with `OFFICEONLY`3132SIM112 Use capitalized environment variable `ENFORCING` instead of `enforcing`33 --> checks/hermes-desktop-connections/test.py:51:2434 |3549 | with_remotes = os.environ["withRemotes"]3650 | office_only = os.environ["officeOnly"]3751 | enforcing = os.environ["enforcing"]38 | ^^^^^^^^^^^3952 |4053 | # Fresh render.41 |42help: Replace `enforcing` with `ENFORCING`4344S106 Possible hardcoded password assigned to argument: "token"45 --> checks/hermes-desktop-connections/test.py:108:1846 |47107 | # A token change reaches both files on the next launch.48108 | run(office_only, token="tok-2")49 | ^^^^^^^^^^^^^50109 | check(load(CONNECTION)["remote"]["token"]["value"] == "tok-2", "connection.json follows the token")51110 | check(load(REGISTRY)["connections"][1]["token"]["value"] == "tok-2", "registry follows the token")52 |5354S106 Possible hardcoded password assigned to argument: "token"55 --> checks/hermes-desktop-connections/test.py:114:2256 |57112 | # connection.json saved in the app stays, and the launcher says so.58113 | CONNECTION.write_text(json.dumps({"mode": "local", "profiles": {}}))59114 | r = run(office_only, token="tok-2")60 | ^^^^^^^^^^^^^61115 | check(load(CONNECTION)["mode"] == "local", "user gateway left alone")62116 | check(str(CONNECTION) in r.stderr and "--reset-connections" in r.stderr, f"stderr names the file: {r.stderr!r}")63 |6465S106 Possible hardcoded password assigned to argument: "token"66 --> checks/hermes-desktop-connections/test.py:120:2967 |68119 | # --reset restores it; the user's registry entry survives the reset.69120 | run(office_only, "--reset", token="tok-2")70 | ^^^^^^^^^^^^^71121 | check(load(CONNECTION)["mode"] == "remote", "reset restores the managed gateway")72122 | check("mine" in ids(load(REGISTRY)), "user entry survives reset")73 |7475S106 Possible hardcoded password assigned to argument: "token"76 --> checks/hermes-desktop-connections/test.py:126:2077 |78124 | # enforcePrimary overwrites a user gateway without a reset.79125 | CONNECTION.write_text(json.dumps({"mode": "local", "profiles": {}}))80126 | r = run(enforcing, token="tok-2")81 | ^^^^^^^^^^^^^82127 | check(load(CONNECTION)["remote"]["url"] == URL and r.stderr == "", "enforcePrimary overwrites")83 |8485S106 Possible hardcoded password assigned to argument: "token"86 --> checks/hermes-desktop-connections/test.py:132:1887 |88130 | SIDECAR.unlink()89131 | CONNECTION.write_text(json.dumps({"mode": "local", "profiles": {}}))90132 | run(office_only, token="tok-2")91 | ^^^^^^^^^^^^^92133 | check(load(CONNECTION)["mode"] == "remote", "first adoption takes over a stray connection.json")93 |9495S106 Possible hardcoded password assigned to argument: "token"96 --> checks/hermes-desktop-connections/test.py:140:1897 |98138 | REGISTRY.unlink()99139 | REGISTRY.symlink_to(target)100140 | run(office_only, token="tok-2")101 | ^^^^^^^^^^^^^102141 | check(not REGISTRY.is_symlink() and REGISTRY.is_file() and mode(REGISTRY) == 0o600, "symlink replaced by a regular file")103142 | check(load(target)["connections"] == [], "symlink target untouched")104 |105106S106 Possible hardcoded password assigned to argument: "token"107 --> checks/hermes-desktop-connections/test.py:146:18108 |109144 | # Garbage in the registry is not fatal.110145 | REGISTRY.write_text("{not json")111146 | run(office_only, token="tok-2")112 | ^^^^^^^^^^^^^113147 | check(ids(load(REGISTRY)) == ["local", "nix-this-machine", "nix-office"], "unparsable registry is rebuilt")114 |115116ANN201 Missing return type annotation for public function `warn`117 --> modules/nixos/hermes/desktop-connections.py:48:5118 |11948 | def warn(msg):120 | ^^^^12149 | print(f"hermes-desktop-connections: {msg}", file=sys.stderr)122 |123help: Add return type annotation: `None`124125ANN001 Missing type annotation for function argument `msg`126 --> modules/nixos/hermes/desktop-connections.py:48:10127 |12848 | def warn(msg):129 | ^^^13049 | print(f"hermes-desktop-connections: {msg}", file=sys.stderr)131 |132133ANN201 Missing return type annotation for public function `load_json`134 --> modules/nixos/hermes/desktop-connections.py:52:5135 |13652 | def load_json(path):137 | ^^^^^^^^^13853 | try:13954 | with open(path, encoding="utf-8") as f:140 |141help: Add return type annotation142143ANN001 Missing type annotation for function argument `path`144 --> modules/nixos/hermes/desktop-connections.py:52:15145 |14652 | def load_json(path):147 | ^^^^14853 | try:14954 | with open(path, encoding="utf-8") as f:150 |151152PTH123 `open()` should be replaced by `Path.open()`153 --> modules/nixos/hermes/desktop-connections.py:54:14154 |15552 | def load_json(path):15653 | try:15754 | with open(path, encoding="utf-8") as f:158 | ^^^^15955 | return json.load(f)16056 | except (OSError, ValueError):161 |162help: Replace with `Path.open()`163164ANN201 Missing return type annotation for public function `read_bytes`165 --> modules/nixos/hermes/desktop-connections.py:60:5166 |16760 | def read_bytes(path):168 | ^^^^^^^^^^16961 | try:17062 | with open(path, "rb") as f:171 |172help: Add return type annotation173174ANN001 Missing type annotation for function argument `path`175 --> modules/nixos/hermes/desktop-connections.py:60:16176 |17760 | def read_bytes(path):178 | ^^^^17961 | try:18062 | with open(path, "rb") as f:181 |182183PTH123 `open()` should be replaced by `Path.open()`184 --> modules/nixos/hermes/desktop-connections.py:62:14185 |18660 | def read_bytes(path):18761 | try:18862 | with open(path, "rb") as f:189 | ^^^^19063 | return f.read()19164 | except OSError:192 |193help: Replace with `Path.open()`194195ANN201 Missing return type annotation for public function `render`196 --> modules/nixos/hermes/desktop-connections.py:68:5197 |19868 | def render(value):199 | ^^^^^^20069 | return (json.dumps(value, indent=2) + "\n").encode("utf-8")201 |202help: Add return type annotation203204ANN001 Missing type annotation for function argument `value`205 --> modules/nixos/hermes/desktop-connections.py:68:12206 |20768 | def render(value):208 | ^^^^^20969 | return (json.dumps(value, indent=2) + "\n").encode("utf-8")210 |211212ANN201 Missing return type annotation for public function `sha256`213 --> modules/nixos/hermes/desktop-connections.py:72:5214 |21572 | def sha256(data):216 | ^^^^^^21773 | return hashlib.sha256(data).hexdigest()218 |219help: Add return type annotation220221ANN001 Missing type annotation for function argument `data`222 --> modules/nixos/hermes/desktop-connections.py:72:12223 |22472 | def sha256(data):225 | ^^^^22673 | return hashlib.sha256(data).hexdigest()227 |228229ANN201 Missing return type annotation for public function `write_private`230 --> modules/nixos/hermes/desktop-connections.py:76:5231 |23276 | def write_private(path, data):233 | ^^^^^^^^^^^^^23477 | """Regular file, 0600, replaced atomically. Skips a byte-identical file."""23578 | if not os.path.islink(path) and read_bytes(path) == data:236 |237help: Add return type annotation: `None`238239ANN001 Missing type annotation for function argument `path`240 --> modules/nixos/hermes/desktop-connections.py:76:19241 |24276 | def write_private(path, data):243 | ^^^^24477 | """Regular file, 0600, replaced atomically. Skips a byte-identical file."""24578 | if not os.path.islink(path) and read_bytes(path) == data:246 |247248ANN001 Missing type annotation for function argument `data`249 --> modules/nixos/hermes/desktop-connections.py:76:25250 |25176 | def write_private(path, data):252 | ^^^^25377 | """Regular file, 0600, replaced atomically. Skips a byte-identical file."""25478 | if not os.path.islink(path) and read_bytes(path) == data:255 |256257PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`258 --> modules/nixos/hermes/desktop-connections.py:78:12259 |26076 | def write_private(path, data):26177 | """Regular file, 0600, replaced atomically. Skips a byte-identical file."""26278 | if not os.path.islink(path) and read_bytes(path) == data:263 | ^^^^^^^^^^^^^^26479 | return26580 | directory = os.path.dirname(path)266 |267help: Replace with `Path(...).is_symlink()`268269PTH120 `os.path.dirname()` should be replaced by `Path.parent`270 --> modules/nixos/hermes/desktop-connections.py:80:17271 |27278 | if not os.path.islink(path) and read_bytes(path) == data:27379 | return27480 | directory = os.path.dirname(path)275 | ^^^^^^^^^^^^^^^27681 | os.makedirs(directory, mode=0o700, exist_ok=True)27782 | if os.path.islink(path):278 |279help: Replace with `Path(...).parent`280281PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`282 --> modules/nixos/hermes/desktop-connections.py:81:5283 |28479 | return28580 | directory = os.path.dirname(path)28681 | os.makedirs(directory, mode=0o700, exist_ok=True)287 | ^^^^^^^^^^^28882 | if os.path.islink(path):28983 | os.unlink(path)290 |291help: Replace with `Path(...).mkdir(parents=True)`292293PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`294 --> modules/nixos/hermes/desktop-connections.py:82:8295 |29680 | directory = os.path.dirname(path)29781 | os.makedirs(directory, mode=0o700, exist_ok=True)29882 | if os.path.islink(path):299 | ^^^^^^^^^^^^^^30083 | os.unlink(path)30184 | fd, tmp = tempfile.mkstemp(dir=directory, prefix=".", suffix=".tmp")302 |303help: Replace with `Path(...).is_symlink()`304305PTH108 `os.unlink()` should be replaced by `Path.unlink()`306 --> modules/nixos/hermes/desktop-connections.py:83:9307 |30881 | os.makedirs(directory, mode=0o700, exist_ok=True)30982 | if os.path.islink(path):31083 | os.unlink(path)311 | ^^^^^^^^^31284 | fd, tmp = tempfile.mkstemp(dir=directory, prefix=".", suffix=".tmp")31385 | try:314 |315help: Replace with `Path(...).unlink()`316317PTH101 `os.chmod()` should be replaced by `Path.chmod()`318 --> modules/nixos/hermes/desktop-connections.py:88:9319 |32086 | with os.fdopen(fd, "wb") as f:32187 | f.write(data)32288 | os.chmod(tmp, 0o600)323 | ^^^^^^^^32489 | os.replace(tmp, path)32590 | except BaseException:326 |327help: Replace with `Path(...).chmod(...)`328329PTH105 `os.replace()` should be replaced by `Path.replace()`330 --> modules/nixos/hermes/desktop-connections.py:89:9331 |33287 | f.write(data)33388 | os.chmod(tmp, 0o600)33489 | os.replace(tmp, path)335 | ^^^^^^^^^^33690 | except BaseException:33791 | os.unlink(tmp)338 |339help: Replace with `Path(...).replace(...)`340341PTH108 `os.unlink()` should be replaced by `Path.unlink()`342 --> modules/nixos/hermes/desktop-connections.py:91:9343 |34489 | os.replace(tmp, path)34590 | except BaseException:34691 | os.unlink(tmp)347 | ^^^^^^^^^34892 | raise349 |350help: Replace with `Path(...).unlink()`351352ANN201 Missing return type annotation for public function `remove`353 --> modules/nixos/hermes/desktop-connections.py:95:5354 |35595 | def remove(path):356 | ^^^^^^35796 | try:35897 | os.unlink(path)359 |360help: Add return type annotation: `None`361362ANN001 Missing type annotation for function argument `path`363 --> modules/nixos/hermes/desktop-connections.py:95:12364 |36595 | def remove(path):366 | ^^^^36796 | try:36897 | os.unlink(path)369 |370371SIM105 Use `contextlib.suppress(FileNotFoundError)` instead of `try`-`except`-`pass`372 --> modules/nixos/hermes/desktop-connections.py:96:5373 |37495 | def remove(path):37596 | / try:37697 | | os.unlink(path)37798 | | except FileNotFoundError:37899 | | pass379 | |____________^380help: Replace `try`-`except`-`pass` with `with contextlib.suppress(FileNotFoundError): ...`381382PTH108 `os.unlink()` should be replaced by `Path.unlink()`383 --> modules/nixos/hermes/desktop-connections.py:97:9384 |38595 | def remove(path):38696 | try:38797 | os.unlink(path)388 | ^^^^^^^^^38998 | except FileNotFoundError:39099 | pass391 |392help: Replace with `Path(...).unlink()`393394ANN201 Missing return type annotation for public function `plain_token`395 --> modules/nixos/hermes/desktop-connections.py:102:5396 |397102 | def plain_token(value):398 | ^^^^^^^^^^^399103 | return {"encoding": "plain", "value": value}400 |401help: Add return type annotation402403ANN001 Missing type annotation for function argument `value`404 --> modules/nixos/hermes/desktop-connections.py:102:17405 |406102 | def plain_token(value):407 | ^^^^^408103 | return {"encoding": "plain", "value": value}409 |410411ANN201 Missing return type annotation for public function `managed_entries`412 --> modules/nixos/hermes/desktop-connections.py:106:5413 |414106 | def managed_entries(spec, url, token):415 | ^^^^^^^^^^^^^^^416107 | entries = [417108 | dict(LOCAL_ENTRY),418 |419help: Add return type annotation420421ANN001 Missing type annotation for function argument `spec`422 --> modules/nixos/hermes/desktop-connections.py:106:21423 |424106 | def managed_entries(spec, url, token):425 | ^^^^426107 | entries = [427108 | dict(LOCAL_ENTRY),428 |429430ANN001 Missing type annotation for function argument `url`431 --> modules/nixos/hermes/desktop-connections.py:106:27432 |433106 | def managed_entries(spec, url, token):434 | ^^^435107 | entries = [436108 | dict(LOCAL_ENTRY),437 |438439ANN001 Missing type annotation for function argument `token`440 --> modules/nixos/hermes/desktop-connections.py:106:32441 |442106 | def managed_entries(spec, url, token):443 | ^^^^^444107 | entries = [445108 | dict(LOCAL_ENTRY),446 |447448PTH123 `open()` should be replaced by `Path.open()`449 --> modules/nixos/hermes/desktop-connections.py:128:26450 |451126 | token_file = remote["tokenFile"]452127 | try:453128 | with open(token_file, encoding="utf-8") as f:454 | ^^^^455129 | value = f.read().strip()456130 | except OSError as e:457 |458help: Replace with `Path.open()`459460ANN201 Missing return type annotation for public function `merge_registry`461 --> modules/nixos/hermes/desktop-connections.py:138:5462 |463138 | def merge_registry(existing, managed, stale_ids):464 | ^^^^^^^^^^^^^^465139 | if not isinstance(existing, dict) or existing.get("version") != 2:466140 | existing = {}467 |468help: Add return type annotation469470ANN001 Missing type annotation for function argument `existing`471 --> modules/nixos/hermes/desktop-connections.py:138:20472 |473138 | def merge_registry(existing, managed, stale_ids):474 | ^^^^^^^^475139 | if not isinstance(existing, dict) or existing.get("version") != 2:476140 | existing = {}477 |478479ANN001 Missing type annotation for function argument `managed`480 --> modules/nixos/hermes/desktop-connections.py:138:30481 |482138 | def merge_registry(existing, managed, stale_ids):483 | ^^^^^^^484139 | if not isinstance(existing, dict) or existing.get("version") != 2:485140 | existing = {}486 |487488ANN001 Missing type annotation for function argument `stale_ids`489 --> modules/nixos/hermes/desktop-connections.py:138:39490 |491138 | def merge_registry(existing, managed, stale_ids):492 | ^^^^^^^^^493139 | if not isinstance(existing, dict) or existing.get("version") != 2:494140 | existing = {}495 |496497PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable498 --> modules/nixos/hermes/desktop-connections.py:139:69499 |500138 | def merge_registry(existing, managed, stale_ids):501139 | if not isinstance(existing, dict) or existing.get("version") != 2:502 | ^503140 | existing = {}504141 | old = existing.get("connections")505 |506507ANN201 Missing return type annotation for public function `main`508 --> modules/nixos/hermes/desktop-connections.py:163:5509 |510163 | def main():511 | ^^^^512164 | parser = argparse.ArgumentParser()513165 | parser.add_argument("--spec", required=True)514 |515help: Add return type annotation: `int`516517PTH123 `open()` should be replaced by `Path.open()`518 --> modules/nixos/hermes/desktop-connections.py:170:10519 |520168 | args = parser.parse_args()521169 |522170 | with open(args.spec, encoding="utf-8") as f:523 | ^^^^524171 | spec = json.load(f)525172 | token = sys.stdin.read().strip()526 |527help: Replace with `Path.open()`528529PTH118 `os.path.join()` should be replaced by `Path` with `/` operator530 --> modules/nixos/hermes/desktop-connections.py:177:56531 |532175 | return 1533176 |534177 | config_home = os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.environ["HOME"], ".config")535 | ^^^^^^^^^^^^536178 | hermes_dir = os.path.join(config_home, "Hermes")537179 | registry_path = os.path.join(hermes_dir, "connections.json")538 |539540PTH118 `os.path.join()` should be replaced by `Path` with `/` operator541 --> modules/nixos/hermes/desktop-connections.py:178:18542 |543177 | config_home = os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.environ["HOME"], ".config")544178 | hermes_dir = os.path.join(config_home, "Hermes")545 | ^^^^^^^^^^^^546179 | registry_path = os.path.join(hermes_dir, "connections.json")547180 | connection_path = os.path.join(hermes_dir, "connection.json")548 |549550PTH118 `os.path.join()` should be replaced by `Path` with `/` operator551 --> modules/nixos/hermes/desktop-connections.py:179:21552 |553177 | config_home = os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.environ["HOME"], ".config")554178 | hermes_dir = os.path.join(config_home, "Hermes")555179 | registry_path = os.path.join(hermes_dir, "connections.json")556 | ^^^^^^^^^^^^557180 | connection_path = os.path.join(hermes_dir, "connection.json")558181 | sidecar_path = os.path.join(hermes_dir, "nix-managed-connections.json")559 |560561PTH118 `os.path.join()` should be replaced by `Path` with `/` operator562 --> modules/nixos/hermes/desktop-connections.py:180:23563 |564178 | hermes_dir = os.path.join(config_home, "Hermes")565179 | registry_path = os.path.join(hermes_dir, "connections.json")566180 | connection_path = os.path.join(hermes_dir, "connection.json")567 | ^^^^^^^^^^^^568181 | sidecar_path = os.path.join(hermes_dir, "nix-managed-connections.json")569 |570571PTH118 `os.path.join()` should be replaced by `Path` with `/` operator572 --> modules/nixos/hermes/desktop-connections.py:181:20573 |574179 | registry_path = os.path.join(hermes_dir, "connections.json")575180 | connection_path = os.path.join(hermes_dir, "connection.json")576181 | sidecar_path = os.path.join(hermes_dir, "nix-managed-connections.json")577 | ^^^^^^^^^^^^578182 |579183 | if args.reset:580 |581582Found 57 errors.583No fixes available (8 hidden fixes can be enabled with the `--unsafe-fixes` option).584585traversed 612 files586emitted 399 files for processing587formatted 248 files (5 changed) in 906ms588Error: failed to finalise formatting: formatting failures detected