ruff: process remaining existing checks and suppress the annoying ones
This commit is contained in:
parent
1c5efc46aa
commit
d58453410c
6 changed files with 38 additions and 8 deletions
|
@ -178,12 +178,12 @@ def repos() -> List[Path]:
|
||||||
|
|
||||||
# returns modification time for an index to use as hash function
|
# returns modification time for an index to use as hash function
|
||||||
def _repo_depends_on(_repo: Path) -> int:
|
def _repo_depends_on(_repo: Path) -> int:
|
||||||
for pp in {
|
for pp in [
|
||||||
".git/FETCH_HEAD",
|
".git/FETCH_HEAD",
|
||||||
".git/HEAD",
|
".git/HEAD",
|
||||||
"FETCH_HEAD", # bare
|
"FETCH_HEAD", # bare
|
||||||
"HEAD", # bare
|
"HEAD", # bare
|
||||||
}:
|
]:
|
||||||
ff = _repo / pp
|
ff = _repo / pp
|
||||||
if ff.exists():
|
if ff.exists():
|
||||||
return int(ff.stat().st_mtime)
|
return int(ff.stat().st_mtime)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Ext:
|
||||||
def is_compressed(p: Path) -> bool:
|
def is_compressed(p: Path) -> bool:
|
||||||
# todo kinda lame way for now.. use mime ideally?
|
# todo kinda lame way for now.. use mime ideally?
|
||||||
# should cooperate with kompress.kopen?
|
# 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:
|
def _zstd_open(path: Path, *args, **kwargs) -> IO:
|
||||||
|
|
|
@ -14,7 +14,7 @@ from typing import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import compat
|
from . import compat
|
||||||
from . import warnings as warnings
|
from . import warnings
|
||||||
|
|
||||||
# some helper functions
|
# some helper functions
|
||||||
# TODO start deprecating this? soon we'd be able to use Path | str syntax which is shorter and more explicit
|
# TODO start deprecating this? soon we'd be able to use Path | str syntax which is shorter and more explicit
|
||||||
|
|
|
@ -123,7 +123,7 @@ class always_supports_sequence(Iterator[V]):
|
||||||
self.it = it
|
self.it = it
|
||||||
self._list: Optional[List] = None
|
self._list: Optional[List] = None
|
||||||
|
|
||||||
def __iter__(self) -> Iterator[V]:
|
def __iter__(self) -> Iterator[V]: # noqa: PYI034
|
||||||
return self.it.__iter__()
|
return self.it.__iter__()
|
||||||
|
|
||||||
def __next__(self) -> V:
|
def __next__(self) -> V:
|
||||||
|
|
|
@ -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]:
|
def _make_photo(photo: Path, mtype: str, *, parent_geo: Optional[LatLon]) -> Iterator[Result]:
|
||||||
exif: Exif
|
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..
|
# TODO don't remember why..
|
||||||
logger.debug(f"skipping exif extraction for {photo} due to mime {mtype}")
|
logger.debug(f"skipping exif extraction for {photo} due to mime {mtype}")
|
||||||
exif = {}
|
exif = {}
|
||||||
|
|
34
ruff.toml
34
ruff.toml
|
@ -15,11 +15,15 @@ lint.extend-select = [
|
||||||
"PERF", # various potential performance speedups
|
"PERF", # various potential performance speedups
|
||||||
"PD", # pandas rules
|
"PD", # pandas rules
|
||||||
"PIE", # 'misc' lints
|
"PIE", # 'misc' lints
|
||||||
"PLR", # 'refactor' rules
|
"PLC", # pylint convention rules
|
||||||
|
"PLR", # pylint refactor rules
|
||||||
"PLW", # pylint warnings
|
"PLW", # pylint warnings
|
||||||
"PT", # pytest stuff
|
"PT", # pytest stuff
|
||||||
|
"PYI", # various type hinting rules
|
||||||
"RET", # early returns
|
"RET", # early returns
|
||||||
"RUF", # various ruff-specific rules
|
"RUF", # various ruff-specific rules
|
||||||
|
"TID", # various imports suggestions
|
||||||
|
"TCH", # various type checking rules
|
||||||
"TRY", # various exception handling 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?
|
||||||
|
@ -31,10 +35,15 @@ lint.extend-select = [
|
||||||
# "EM", # TODO hmm could be helpful to prevent duplicate err msg in traceback.. but kinda annoying
|
# "EM", # TODO hmm could be helpful to prevent duplicate err msg in traceback.. but kinda annoying
|
||||||
# "FIX", # complains about fixmes/todos -- annoying
|
# "FIX", # complains about fixmes/todos -- annoying
|
||||||
# "TD", # complains about todo formatting -- too 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 = [
|
lint.ignore = [
|
||||||
|
"D", # annoying nags about docstrings
|
||||||
|
"N", # pep naming
|
||||||
|
|
||||||
### too opinionated style checks
|
### too opinionated style checks
|
||||||
"E501", # too long lines
|
"E501", # too long lines
|
||||||
"E702", # Multiple statements on one line (semicolon)
|
"E702", # Multiple statements on one line (semicolon)
|
||||||
|
@ -115,4 +124,25 @@ lint.ignore = [
|
||||||
"TRY201", # raise without specifying exception name -- sometimes hurts readability
|
"TRY201", # raise without specifying exception name -- sometimes hurts readability
|
||||||
"TRY400", # TODO double check this, might be useful
|
"TRY400", # TODO double check this, might be useful
|
||||||
"TRY401", # redundant exception in logging.exception call? TODO double check, might result in excessive logging
|
"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
|
||||||
|
##
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue