Verified Commit d67c02be authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Update code quality checks

parent 2ff21488
Loading
Loading
Loading
Loading
+30 −47
Changes for .pre-commit-config.yaml: 30 added lines, 47 removed lines.
Original line number Diff line number Diff line
default_stages: [commit]
minimum_pre_commit_version: 3.2.0
default_install_hook_types: [pre-commit, pre-push, commit-msg]
default_language_version: {python: "3.11"}
default_stages: [pre-commit]
repos:

- repo: meta
@@ -7,7 +10,7 @@ repos:
  - id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.6.0
  rev: v6.0.0
  hooks:
  - id: check-added-large-files
  - id: check-case-conflict
@@ -18,16 +21,14 @@ repos:
  - id: debug-statements
  - id: destroyed-symlinks
  - id: end-of-file-fixer
    stages: [commit, manual]
    stages: [pre-commit, manual]
  - id: fix-byte-order-marker
  - id: fix-encoding-pragma
    args: [--remove]
  - id: mixed-line-ending
    args: [--fix=lf]
    stages: [commit, manual]
    stages: [pre-commit, manual]
  - id: trailing-whitespace
    exclude_types: [markdown, plain-text]
    stages: [commit, manual]
    stages: [pre-commit, manual]

- repo: https://github.com/jorisroovers/gitlint
  rev: v0.19.1
@@ -35,13 +36,13 @@ repos:
  - id: gitlint

- repo: https://code.kodo.org.uk/dom/pre-commit-hooks
  rev: v0.6.1
  rev: v1.0.0
  hooks:
  - id: check-executable-modes
  - id: check-for-squash
  - id: copyright-notice
    args: [--min-size=100]
    stages: [commit, manual]
    stages: [pre-commit, manual]
  - id: protect-first-parent

- repo: https://github.com/pre-commit/pygrep-hooks
@@ -51,52 +52,34 @@ repos:
  - id: python-no-log-warn
  - id: python-use-type-annotations

- repo: https://github.com/hakancelikdev/unimport
  rev: 1.2.1
- repo: https://github.com/asottile/pyupgrade
  rev: v3.22.0
  hooks:
  - id: unimport
    args: ["--remove", "--include=\\.pyi?$"]
    types: []
    types_or: [python, pyi]
    stages: [commit, manual]
  - id: pyupgrade

- repo: https://github.com/pycqa/isort
  rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.17.2
  hooks:
  - id: isort
    stages: [commit, manual]
  - id: ruff-check
    # args: ["--fix", "--unsafe-fixes"]
  - id: ruff-format
    stages: [manual]

- repo: https://github.com/asottile/add-trailing-comma
  rev: v3.1.0
- repo: https://github.com/RobertCraigie/pyright-python
  rev: v1.1.414
  hooks:
  - id: add-trailing-comma
    args: [--py36-plus]
    types: []
    types_or: [python, pyi]
    stages: [commit, manual]

- repo: https://github.com/flakeheaven/flakeheaven
  rev: 3.3.0
  hooks:
  - id: flakeheaven
    additional_dependencies:
    - flake8-bugbear
    - flake8-docstrings
    - flake8-print
    - flake8-return
    - flake8-sfs

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.10.0
  hooks:
  - id: mypy
    args: [--follow-imports=silent]
    additional_dependencies:
  - id: pyright
    additional_dependencies: &deps
    - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[behave,jsonpath]
    - packaging >=21
    - parse ==1.22.0
    - trio-typing[mypy]
    - types-orjson
    - types-requests
    - types-urllib3
    - typing-extensions ~=4.0; python_version < "3.11"
    - trio-typing[mypy]
    - xdg-base-dirs ~=6.0
    - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[jsonpath,parse]
  # - id: pyright
  #   additional_dependencies: *deps
  #   stages: ["pre-push", "manual"]
  #   pass_filenames: false
+188
Changes for .ruff.toml: 188 added lines, 0 removed lines.
Original line number Diff line number Diff line
line-length = 92
indent-width = 1  # Used for line length violations

[format]
indent-style = "tab"
skip-magic-trailing-comma = false

[lint.isort]
force-single-line = true
required-imports = ["from __future__ import annotations"]

[lint]
select = [
	# pyflakes
	# --------

	# ENABLE "%s imported but unused; ..."
	# Replace unimport with this due to unimport's Python parsing lagging
	# severely behind.
	"F401",

	# ENABLE "Undefined name %s in __all__"
	"F822",

	# ENABLE "Local variable %s ... referenced before assignment"
	"F823",

	# ENABLE "Local variable %s is assigned to but never used"
	"F841",

	# ENABLE "raise NotImplemented should be raise NotImplementedError"
	# mypy has particular trouble with this one:
	# https://github.com/python/mypy/issues/5710
	"F901",

	# pycodestyle
	# -----------

	# Warnings not considered, many are not relevant to Python ~=3.9 and will
	# cause syntax errors anyway, others concern whitespace which is fixed by
	# a pre-commit hook.
	"E",

	# mccabe
	# ------

	"C90",

	# pydocstyle
	# ----------

	# Missing docstrings
	"D1",

	# Whitespace Issues
	"D2",

	# ENABLE "Use “””triple double quotes”””"
	"D300",

	# First line should be descriptive, imperative and capitalised
	"D401", "D402", "D403", "D404",

	# ENABLE "Function/Method decorated with @overload shouldn’t contain a docstring"
	"D418",

	# flake8-bugbear
	# --------------

	# The bulk of bugbear's checks are useful
	"B0",

	# Various others
	# --------------

	"UP", "BLE", "FBT", "A", "C4", "DTZ", "ISC", "LOG", "G", "PIE", "T",
	"Q", "RSE", "RET", "SLF", "SLOT", "SIM", "TD", "ANN",
	"RUF", "I",

	# Nice to have, needs fixing in several places though...
	# "EM", "TCH", "PTH", "PGH",
]
ignore = [
	# pycodestyle
	# -----------

	# DISABLE "Indentation contains mixed spaces and tabs"
	# Will cause a syntax error if critical, otherwise in docstrings it is
	# sometimes nice to use different indentation for "outer" (code) indentation
	# and "inner" (documentation) indentation.
	"E101",

	# DISABLE "Continuation line missing indentation or outdented"
	# "E122",

	# DISABLE "Missing whitespace around bitwise or shift operator"
	"E227",

	# DISABLE "missing whitespace around arithmetic operator"
	"E226",

	# DISABLE "Line too long"
	# Prefer B950 implementation
	"E501",

	# DISABLE "Multiple statements on one line (colon)"
	"E701",

	# DISABLE "Multiple statements on one line (def)"
	# Doesn't work well with @overload definitions
	# "E704",

	# pydocstyle
	# ----------

	# DISABLE "Missing docstring in magic method"
	# Magic/dunder methods are well-known
	"D105",

	# DISABLE "Missing docstring in __init__"
	# Document basic construction in the class docstring
	"D107",

	# DISABLE "One-line docstring should fit on one line with quotes"
	# Prefer top-and-bottom style always
	"D200",

	# DISABLE "1 blank line required before class docstring"
	"D203",

	# DISABLE "Docstring should be indented with spaces, not tabs"
	# Tabs, absolutely always
	"D206",

	# DISABLE "Multi-line docstring summary should start at the first line"
	"D212",

	# flake8-bugbear
	# --------------

	# DISABLE "Do not use mutable data structures for argument defaults [...]"
	# Would be nice if could take into account use as a non-mutable type
	"B006",

	# DISABLE "Loop control variable `self` overrides iterable it iterates"
	# Bit buggy, and type checker should catch it.
	"B020",

	# DISABLE "release is an empty method in an abstract base class, [...]"
	# Until abstract methods are optional, empty optional "abstract" methods
	# stay
	"B027",

	# Use named-tuples (preferably class based) for data-only classes
	# "B903",

	# Replacement for E501
	# "B950",

	# flake8-return
	# -------------

	# DISABLE "missing explicit return at the end of function able to return
	# non-None value"
	# Mypy will report this, plugin also cannot do exhaustiveness check of match
	# block, leading to false-positives.
	"RET503",

	# DISABLE "Boolean positional value in function call"
	# Too many stdlib functions take a single positional-only boolean. ruff
	# can't interpret function signatures to ignore these and doesn't understand
	# types to allow-list methods.
	"FBT003",

	# DISABLE "Implicitly concatenated string literals over multiple lines"
	# It sometimes looks better to do this than introduce unecessary
	# parentheses.
	"ISC002",
]

[lint.per-file-ignores]
"**/__init__.py" = ["D104"]
"**/__main__.py" = ["D100", "E702"]
"**/_*.py" = ["D1"]
"examples/**.py" = ["T"]
"tests/*" = ["D1"]
"doc/*" = ["D"]
"README.md" = ["D"]
+2 −39
Changes for pyproject.toml: 2 added lines, 39 removed lines.
Original line number Diff line number Diff line
@@ -34,54 +34,17 @@ include = [
Issues = "https://code.kodo.org.uk/dom/behave-utils/-/issues"

[tool.poetry.dependencies]
python = "~=3.10"
python = "~=3.11"
behave = "~=1.2"
jsonpath-python = "~=1.0"
orjson = "~=3.6"
parse = "~=1.19"
parse = "~=1.22"
requests = "~=2.26"
trio = "~=0.25.0"
xdg-base-dirs = "~=6.0"
packaging = ">=21"


[tool.isort]
force_single_line = true

[tool.mypy]
strict = true
warn_unused_configs = true
warn_unreachable = true
mypy_path = ["stubs"]
plugins = ["trio_typing.plugin"]

[[tool.mypy.overrides]]
module = "coverage.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "tests.coverage"
disallow_subclassing_any = false


[tool.flakeheaven]
base = "https://code.kodo.org.uk/dom/project-templates/-/raw/main/.flakerules.toml"
max_line_length = 92
max_doc_length = 92

[tool.flakeheaven.plugins]
pycodestyle = ["-E701", "-E226", "-W191"]

[tool.flakeheaven.exceptions."tests/"]
flake8-docstrings = ["-D100"]

[tool.flakeheaven.exceptions."README.md"]
flake8-docstrings = ["-*"]

[tool.flakeheaven.exceptions."doc/*"]
flake8-docstrings = ["-*"]


[tool.coverage.run]
data_file = "results/coverage.db"
branch = true
−1

File deleted.

−30

File deleted.

Loading