diff --git a/Makefile b/Makefile index 3dbc767..be20f2c 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ PYTEST_ARGS := TOX_ARGS := PYLINT_ARGS := MYPY_ARGS := +RUFF_ARGS := DOC_DIR := docs MKDOC_CONFIG := mkdocs.yml @@ -71,7 +72,7 @@ help: @$(ECHO) @$(ECHO) "$(SECTION_COLOR)--- lint ---$(COLORLESS)" @$(ECHO) "lint - Run linting commands in '$(DEV_ENV)' environment." - @$(ECHO) "pylint - Run pylint in '$(DEV_ENV)' environment." + @$(ECHO) "ruff - Run ruff in '$(DEV_ENV)' environment." @$(ECHO) "mypy - Run mypy in '$(DEV_ENV)' environment." @$(ECHO) @$(ECHO) "$(SECTION_COLOR)--- build ---$(COLORLESS)" @@ -137,10 +138,13 @@ coverage-show: pylint: $(CONDA_RUN) pylint src/mkdocstrings_handlers tests $(PYLINT_ARGS) +ruff: + $(CONDA_RUN) ruff check src/mkdocstrings_handlers tests $(RUFF_ARGS) + mypy: $(CONDA_RUN) mypy $(MYPY_ARGS) -lint: pylint mypy +lint: ruff mypy WHEEL_FILE := dist/$(subst -,_,$(PACKAGE))-$(VERSION)-py3-none-any.whl CONDA_FILE := dist/$(PACKAGE)-$(VERSION)-py_0.conda diff --git a/environment.yml b/environment.yml index 580b53f..98131ad 100644 --- a/environment.yml +++ b/environment.yml @@ -11,10 +11,11 @@ dependencies: - hatchling >=1.21 # test - coverage >=7.4.0 - - pytest >=7.4.0 - - pytest-cov >=4.1.0 + - pytest >=8.2 + - pytest-cov >=5.0 - pylint >=3.0.3 - - mypy >=1.8 + - mypy >=1.10 + - ruff >=0.4.10 - beautifulsoup4 >=4.12 # documentation - black >=23.12 diff --git a/pyproject.toml b/pyproject.toml index 8c035a5..636767a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,66 @@ module = [ ] ignore_missing_imports = true +[tool.ruff.lint] +# TODO add "I" (isort) +# TODO add "RUF" +# TODO add "ARG" +# TODO add "SIM" +# TODO add "S" (bandit) +# TODO add "PT" (pytest style) +# TODO add "CPY101" +select = ["E", "F", "PL", "D", "R", "T10", "EXE"] +ignore = [ + "D105", # missing doc string for dunder methods + "D200", # one line doc string + "D202", # blank lines after function docstring + "D205", # doc on first line + "D212", # doc on first line + "D410", # blank line after doc section + "D411", # blank line before doc section + "D412", # no blank lines after section header + "D415", # doc title punctuation + "E501", # line too long + "PLC0105", # covariant metatype names + "PLR0913", # too-many-argument + "PLR2004", # magic value + "PT001", # allow @pytest.fixture without parens + "RET504", # unnecessary assignment to variable before return + "S101", # use of assert - do we care? + # TODO: fix the ones below + "D403", # capitalize first word of doc string + "D102", # undocumented public method + "D104", # missing docstring in public package + "D107", # __init__ docstring + "D417", # missing argument description +] +preview = true +explicit-preview-rules = true # only preview explicitly selected rules (E.g. CPY001) + +[tool.ruff.lint.per-file-ignores] +# Ignore some issues in tests +"tests/**" = [ + "F401", # unused import (pytest fixture) + "F403", # wildcard import (for fixtures) + "F405", # defined from star imports (typicallky a pytest fixture) + "F811", # redefinition of unused (typically a pytest fixture) + "PLR0912", # too many branches + "PLR0915", # too many statements + "S", # bandit rules +] + +[tool.ruff.lint.pylint] +#max-locals = 30 +max-branches = 15 +#max-attributes = 30 + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[too.ruff.format] +skip-magic-trailing-comma = false +line-ending = "lf" + [tool.pylint.main] jobs = 0 # Minimum Python version to use for version dependent checks. diff --git a/tests/test_handler.py b/tests/test_handler.py index f1d316d..d56ca1d 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -74,8 +74,7 @@ def test_handler(tmpdir: PathLike, def fake_collect(_self: PythonHandler, identifier: str, _config: dict) -> Any: if identifier.startswith('mod'): return Object(identifier) - else: - raise CollectionError(identifier) + raise CollectionError(identifier) def fake_render(_self: PythonHandler, data: Object, _config: dict) -> str: assert data.docstring is not None