diff --git a/src/python/jw/util/Config.py b/src/python/jw/util/Config.py index afccf95..7ac3ab4 100644 --- a/src/python/jw/util/Config.py +++ b/src/python/jw/util/Config.py @@ -22,7 +22,7 @@ class Config(Mapping): # export def __load( self, search_dirs: list[str] | None, - glob_paths: list[str] | None, + glob_paths: list[str] | str | None, refuse_mode_mask: int | None ) -> StringTree: diff --git a/src/python/jw/util/auth/ldap/Auth.py b/src/python/jw/util/auth/ldap/Auth.py index b12032d..ad6da9f 100644 --- a/src/python/jw/util/auth/ldap/Auth.py +++ b/src/python/jw/util/auth/ldap/Auth.py @@ -123,7 +123,6 @@ class Auth(AuthBase): # export except Exception as e: slog(WARNING, f'Exception {e}') raise - continue for dummy_user in self.__dummy.users.values(): ret[dummy_user.name] = dummy_user self.___users = ret diff --git a/src/python/jw/util/db/schema/DataType.py b/src/python/jw/util/db/schema/DataType.py index 15f8bea..b679dcb 100644 --- a/src/python/jw/util/db/schema/DataType.py +++ b/src/python/jw/util/db/schema/DataType.py @@ -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 diff --git a/src/python/jw/util/ldap.py b/src/python/jw/util/ldap.py index 8838b9a..6ff94e7 100644 --- a/src/python/jw/util/ldap.py +++ b/src/python/jw/util/ldap.py @@ -211,8 +211,6 @@ class Connection: # export key: [val.decode() for val in vals] for key, vals in entry[1].items() } - if unroll and False: - entry = entry[0], {key: val[0] for key, val in entry[1].items()} try: callback(self, entry, context) except Exception as e: diff --git a/src/python/jw/util/stree/StringTree.py b/src/python/jw/util/stree/StringTree.py index 2f05a45..42a217c 100644 --- a/src/python/jw/util/stree/StringTree.py +++ b/src/python/jw/util/stree/StringTree.py @@ -19,8 +19,6 @@ if TYPE_CHECKING: from ..log import DEBUG, INFO, get_caller_pos, slog def is_quoted(s: str) -> bool: - if isinstance(s, StringTree): - return False s = s.strip() if len(s) < 2: return False @@ -85,7 +83,7 @@ class StringTree(MutableMapping): # export def __set( self, - path: str, + path: str | None, content: str | StringTree | None, split: bool = True ) -> StringTree: @@ -99,7 +97,7 @@ class StringTree(MutableMapping): # export # works fine without. #assert self.content != str(content) - if content is not None and type(content) not in [str, StringTree]: + if content is not None and not isinstance(content, (str, StringTree)): raise self.Error( "Tried to add content of unsupported type {}".format( type(content).__name__ @@ -110,12 +108,6 @@ class StringTree(MutableMapping): # export self.content = cleanup_string(content) elif isinstance(content, StringTree): self.__adopt_children(content) - else: - raise self.Error( - "Tried to add content of unsupported type {}".format( - type(content).__name__ - ) - ) slog( DEBUG, " -- content = >" + str(content) + "<, self.content = >" + @@ -346,7 +338,6 @@ class StringTree(MutableMapping): # export @override def get(self, path: str, default: Any = None) -> StringTree | None: slog(DEBUG, 'looking for "{}" in "{}"'.format(path, self.content)) - assert not isinstance(path, int) _path: str = cleanup_string(path) if len(_path) == 0: slog(DEBUG, "returning myself")