From fec03045430f3b35f5ee0e34259e6de932618816 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 22 Jul 2026 22:22:05 +0200 Subject: [PATCH] App, AsyncSSH: Allow unused "type: ignore" comments Some '# type: ignore' comments are needed because they complain about missing but optional third-party packages: argcomplete, paramiko, asyncssh. The next commit will enable warn_unused_ignores, and since nor mypy nor pyright have a way of knowing that this is a tolerable lack of packages, this commit teaches them in advance. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/App.py | 10 ++++++---- src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py | 2 +- src/python/jw/pkg/lib/ec/ssh/Paramiko.py | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index 62f5467f..881f6b69 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -150,7 +150,7 @@ class App: # export cmd_classes: LoadTypes[AbstractCmd] = LoadTypes( modules if modules else ['__main__'], type_name_filter = name_filter, - type_filter = [AbstractCmd], # type: ignore[type-abstract] + type_filter = [AbstractCmd], ) add_all_parsers = ( '-h' in sys.argv or '--help' in sys.argv or '_ARGCOMPLETE' in os.environ @@ -186,17 +186,19 @@ class App: # export try: # Import argcomplete only here to not require it to be compatible # with minimal environments - from argcomplete.completers import ( # type: ignore[import-not-found] + from argcomplete.completers import ( # type: ignore[import-not-found, unused-ignore] BaseCompleter ) class NoopCompleter(BaseCompleter): @override - def __call__(self, *args, **kwargs): + def __call__( # pyright: ignore[reportGeneralTypeIssues] + self, *args, **kwargs + ): return None - import argcomplete # type: ignore[import-not-found] + import argcomplete # type: ignore[import-not-found, unused-ignore] argcomplete.autocomplete(self.__parser, default_completer = NoopCompleter()) diff --git a/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py b/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py index 127e2ef6..eacc31a3 100644 --- a/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py +++ b/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py @@ -6,7 +6,7 @@ import shutil import signal import sys -import asyncssh # type: ignore[import-not-found] +import asyncssh # type: ignore[import-not-found, unused-ignore] from ...base import Result from ...log import DEBUG, ERR, NOTICE, log diff --git a/src/python/jw/pkg/lib/ec/ssh/Paramiko.py b/src/python/jw/pkg/lib/ec/ssh/Paramiko.py index 936a9deb..866c3f67 100644 --- a/src/python/jw/pkg/lib/ec/ssh/Paramiko.py +++ b/src/python/jw/pkg/lib/ec/ssh/Paramiko.py @@ -4,9 +4,9 @@ from typing import override, TYPE_CHECKING # Tolerate missing paramiko imports. jw-pkg is designed to work with what it # finds. -import paramiko # type: ignore[import-untyped,import-not-found] # error: Library stubs not installed for "paramiko" -import paramiko.agent # type: ignore[import-untyped,import-not-found] -import paramiko.SCPClient # type: ignore[import-untyped,import-not-found] +import paramiko # type: ignore[import-untyped,import-not-found, unused-ignore] # error: Library stubs not installed for "paramiko" +import paramiko.agent # type: ignore[import-untyped,import-not-found, unused-ignore] +import paramiko.SCPClient # type: ignore[import-untyped,import-not-found, unused-ignore] from ...base import Result from ...log import ERR, log