ci: update mypy config and make ruff config more consistent with other projects

This commit is contained in:
Dima Gerasimov 2024-08-31 02:03:22 +01:00 committed by karlicoss
parent d58453410c
commit 71fdeca5e1
13 changed files with 32 additions and 38 deletions

View file

@ -6,7 +6,7 @@ warnings.high('my.coding.github is deprecated! Please use my.github.all instead!
# todo why aren't DeprecationWarning shown by default??
if not TYPE_CHECKING:
from ..github.all import events, get_events
from ..github.all import events, get_events # noqa: F401
# todo deprecate properly
iter_events = events

View file

@ -10,7 +10,7 @@ This file is used for:
- for loading the actual user config
'''
#### NOTE: you won't need this line VVVV in your personal config
from my.core import init
from my.core import init # noqa: F401
###

View file

@ -577,7 +577,7 @@ def query_hpi_functions(
# output == 'repl'
eprint(f"\nInteract with the results by using the {click.style('res', fg='green')} variable\n")
try:
import IPython # type: ignore[import]
import IPython # type: ignore[import,unused-ignore]
except ModuleNotFoundError:
eprint("'repl' typically uses ipython, install it with 'python3 -m pip install ipython'. falling back to stdlib...")
import code

View file

@ -120,7 +120,7 @@ class CPath(BasePath):
Path only has _accessor and _closed slots, so can't directly set .open method
_accessor.open has to return file descriptor, doesn't work for compressed stuff.
"""
def open(self, *args, **kwargs):
def open(self, *args, **kwargs): # noqa: ARG002
kopen_kwargs = {}
mode = kwargs.get('mode')
if mode is not None:

View file

@ -8,7 +8,6 @@ from pathlib import Path
import pytest
import pytz
from more_itertools import ilen
import my.config
from my.core import notnone

View file

@ -47,5 +47,5 @@ class DummyExecutor(Executor):
return f
def shutdown(self, wait: bool = True, **kwargs) -> None: # noqa: FBT001,FBT002
def shutdown(self, wait: bool = True, **kwargs) -> None: # noqa: FBT001,FBT002,ARG002
self._shutdown = True

View file

@ -3,7 +3,6 @@ Just a demo module for testing and documentation purposes
'''
import json
from abc import abstractmethod
from dataclasses import dataclass
from datetime import datetime, timezone, tzinfo
from pathlib import Path

View file

@ -31,7 +31,7 @@ def inputs() -> Sequence[Path]:
# todo add a doctor check for pip endoexport module
import endoexport.dal as dal
from endoexport.dal import Point, Workout
from endoexport.dal import Point, Workout # noqa: F401
from .core import Res

View file

@ -4,7 +4,6 @@ Foursquare/Swarm checkins
from datetime import datetime, timezone, timedelta
from itertools import chain
from pathlib import Path
import json
# TODO pytz for timezone???

View file

@ -1,6 +1,6 @@
from typing import Protocol
from my.core import datetime_aware, Json
from my.core import datetime_aware
def hackernews_link(id: str) -> str:

View file

@ -3,7 +3,6 @@
from pathlib import Path
# from kython.plotting import *
from csv import DictReader
from itertools import islice
from typing import Dict, Any, NamedTuple

View file

@ -1,18 +1,13 @@
[mypy]
namespace_packages = True
pretty = True
show_error_context = True
show_error_codes = True
show_column_numbers = True
show_error_end = True
warn_redundant_casts = True
warn_unused_ignores = True
check_untyped_defs = True
enable_error_code = possibly-undefined
strict_equality = True
# a bit annoying, it has optional ipython import which should be ignored in mypy-core configuration..
[mypy-my.core.__main__]
warn_unused_ignores = False
enable_error_code = possibly-undefined
# todo ok, maybe it wasn't such a good idea..
# mainly because then tox picks it up and running against the user config, not the repository config

View file

@ -9,6 +9,7 @@ lint.extend-select = [
"C4", # flake8-comprehensions -- unnecessary list/map/dict calls
"COM", # trailing commas
"EXE", # various checks wrt executable files
# "I", # sort imports
"ICN", # various import conventions
"FBT", # detect use of boolean arguments
"FURB", # various rules
@ -23,26 +24,26 @@ lint.extend-select = [
"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?
# "FA", # suggest using from __future__ import annotations TODO enable later after we make sure cachew works?
# "PTH", # pathlib migration -- TODO enable later
# "ARG", # TODO useful, but results in some false positives in pytest fixtures... maybe later
# "A", # TODO builtin shadowing -- handle later
# "S", # bandit (security checks) -- tends to be not very useful, lots of nitpicks
# "DTZ", # datetimes checks -- complaining about missing tz and mostly false positives
"ARG", # unused argument checks
# "A", # builtin shadowing -- TODO handle later
# "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
# "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
"D", # annoying nags about docstrings
"N", # pep naming
"TCH", # type checking rules, mostly just suggests moving imports under TYPE_CHECKING
"S", # bandit (security checks) -- tends to be not very useful, lots of nitpicks
"DTZ", # datetimes checks -- complaining about missing tz and mostly false positives
"FIX", # complains about fixmes/todos -- annoying
"TD", # complains about todo formatting -- too annoying
"ANN", # missing type annotations? seems way to strict though
### too opinionated style checks
"E501", # too long lines
@ -62,10 +63,9 @@ lint.ignore = [
"E402", # Module level import not at top of file
### maybe consider these soon
# sometimes it's useful to give a variable a name even if we don't use it as a documentation
# on the other hand, often is a sign of error
# sometimes it's useful to give a variable a name even if we don't use it as a documentation
# on the other hand, often is a sign of error
"F841", # Local variable `count` is assigned to but never used
"F401", # imported but unused
###
### TODO should be fine to use these with from __future__ import annotations?
@ -90,8 +90,10 @@ lint.ignore = [
"B009", # calling gettattr with constant attribute -- this is useful to convince mypy
"B010", # same as above, but setattr
"B011", # complains about assert False
"B017", # pytest.raises(Exception)
"B023", # seems to result in false positives?
"B028", # suggest using explicit stacklevel? TODO double check later, but not sure it's useful
# complains about useless pass, but has sort of a false positive if the function has a docstring?
# this is common for click entrypoints (e.g. in __main__), so disable
@ -115,7 +117,7 @@ lint.ignore = [
"PT011", # pytest raises should is too broad
"PT012", # pytest raises should contain a single statement
"COM812", # trailing comma missing -- TODO maybe use this?
"COM812", # trailing comma missing -- mostly just being annoying with long multiline strings
"PD901", # generic variable name df
@ -125,15 +127,12 @@ lint.ignore = [
"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
"UP038", # suggests using | (union) in isisntance checks.. but it results in slower code
## too annoying
"T20", # just complains about prints and pprints
"Q", # flake quotes, too annoying
@ -144,5 +143,9 @@ lint.ignore = [
"BLE001", # do not catch 'blind' Exception
"INP001", # complains about implicit namespace packages
"SIM", # some if statements crap
"RSE102", # complains about missing parens in exceptions
##
"ARG001", # ugh, kinda annoying when using pytest fixtures
"F401" , # TODO nice to have, but annoying with NOT_HPI_MODULE thing
]