Skip to content

cleanup: import NoReturn properly + remove unused argparse + fix f-string placeholder#3

Open
fadai216 wants to merge 1 commit into
GhostClaw-dev:mainfrom
fadai216:cleanup-typing-and-imports
Open

cleanup: import NoReturn properly + remove unused argparse + fix f-string placeholder#3
fadai216 wants to merge 1 commit into
GhostClaw-dev:mainfrom
fadai216:cleanup-typing-and-imports

Conversation

@fadai216

Copy link
Copy Markdown

Three small lints flagged by pyflakes scripts/:

1. kya_lib.py: import NoReturn properly

die() was annotated as -> "NoReturn" (string forward-reference) with a # type: ignore[name-defined] to paper over the missing import. The clean fix is to just add NoReturn to the existing typing import:

-from typing import Any, Optional
+from typing import Any, NoReturn, Optional

-def die(msg: str, code: int = 1) -> "NoReturn":  # type: ignore[name-defined]
+def die(msg: str, code: int = 1) -> NoReturn:

Now mypy / pyright / pyflakes all resolve the name correctly instead of silently trusting the type: ignore.

2. sign-kyc.py:115: f-string without placeholders (F541)

-    print(f"Open this URL in any browser to complete Didit:", flush=True)
+    print("Open this URL in any browser to complete Didit:", flush=True)

Semantically identical, avoids the f"" tripwire that makes future readers look for interpolation that isn't there.

3. sign.py:24: unused import argparse

Script uses base_parser from kya_lib (a pre-configured ArgumentParser), never touches argparse directly. Removed.

Verification

  • All 3 files pass python3 -m py_compile
  • scripts/test_kya_lib.py still passes 22/22 tests
  • pyflakes scripts/ output clean for the 3 flagged items

… placeholder

Three small lints flagged by pyflakes:

- scripts/kya_lib.py: 'NoReturn' was written as a string forward-reference with a type:ignore, hiding the real fix: just import it from typing. Now the return type is a proper annotation instead of a stringly-typed hack.
- scripts/sign-kyc.py:115: f-string had no placeholders - dropped the 'f' prefix.
- scripts/sign.py:24: argparse was imported but unused (script uses base_parser from kya_lib); removed.

All three files pass python3 -m py_compile. scripts/test_kya_lib.py still passes 22/22 tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants