diff --git a/my/core/_deprecated/kompress.py b/my/core/_deprecated/kompress.py index cd09c06..1cd2636 100644 --- a/my/core/_deprecated/kompress.py +++ b/my/core/_deprecated/kompress.py @@ -141,9 +141,10 @@ open = kopen # TODO deprecate def kexists(path: PathIsh, subpath: str) -> bool: try: kopen(path, subpath) - return True except Exception: return False + else: + return True import zipfile diff --git a/my/core/time.py b/my/core/time.py index 5a47c3d..6de4105 100644 --- a/my/core/time.py +++ b/my/core/time.py @@ -11,10 +11,11 @@ def user_forced() -> Sequence[str]: # https://stackoverflow.com/questions/36067621/python-all-possible-timezone-abbreviations-for-given-timezone-name-and-vise-ve try: from my.config import time as user_config - return user_config.tz.force_abbreviations # type: ignore[attr-defined] except: # todo log/apply policy return [] + else: + return user_config.tz.force_abbreviations # type: ignore[attr-defined] @lru_cache(1) diff --git a/ruff.toml b/ruff.toml index c2c88ef..9a932ef 100644 --- a/ruff.toml +++ b/ruff.toml @@ -20,6 +20,7 @@ lint.extend-select = [ "PT", # pytest stuff "RET", # early returns "RUF", # various ruff-specific rules + "TRY", # various exception handling rules "UP", # detect deprecated python stdlib stuff # "FA", # TODO enable later after we make sure cachew works? # "PTH", # pathlib migration -- TODO enable later @@ -108,4 +109,10 @@ lint.ignore = [ "COM812", # trailing comma missing -- TODO maybe use this? "PD901", # generic variable name df + + "TRY003", # suggests defining exception messages in exception class -- kinda annoying + "TRY004", # prefer TypeError -- don't see the point + "TRY201", # raise without specifying exception name -- sometimes hurts readability + "TRY400", # TODO double check this, might be useful + "TRY401", # redundant exception in logging.exception call? TODO double check, might result in excessive logging ]