diff --git a/pyproject.toml b/pyproject.toml index 7fae398..30719be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ testing = [ ] linting = [ "pytest", + "ruff", "mypy", "lxml", # for mypy html coverage ] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..0be93e0 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,25 @@ +ignore = [ +### too opinionated style checks + "E501", # too long lines + "E702", # Multiple statements on one line (semicolon) + "E731", # assigning lambda instead of using def + "E741", # Ambiguous variable name: `l` + "E742", # Ambiguous class name: `O + "E401", # Multiple imports on one line + "F403", # import *` used; unable to detect undefined names +### + +### + "E722", # Do not use bare `except` ## Sometimes it's useful for defensive imports and that sort of thing.. + "F811", # Redefinition of unused # this gets in the way of pytest fixtures (e.g. in cachew) + +## might be nice .. but later and I don't wanna make it strict + "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 + "F841", # Local variable `count` is assigned to but never used + "F401", # imported but unused +### +] diff --git a/src/orgparse/node.py b/src/orgparse/node.py index 154a3e8..7ed1cdb 100644 --- a/src/orgparse/node.py +++ b/src/orgparse/node.py @@ -832,7 +832,7 @@ def level(self): :rtype: int """ - raise NotImplemented + raise NotImplementedError def _get_tags(self, inher=False) -> Set[str]: """ diff --git a/tox.ini b/tox.ini index 788cbb5..dc04b0e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] -minversion = 3.7 +minversion = 3.21 # relies on the correct version of Python installed -envlist = tests,mypy +envlist = ruff,tests,mypy # https://github.com/tox-dev/tox/issues/20#issuecomment-247788333 # hack to prevent .tox from crapping to the project directory -toxworkdir={env:TOXWORKDIR_BASE:}{toxinidir}/.tox +toxworkdir = {env:TOXWORKDIR_BASE:}{toxinidir}/.tox [testenv] # TODO how to get package name from setuptools? @@ -18,6 +18,12 @@ passenv = PYTHONPYCACHEPREFIX +[testenv:ruff] +commands = + {envpython} -m pip install --use-pep517 -e .[linting] + {envpython} -m ruff src/ + + # note: --use-pep517 here is necessary for tox --parallel flag to work properly # otherwise it seems that it tries to modify .eggs dir in parallel and it fails [testenv:tests]