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

Update pre-commit check hooks

parent 7f09833d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
[general]
ignore=body-trailing-whitespace,body-is-missing
regex-style-search=True

[author-valid-email]
regex=.*@[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9])+
regex=@[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])+$

[ignore-body-lines]
regex=^(Fixes|Closes):?\s+[#][0-9]+

# vim:ft=cfg

.lint

deleted100644 → 0
+0 −132
Original line number Diff line number Diff line
[mypy]
strict = true
warn_unreachable = true

[flake8]
max-line-length = 92
max-doc-length = 92
use-flake8-tabs = true
blank-lines-indent = never
indent-tabs-def = 1
format = pylint
select = C,D,E,ET,F,SFS,T,W,WT

; Speedup by pruning potentially large trees that will have nothing of interest
; in them.
exclude =
  __pycache__
  .*

per-file-ignores =
  setup.py: D100, E702
  tests/*.py: D100, C801
  **/__init__.py: D104
  **/__main__.py: D100, E702

ignore =
  ;[ Missing docstring in public method ]
  ; Handled by pylint, which does it better
  D102

  ;[ Missing docstring in magic method ]
  ; Magic/dunder methods are well-known
  D105

  ;[ Misisng docstring in __init__ ]
  ; Document basic construction in the class docstring
  D107

  ;[ One-line docstring should fit on one line with quotes ]
  ; Prefer top-and-bottom style always
  D200

  ;[ Docstring should be indented with spaces, not tabs ]
  ; Tabs, absolutely always
  D206

  ;[ Use r""" if any backslashes in a docstring ]
  ; If I want to put escape chars in a docstring, I will
  D301

  ;[ Use u""" for Unicode docstrings ]
  ; This must be for Python 2?
  D302

  ;[ First line should end with a period ]
  ; First line should *NEVER* end with a period
  D400

  ;[ First line should be in the imperative mood ]
  ; I like this for functions and methods, not for properties. This stands until
  ; pydocstyle splits a new code for properties or flake8 adds some way of
  ; filtering codes with line regexes like golangci-lint.
  D401

  ;[ No blank lines allowed between a section header and its content ]
  D412

  ;[ missing whitespace around bitwise or shift operator ]
  E227

  ;[ Line too long ]
  ; Prefer B950 implementation
  E501

  ;[ '%s' imported but unused ]
  ; Prefer pylint
  F401

  ;[ Line break before binary operator ]
  ; Not considered current
  W503

  ;[ Format-method string formatting ]
  ; Allow this style
  SFS201

  ;[ f-string string formatting ]
  ; Allow this style
  SFS301

include =
  ;[ First word of the docstring should not be This ]
  D404

  ; flake8-bugbear plugin
  ; B950 is a replacement for E501
  B0 B903 B950

[pylint.MASTER]
persistent=yes
ignore =
  __pycache__
  .*

[pylint.BASIC]
const-rgx = (([A-Z_][A-Z0-9_]*)|(_[A-Za-z0-9_]+))$
good-names = db, i, a, b, ab, t, fd

[pylint.REPORTS]
reports = no

[pylint.FORMAT]
indent-string = '\t'

[pylint.DESIGN]
max-attributes = 10

[pylint.MESSAGES CONTROL]
disable =
  bad-continuation,
  ; Would be nice to not disable but it is bugged; it trys to interpret tabs as
  ; spaces.

  trailing-whitespace,
  ; Would be nice to have enabled for *code* but not for comments or
  ; multi-line strings.

  wrong-import-order,
  ; Rely on isort, otherwise pylint and isort occasionally clash.


; vim:ft=cfg:sw=2:sts=2:expandtab
+14 −43
Original line number Diff line number Diff line
default_stages: [commit]
repos:

- repo: meta
@@ -8,37 +9,24 @@ repos:
  rev: v3.4.0
  hooks:
  - id: check-added-large-files
    stages: [commit]
  - id: check-case-conflict
    stages: [commit]
  - id: check-docstring-first
    stages: [commit]
  - id: check-merge-conflict
    stages: [commit]
  - id: check-toml
    stages: [commit]
  - id: check-yaml
    stages: [commit]
  - id: debug-statements
    stages: [commit]
  - id: destroyed-symlinks
    stages: [commit]
  - id: end-of-file-fixer
    stages: [commit]
  - id: fix-byte-order-marker
    stages: [commit]
  - id: fix-encoding-pragma
    args: [--remove]
    stages: [commit]
  - id: mixed-line-ending
    args: [--fix=lf]
    stages: [commit]
  - id: trailing-whitespace
    exclude_types: [markdown, plain-text]
    stages: [commit]

- repo: https://github.com/jorisroovers/gitlint
  rev: v0.15.0
  rev: v0.19.1
  hooks:
  - id: gitlint

@@ -50,7 +38,6 @@ repos:
    entry: hooks/copyright.py
    require_serial: true
    types: [python]
    stages: [commit]
  - id: check-for-squash
    name: Check for commits that need squashing
    language: system
@@ -70,51 +57,35 @@ repos:
    args: [--fix-mode]
    minimum_pre_commit_version: 2.9.0
    require_serial: true
    stages: [commit]
    types: [text]

- repo: https://github.com/pre-commit/pygrep-hooks
  rev: v1.8.0
  rev: v1.10.0
  hooks:
  - id: python-no-eval
    stages: [commit]
  - id: python-no-log-warn
    stages: [commit]
  - id: python-use-type-annotations
    stages: [commit]

- repo: https://github.com/hakancelik96/unimport
  rev: 0.7.4
- repo: https://github.com/hakancelikdev/unimport
  rev: 1.2.1
  hooks:
  - id: unimport
    args: [--remove]
    stages: [commit]

- repo: https://github.com/timothycrosley/isort
  rev: 5.7.0
- repo: https://github.com/pycqa/isort
  rev: 5.13.2
  hooks:
  - id: isort
    types: [python]
    stages: [commit]

- repo: https://gitlab.com/pycqa/flake8
  rev: 3.8.4
- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.8.4
  hooks:
  - id: flake8
    args: ["--config=.lint"]
    additional_dependencies:
    - flake8-commas
    - flake8-bugbear
    - flake8-docstrings
    - flake8-print
    - flake8-requirements
    - flake8-return
    - flake8-sfs
    - flake8-tabs
    stages: [commit]
  - id: ruff
    args: [--fix, --unsafe-fixes]

- repo: https://code.kodo.org.uk/dom/pre-commit-mypy
  rev: v0.812
- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.14.1
  hooks:
  - id: mypy
    args: ["--config-file=.lint"]
    # args: [--follow-imports=silent]

.ruff.toml

0 → 100644
+182 −0
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]
select = [
	# pyflakes
	# --------

	# 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",

	# 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", "COM", "C4", "DTZ", "ISC", "LOG", "G", "PIE", "T",
	"Q", "RSE", "RET", "SLF", "SLOT", "SIM", "TD", "ANN", #"FA",

	# 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",

	# Unfortunately a lot of single quotes strings used in this project already
	"Q000",
]

[lint.per-file-ignores]
"**/__init__.py" = ["D104"]
"**/__main__.py" = ["D100", "E702"]
"**/_*.py" = ["D1"]
"examples/**.py" = ["T"]
"tests/*" = ["D1"]
"doc/*" = ["D"]
"README.md" = ["D"]
"migrations/**" = ["D", "SLF001"]
+6 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ classifiers = [
	"Programming Language :: Python :: 3.9",
	"Topic :: Software Development :: Quality Assurance",
]
requires-python = "~=3.6"
requires-python = "~=3.9"

[tool.flit.scripts]
check-copyright-notice = "hooks.copyright:main"
@@ -34,3 +34,8 @@ force_single_line = true
[tool.unimport]
exclude = "__init__.py"
remove = true

[tool.mypy]
strict = true
warn_unused_configs = true
warn_unreachable = true