Skip to content

Commit

Permalink
Activate LOTS of flake8 plugins to enforce code hygiene
Browse files Browse the repository at this point in the history
Selection criteria:

* Must be useful, even if many warnings
  For example: Plugins related to annotations. As @warsaw raised in
  aio-libs#128, it's a good idea to type-annotate as much as possible.

* If not simple, must be maintained
  "maintained" here is overly-simplified to mean only "master has an
  update in 2020 or later".
  Some plugins have not received updates for a long time, but their
  logic are simple and really does not need updates, so those can also
  be included on a case-by-case basis.

* Will not need significant change in logic
  Adding annotations, removing temp vars used just for return values,
  those are not logic changes. So even if lots of instances need to be
  fixed, that is okay.
  Plugins that need a restructurization of the logic flow (e.g.,
  "flake8-cognitive-complexity") should not be included; or, if
  included, should not be activated. At least not until the next Epic.
  • Loading branch information
pepoluan committed Mar 2, 2021
1 parent 4148e16 commit d1e8dca
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
37 changes: 36 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,39 @@ source-dir = aiosmtpd/docs
[flake8]
jobs = 1
max-line-length = 88
ignore = E123, E133, W503, W504, W293, E203
# "E,F,W,C90" are flake8 defaults
# For others, take a gander at tox.ini to see which prefix provided by who
select = E,F,W,C90,C4,MOD,JS,PIE,PT,SIM,ECE,C801,DUO,TAE,ANN,G,YTT,N400
ignore =
# black conflicts with E123 & E133
E123
E133
# W503 conflicts with PEP8...
W503
# W293 is a bit too noisy. Many files have been edited using editors that do not remove spaces from blank lines.
W293
# Sometimes spaces around colons improve readability
E203
# Sometimes we prefer the func()-based creation, not literal, for readability
C408
# Sometimes we need to catch Exception broadly
PIE786
# We don't really care about pytest.fixture vs pytest.fixture()
PT001
# Good idea, but too many changes. Remove this in the future, and create separate PR
PT004
# Sometimes exception needs to be explicitly raised in special circumstances, needing additional lines of code
PT012
# I still can't grok the need to annotate "self" or "cls" ...
ANN101
ANN102
# I don't think forcing annotation for *args and **kwargs is a wise idea...
ANN002
ANN003
no-accept-encodings = True
copyright-check = True
# The number below was determined empirically by bisecting from 100 until no copyright-unnecessary files appear
copyright-min-file-size = 44
copyright-author = The aiosmtpd Developers
max-annotations-complexity = 4
mypy-init-return = True
38 changes: 38 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,51 @@ basepython = python3
envdir = {toxworkdir}/qa
commands =
python housekeep.py prep
# The next line lists enabled plugins
python -m flake8 --version
python -m flake8 aiosmtpd setup.py housekeep.py release.py
check-manifest -v
pytest -v --tb=short aiosmtpd/qa
# Snippets of letters above flake8- plugins are tests that need to be "select"-ed in flake8 config to
# activate the respective plugins. If no snippet is given, that means the plugin is always active
deps =
colorama
flake8
flake8-bugbear
flake8-builtins
flake8-coding
# C4
flake8-comprehensions
# JS
flake8-multiline-containers
# PIE
flake8-pie
# MOD
flake8-printf-formatting
# PT
flake8-pytest-style
# SIM
flake8-simplify
# Cognitive Complexity looks like a good idea, but to fix the complaints... it will be an epic effort.
# So we disable it for now and reenable when we're ready, probably just before 2.0
# # CCR
# flake8-cognitive-complexity
# ECE
flake8-expression-complexity
# C801
flake8-copyright
# DUO
dlint
# TAE
flake8-annotations-complexity
# ANN
flake8-annotations
# G
flake8-logging-format
# YTT
flake8-2020
# N400
flake8-broken-line
pytest
check-manifest

Expand Down

0 comments on commit d1e8dca

Please sign in to comment.