diff --git a/my/coding/commits.py b/my/coding/commits.py index 9661ae5..31c366e 100644 --- a/my/coding/commits.py +++ b/my/coding/commits.py @@ -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) diff --git a/my/core/_deprecated/kompress.py b/my/core/_deprecated/kompress.py index 1cd2636..63ce523 100644 --- a/my/core/_deprecated/kompress.py +++ b/my/core/_deprecated/kompress.py @@ -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: diff --git a/my/core/common.py b/my/core/common.py index 5f8d03a..a2c2ad3 100644 --- a/my/core/common.py +++ b/my/core/common.py @@ -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 diff --git a/my/core/hpi_compat.py b/my/core/hpi_compat.py index 9330e49..6261c23 100644 --- a/my/core/hpi_compat.py +++ b/my/core/hpi_compat.py @@ -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: diff --git a/my/photos/main.py b/my/photos/main.py index c326405..bf912e4 100644 --- a/my/photos/main.py +++ b/my/photos/main.py @@ -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 = {} diff --git a/ruff.toml b/ruff.toml index 9a932ef..0d3bb16 100644 --- a/ruff.toml +++ b/ruff.toml @@ -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 + ## ]