From 55b63ded69f42874c4ec943d6cd2cddea4499490 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 22 Jul 2026 22:35:22 +0200 Subject: [PATCH] lib, cmds: Add exhaustive match cases Add 'case _: pass' to match statements that are intentionally non-exhaustive, satisfying the new exhaustive-match mypy rule. Also replaced 'case '_':' (a string literal) with 'case _: pass' in pkg_relations.py since it was an unreachable case (syntax is a VersionSyntax enum, not a str). Added 'case VersionSyntax.names_only:' to the match in pkg_relations.py to handle the missing enum value. Files modified: - util.py: Two match statements for askpass env vars - Distro.py: Three match statements for backend/os detection - pkg_relations.py: Match on VersionSyntax enum - CmdListRepos.py: Match on URL scheme Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev 0.81.1 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/cmds/projects/CmdListRepos.py | 2 ++ src/python/jw/pkg/cmds/projects/lib/pkg_relations.py | 11 ++++++----- src/python/jw/pkg/lib/Distro.py | 6 ++++++ src/python/jw/pkg/lib/util.py | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/python/jw/pkg/cmds/projects/CmdListRepos.py b/src/python/jw/pkg/cmds/projects/CmdListRepos.py index afcce40d..6324a81c 100644 --- a/src/python/jw/pkg/cmds/projects/CmdListRepos.py +++ b/src/python/jw/pkg/cmds/projects/CmdListRepos.py @@ -143,6 +143,8 @@ class CmdListRepos(Cmd): # export f'instance at {args.base_url}, tried {", ".join(tried)}' ) return + case _: + pass if os.path.isdir(args.base_url): for subdir in ['.', args.from_owner]: out = [] diff --git a/src/python/jw/pkg/cmds/projects/lib/pkg_relations.py b/src/python/jw/pkg/cmds/projects/lib/pkg_relations.py index 9bdcbecc..954a77ec 100644 --- a/src/python/jw/pkg/cmds/projects/lib/pkg_relations.py +++ b/src/python/jw/pkg/cmds/projects/lib/pkg_relations.py @@ -150,6 +150,8 @@ def pkg_relations( match syntax: case VersionSyntax.semver: pass + case VersionSyntax.names_only: + pass case VersionSyntax.debian: if len(expanded_dep) == 3: match expanded_dep[1]: @@ -157,11 +159,10 @@ def pkg_relations( expanded_dep[1] = '<<' case '>': expanded_dep[1] = '>>' - case '_': - raise NotImplementedError( - f'Unknown dependency syntax "{syntax}" for ' - f'dependency "{dep[0]} {dep[1]} {dep[3]}"' - ) + case _: + pass + case _: + pass dep_str = ' '.join(expanded_dep) if quote: dep_str = '"' + dep_str + '"' diff --git a/src/python/jw/pkg/lib/Distro.py b/src/python/jw/pkg/lib/Distro.py index 467636b4..0a40dbd4 100644 --- a/src/python/jw/pkg/lib/Distro.py +++ b/src/python/jw/pkg/lib/Distro.py @@ -98,6 +98,8 @@ class Distro(abc.ABC): match ret: case 'opensuse-tumbleweed': return 'suse' + case _: + pass return ret @classmethod @@ -119,6 +121,8 @@ class Distro(abc.ABC): backend_id = 'redhat' case 'opensuse' | 'suse': backend_id = 'suse' + case _: + pass module_path = 'jw.pkg.lib.distros.' + backend_id + '.Distro' try: module = importlib.import_module(module_path) @@ -173,6 +177,8 @@ class Distro(abc.ABC): __append('linux') __append('pkg-pm') __append('pm-pacman') + case _: + pass os = self.os name = re.sub(r'-.*', '', os) diff --git a/src/python/jw/pkg/lib/util.py b/src/python/jw/pkg/lib/util.py index c3f581b9..db0eb5e1 100644 --- a/src/python/jw/pkg/lib/util.py +++ b/src/python/jw/pkg/lib/util.py @@ -122,6 +122,8 @@ async def run_askpass( continue # Can't get user name from SSH_ASKPASS case AskpassKey.Password: exe_arg += 'Password' + case _: + pass result = await run_cmd([exe, exe_arg], throw = throw, ec = ec) if result.status == 0 and result.stdout_or_none is not None: ret = result.stdout_str_or_none