ruff: enable TRY rules
This commit is contained in:
parent
affa79ba3a
commit
1c5efc46aa
3 changed files with 11 additions and 2 deletions
|
@ -141,9 +141,10 @@ open = kopen # TODO deprecate
|
||||||
def kexists(path: PathIsh, subpath: str) -> bool:
|
def kexists(path: PathIsh, subpath: str) -> bool:
|
||||||
try:
|
try:
|
||||||
kopen(path, subpath)
|
kopen(path, subpath)
|
||||||
return True
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
|
@ -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
|
# https://stackoverflow.com/questions/36067621/python-all-possible-timezone-abbreviations-for-given-timezone-name-and-vise-ve
|
||||||
try:
|
try:
|
||||||
from my.config import time as user_config
|
from my.config import time as user_config
|
||||||
return user_config.tz.force_abbreviations # type: ignore[attr-defined]
|
|
||||||
except:
|
except:
|
||||||
# todo log/apply policy
|
# todo log/apply policy
|
||||||
return []
|
return []
|
||||||
|
else:
|
||||||
|
return user_config.tz.force_abbreviations # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(1)
|
@lru_cache(1)
|
||||||
|
|
|
@ -20,6 +20,7 @@ lint.extend-select = [
|
||||||
"PT", # pytest stuff
|
"PT", # pytest stuff
|
||||||
"RET", # early returns
|
"RET", # early returns
|
||||||
"RUF", # various ruff-specific rules
|
"RUF", # various ruff-specific rules
|
||||||
|
"TRY", # various exception handling rules
|
||||||
"UP", # detect deprecated python stdlib stuff
|
"UP", # detect deprecated python stdlib stuff
|
||||||
# "FA", # TODO enable later after we make sure cachew works?
|
# "FA", # TODO enable later after we make sure cachew works?
|
||||||
# "PTH", # pathlib migration -- TODO enable later
|
# "PTH", # pathlib migration -- TODO enable later
|
||||||
|
@ -108,4 +109,10 @@ lint.ignore = [
|
||||||
"COM812", # trailing comma missing -- TODO maybe use this?
|
"COM812", # trailing comma missing -- TODO maybe use this?
|
||||||
|
|
||||||
"PD901", # generic variable name df
|
"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
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue