From 3d107c95d739e3e36ca2f3413a769e35a6b8141a Mon Sep 17 00:00:00 2001 From: Mladen Milankovic Date: Fri, 25 Sep 2026 12:29:47 +0200 Subject: [PATCH] Remove dead code in the transport layer list_reader_names() had no caller in src, tests, docs or packaging; reader_states() returns the same names along with card presence and ATR. It was reachable as a public import, so it gets a CHANGELOG Removed entry. describe_sw's family fallback tested `sw1 in (0x62, 0x63)`, but the preceding branch already returns for 0x63, so the tuple advertised an arm that could never be taken. No behaviour change. Co-Authored-By: Claude Opus 5 (1M context) --- CHANGELOG.md | 5 +++++ src/cryptnox_id_cli/transport/errors.py | 2 +- src/cryptnox_id_cli/transport/pcsc.py | 11 ----------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d35f653..d660077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `perso generate-key --create-key-object` - the same dev/eval fallback `import-key` already had. +### Removed + +- `transport.pcsc.list_reader_names()`. Nothing called it; `reader_states()` + returns the same names along with card presence and ATR. + ## [1.0.3] - 2026-08-31 ### Changed diff --git a/src/cryptnox_id_cli/transport/errors.py b/src/cryptnox_id_cli/transport/errors.py index f1f8228..de55952 100644 --- a/src/cryptnox_id_cli/transport/errors.py +++ b/src/cryptnox_id_cli/transport/errors.py @@ -156,7 +156,7 @@ def describe_sw(sw1: int, sw2: int) -> SWInfo: # Family fallbacks. if sw1 == 0x63: return SWInfo(sw, "WARNING", "Operation completed with warning / counter changed.") - if sw1 in (0x62, 0x63): + if sw1 == 0x62: return SWInfo(sw, "WARNING", f"Warning (SW={sw:04X}).") if sw1 in (0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F): return SWInfo(sw, "ERROR", f"Card returned error SW={sw:04X}.") diff --git a/src/cryptnox_id_cli/transport/pcsc.py b/src/cryptnox_id_cli/transport/pcsc.py index 54f2c34..080bc41 100644 --- a/src/cryptnox_id_cli/transport/pcsc.py +++ b/src/cryptnox_id_cli/transport/pcsc.py @@ -95,17 +95,6 @@ def reader_states() -> list[ReaderInfo]: SCardReleaseContext(hcontext) -def list_reader_names() -> list[str]: - try: - from smartcard.System import readers as _readers - except ImportError as exc: # pragma: no cover - raise TransportError(f"pyscard unavailable: {exc}") from exc - try: - return [str(r) for r in _readers()] - except Exception as exc: # pragma: no cover - defensive - raise TransportError(f"Cannot list readers: {exc}") from exc - - def _listing(infos: list[ReaderInfo]) -> str: return ", ".join(f"[{r.index}] {r.name}" for r in infos)