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 <jan@janware.com>
This commit is contained in:
parent
a3e46121da
commit
55b63ded69
4 changed files with 16 additions and 5 deletions
|
|
@ -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 = []
|
||||
|
|
|
|||
|
|
@ -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 + '"'
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue