Commit 1d86514d authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Switch flake8 to flakehell

parent da7a83c6
Loading
Loading
Loading
Loading

.flake8

deleted100644 → 0
+0 −92
Original line number Diff line number Diff line
[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

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

ignore =
  ;[ '%s' imported but unused ]
  ; Handled by pylint, which does it better
  F401

  ;[ 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

  ;[ multiple statements on one line (def) ]
  ; Dosen't work well with short @overload definitions
  E704

  ;[ unexpected number of tabs and spaces at start of statement ]
  ET128

  ;[ 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

.flakehell.toml

0 → 100644
+126 −0
Original line number Diff line number Diff line
[tool.flakehell]
max_line_length = 92
max_doc_length = 92

[tool.flakehell.plugins]
mccabe = [
	"+C",
]
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*",

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

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

	# DISABLE "Multiple statements on one line (def)"
	# Doesn't work well with @overload definitions
	"-E704",
]
pyflakes = [
	# Most pyflakes tests are either discovered by mypy, or fixed automatically
	# by "isort" and "unimport"; the following are the remaining useful checks
	"-*",

	# 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",
]
flake8-docstrings = [
	## Missing Docstrings
	"+D1*",

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

	# Whitespace Issues
	"+D2*",

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

	# 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-sfs = [
	# ENABLE "String literal formatting using percent operator."
	# ENABLE "Bytes literal formatting using percent operator."
	"+SFS1*",
]
flake8-bugbear = [
	# The bulk of bugbear's checks are useful
	"+B0*",

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

	# Replacement for E501
	"+B950",
]
flake8-print = [
	"+T*",
]
flake8-return = [
	"+R*",
]

[tool.flakehell.exceptions."**/__init__.py"]
docstrings = [
	# DISABLE "Missing docstring in public package"
	# Sometimes we want package docstrings, other times not.
	# TODO(dom.sekotill): Verify this
	"-D104",
]

[tool.flakehell.exceptions."**/__main__.py"]
docstrings = [
	# DISABLE "Missing docstring in public module"
	# I don't consider __main__ to be a public module, it serves the same
	# function in packages as `if __name__ == "__main__":` in modules.
	"-D100",
]
pycodestyle = [
	# DISABLE "Multiple statements on one line (semicolon)"
	# __main__ modules SHOULD simply import an entrypoint and call it.
	# One-lining it can look a little more elegant than three (including
	# a blank line between imports and code!)
	"-E702",
]
+3 −4
Original line number Diff line number Diff line
@@ -73,17 +73,16 @@ repos:
    types_or: [python, pyi]
    stages: [commit, manual]

- repo: https://gitlab.com/pycqa/flake8
  rev: 3.8.4
- repo: https://github.com/domsekotill/flakehell
  rev: 5a7ecdc
  hooks:
  - id: flake8
  - id: flakehell
    additional_dependencies:
    - flake8-bugbear
    - flake8-docstrings
    - flake8-print
    - flake8-return
    - flake8-sfs
    - flake8-tabs

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v0.910
+3 −0
Original line number Diff line number Diff line
@@ -39,3 +39,6 @@ strict = true
warn_unused_configs = true
warn_unreachable = true
mypy_path = ["stubs"]

[tool.flakehell]
base = ".flakehell.toml"