ruff: process remaining existing checks and suppress the annoying ones

This commit is contained in:
Dima Gerasimov 2024-08-28 03:58:28 +01:00
parent c248aa7496
commit 1774ed126b
6 changed files with 38 additions and 8 deletions

View file

@ -178,12 +178,12 @@ def repos() -> List[Path]:
# returns modification time for an index to use as hash function
def _repo_depends_on(_repo: Path) -> int:
for pp in {
for pp in [
".git/FETCH_HEAD",
".git/HEAD",
"FETCH_HEAD", # bare
"HEAD", # bare
}:
]:
ff = _repo / pp
if ff.exists():
return int(ff.stat().st_mtime)

View file

@ -27,7 +27,7 @@ class Ext:
def is_compressed(p: Path) -> bool:
# todo kinda lame way for now.. use mime ideally?
# should cooperate with kompress.kopen?
return any(p.name.endswith(ext) for ext in {Ext.xz, Ext.zip, Ext.lz4, Ext.zstd, Ext.zst, Ext.targz})
return any(p.name.endswith(ext) for ext in [Ext.xz, Ext.zip, Ext.lz4, Ext.zstd, Ext.zst, Ext.targz])
def _zstd_open(path: Path, *args, **kwargs) -> IO:

View file

@ -14,7 +14,7 @@ from typing import (
)
from . import compat
from . import warnings as warnings
from . import warnings
# some helper functions
# TODO start deprecating this? soon we'd be able to use Path | str syntax which is shorter and more explicit

View file

@ -123,7 +123,7 @@ class always_supports_sequence(Iterator[V]):
self.it = it
self._list: Optional[List] = None
def __iter__(self) -> Iterator[V]:
def __iter__(self) -> Iterator[V]: # noqa: PYI034
return self.it.__iter__()
def __next__(self) -> V:

View file

@ -65,7 +65,7 @@ def _make_photo_aux(*args, **kwargs) -> List[Result]:
def _make_photo(photo: Path, mtype: str, *, parent_geo: Optional[LatLon]) -> Iterator[Result]:
exif: Exif
if any(x in mtype for x in {'image/png', 'image/x-ms-bmp', 'video'}):
if any(x in mtype for x in ['image/png', 'image/x-ms-bmp', 'video']):
# TODO don't remember why..
logger.debug(f"skipping exif extraction for {photo} due to mime {mtype}")
exif = {}

View file

@ -15,11 +15,15 @@ lint.extend-select = [
"PERF", # various potential performance speedups
"PD", # pandas rules
"PIE", # 'misc' lints
"PLR", # 'refactor' rules
"PLC", # pylint convention rules
"PLR", # pylint refactor rules
"PLW", # pylint warnings
"PT", # pytest stuff
"PYI", # various type hinting rules
"RET", # early returns
"RUF", # various ruff-specific rules
"TID", # various imports suggestions
"TCH", # various type checking rules
"TRY", # various exception handling rules
"UP", # detect deprecated python stdlib stuff
# "FA", # TODO enable later after we make sure cachew works?
@ -31,10 +35,15 @@ lint.extend-select = [
# "EM", # TODO hmm could be helpful to prevent duplicate err msg in traceback.. but kinda annoying
# "FIX", # complains about fixmes/todos -- annoying
# "TD", # complains about todo formatting -- too annoying
# "ALL",
# "ANN", # missing type annotations? seems way to string though
# "ALL", # uncomment this to check for new rules!
]
lint.ignore = [
"D", # annoying nags about docstrings
"N", # pep naming
### too opinionated style checks
"E501", # too long lines
"E702", # Multiple statements on one line (semicolon)
@ -115,4 +124,25 @@ lint.ignore = [
"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
"TCH002", # suggests moving imports into type checking blocks -- too annoying
"TCH003", # suggests moving imports into type checking blocks -- too annoying
"I001", # unsorted import block TODO consider these?
"PGH", # TODO force error code in mypy instead
# TODO enable TID?
"TID252", # Prefer absolute imports over relative imports from parent modules
## too annoying
"T20", # just complains about prints and pprints
"Q", # flake quotes, too annoying
"C90", # some complexity checking
"G004", # logging statement uses f string
"ERA001", # commented out code
"SLF001", # private member accessed
"BLE001", # do not catch 'blind' Exception
"INP001", # complains about implicit namespace packages
"SIM", # some if statements crap
##
]