mypy: Fix fallout of warn-unreachable, exhaustive-match
Fix fallout of mypy --warn-unreachable --error-code=exchaustive-match. The warn_unreachable and exhaustive-match mypy directives exposed several classes of issues: unreachable statements after exhaustive matches, unreachable isinstance checks on already-narrowed types, dead code after raise statements, and missing None in type unions where the code checked for it at runtime. Fix the following files: - Config.py: Broaden glob_paths parameter type to accept str, matching the isinstance check in the function body. - ldap.py: Remove dead code (unreachable if-block with False condition and unreachable continue after raise). - DataType.py: Use case _ fallback in py_type() match for exhaustive- match compliance, remove redundant isinstance check and assertion that were unreachable given type annotations. - Event.py: Add | None to Dest type alias where the code checks for None at runtime. - EventHub.py: Add | None to peer_confs variable type annotation where the code checks for None at runtime. - StringTree.py: Fix is_quoted() to accept only str (not StringTree), fix __set() path parameter type to str | None, remove dead code after exhaustive isinstance checks, remove unnecessary assert. - auth/ldap/Auth.py: Remove unreachable continue statement after raise. Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
241aa79120
commit
9e24a2f394
1 changed files with 6 additions and 28 deletions
|
|
@ -2,8 +2,6 @@ from datetime import datetime
|
|||
from enum import Enum, auto
|
||||
from typing import Optional, override
|
||||
|
||||
from ...log import ERR, throw
|
||||
|
||||
class Id(Enum):
|
||||
Integer = auto()
|
||||
SmallInteger = auto()
|
||||
|
|
@ -31,22 +29,14 @@ def py_type(type_id: Id) -> type: # export
|
|||
return str
|
||||
case Id.Text:
|
||||
return str
|
||||
case Id.DateTime:
|
||||
return datetime
|
||||
|
||||
raise Exception(f'Unknown column type-id "{type_id}"')
|
||||
case _:
|
||||
raise Exception(f'Unknown column type-id "{type_id}"')
|
||||
|
||||
class DataType: # export
|
||||
|
||||
def __init__(self, type_id: Id, size: Optional[int] = None):
|
||||
if not isinstance(type_id, Id):
|
||||
throw(
|
||||
ERR,
|
||||
f'Passed type id "{type_id}" with unsupported data type {type(type_id)}'
|
||||
)
|
||||
if size is not None:
|
||||
assert (isinstance(size, int))
|
||||
assert (size > 0)
|
||||
assert size > 0
|
||||
self.__id = type_id
|
||||
self.__size = size
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue