lint: Replace (most of) pycodestyle with Black.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-09-01 20:22:01 -07:00 committed by Tim Abbott
parent 6e4c3e41dc
commit f21fbea7c7
5 changed files with 53 additions and 65 deletions

View File

@ -32,6 +32,9 @@ line-profiler
# for pep8 linter
pycodestyle
# Python reformatter
black
# Needed to run pyflakes linter
pyflakes

View File

@ -21,6 +21,10 @@ apns2==0.7.2 \
--hash=sha256:4f2dae8c608961d1768f734acb1d0809a60ac71a0cdcca60f46529b73f20fb34 \
--hash=sha256:f64a50181d0206a02943c835814a34fc1b1e12914931b74269a0f0fb4f39fd45
# via -r requirements/common.in
appdirs==1.4.4 \
--hash=sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41 \
--hash=sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128
# via black
argon2-cffi==20.1.0 \
--hash=sha256:05a8ac07c7026542377e38389638a8a1e9b78f1cd8439cd7493b39f08dd75fbf \
--hash=sha256:0bf066bc049332489bb2d75f69216416329d9dc65deee127152caeb16e5ce7d5 \
@ -81,6 +85,9 @@ beautifulsoup4==4.9.3 \
# -r requirements/common.in
# pyoembed
# zulip-bots
black==20.8b1 \
--hash=sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea
# via -r requirements/dev.in
boto3==1.17.5 \
--hash=sha256:0d126d429a8a9ea2c8409a1ee36ce5a34e11db788d7730a714016264f10bbb89 \
--hash=sha256:d6aafb804fca2b67c65dda78ad8b4afed901e004071208b84c804d345ad9ebba
@ -199,6 +206,7 @@ click==7.1.2 \
--hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a \
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc
# via
# black
# click-log
# fb-sapp
# flask
@ -310,6 +318,7 @@ dataclasses==0.8 ; python_version < "3.7" \
--hash=sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97
# via
# -r requirements/common.in
# black
# dataclasses-json
# libcst
# pyre-check
@ -830,6 +839,7 @@ mypy-extensions==0.4.3 \
--hash=sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d \
--hash=sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8
# via
# black
# mypy
# typing-inspect
mypy==0.800 \
@ -919,6 +929,10 @@ parso==0.8.1 \
--hash=sha256:15b00182f472319383252c18d5913b69269590616c947747bc50bf4ac768f410 \
--hash=sha256:8519430ad07087d4c997fda3a7918f7cfa27cb58972a8c89c2a0295a1c940e9e
# via jedi
pathspec==0.8.1 \
--hash=sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd \
--hash=sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d
# via black
pexpect==4.8.0 \
--hash=sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937 \
--hash=sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c
@ -1285,7 +1299,9 @@ regex==2020.11.13 \
--hash=sha256:e3faaf10a0d1e8e23a9b51d1900b72e1635c2d5b0e1bea1c18022486a8e2e52d \
--hash=sha256:f7d29a6fc4760300f86ae329e3b6ca28ea9c20823df123a2ea8693e967b29917 \
--hash=sha256:f8f295db00ef5f8bae530fc39af0b40486ca6068733fb860b42115052206466f
# via talon
# via
# black
# talon
requests-oauthlib==1.3.0 \
--hash=sha256:7f71572defaecd16372f9006f33c2ec8c077c3cfa6f5911a9a90202beb513f3d \
--hash=sha256:b4261601a71fd721a8bd6d7aa1cc1d6a8a93b4a9f5e96626f8e4d91e8beeaa6a
@ -1570,6 +1586,10 @@ tlds==2021020900 \
--hash=sha256:9774b3df448cd880870c5fc409c91b7b0b17d2b1d433a7fab63be5c0facc25e9 \
--hash=sha256:bfd0d63f863b150e451717b35f6cea4621264334e6dd000075edf135e35e0c2a
# via -r requirements/common.in
toml==0.10.2 \
--hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \
--hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f
# via black
tornado==4.5.3 \
--hash=sha256:5ef073ac6180038ccf99411fe05ae9aafb675952a2c8db60592d5daf8401f803 \
--hash=sha256:6d14e47eab0e15799cf3cdcc86b0b98279da68522caace2bd7ce644287685f0a \
@ -1648,13 +1668,16 @@ typed-ast==1.4.2 \
--hash=sha256:d175297e9533d8d37437abc14e8a83cbc68af93cc9c1c59c2c292ec59a0697a3 \
--hash=sha256:d746a437cdbca200622385305aedd9aef68e8a645e385cc483bdc5e488f07166 \
--hash=sha256:e683e409e5c45d5c9082dc1daf13f6374300806240719f95dc783d1fc942af10
# via mypy
# via
# black
# mypy
typing-extensions==3.7.4.3 \
--hash=sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918 \
--hash=sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c \
--hash=sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f
# via
# -r requirements/common.in
# black
# fb-sapp
# importlib-metadata
# libcst

View File

@ -2,74 +2,26 @@
ignore =
# Each of these rules are ignored for the explained reason.
# "whitespace before ':'"
# Black disagrees with this.
E203,
# "multiple spaces before operator"
# There are several typos here, but also several instances that are
# being used for alignment in dict keys/values using the `dict`
# constructor. We could fix the alignment cases by switching to the `{}`
# constructor, but it makes fixing this rule a little less
# straightforward.
E221,
# 'missing whitespace around arithmetic operator'
# This should possibly be cleaned up, though changing some of
# these may make the code less readable.
E226,
# New rules in pycodestyle 2.4.0 that we haven't decided whether to comply with yet
E252, W504,
# "multiple spaces after ':'"
# This is the `{}` analogue of E221, and these are similarly being used
# for alignment.
E241,
# "unexpected spaces around keyword / parameter equals"
# Many of these should be fixed, but many are also being used for
# alignment/making the code easier to read.
E251,
# "block comment should start with '#'"
# These serve to show which lines should be changed in files customized
# by the user. We could probably resolve one of E265 or E266 by
# standardizing on a single style for lines that the user might want to
# change.
E265,
# "too many leading '#' for block comment"
# Most of these are there for valid reasons.
E266,
# "expected 2 blank lines after class or function definition"
# Zulip only uses 1 blank line after class/function
# definitions; the PEP-8 recommendation results in super sparse code.
E302, E305,
# All formatting is handled by Black.
E1,
E2,
E3,
E401,
E5,
E701,
E702,
E703,
E704,
W1,
W2,
W3,
W5,
# "module level import not at top of file"
# Most of these are there for valid reasons, though there might be a
# few that could be eliminated.
E402,
# "line too long"
# Zulip is a bit less strict about line length, and has its
# own check for this (see max_length)
E501,
# "do not assign a lambda expression, use a def"
# Fixing these would probably reduce readability in most cases.
E731,
# "line break before binary operator"
# This is a bug in the `pep8`/`pycodestyle` tool -- it's completely backward.
# See https://github.com/PyCQA/pycodestyle/issues/498 .
W503,
# This number will probably be used for the corrected, inverse version of
# W503 when that's added: https://github.com/PyCQA/pycodestyle/pull/502
# Once that fix lands and we update to a version of pycodestyle that has it,
# we'll want the rule; but we might have to briefly ignore it while we fix
# existing code.
# W504,

View File

@ -2,6 +2,7 @@
import argparse
import os
import random
import re
import sys
# check for the venv
@ -145,6 +146,15 @@ def run() -> None:
fix_arg=["--write"],
description="Formats CSS, JavaScript, YAML",
)
linter_config.external_linter(
"black",
["black"],
["py"],
description="Reformats Python code",
check_arg=["--check"],
suppress_line=lambda line: line == "All done! ✨ 🍰 ✨\n"
or re.fullmatch(r"\d+ files? would be left unchanged\.\n", line) is not None,
)
semgrep_command = [
"semgrep",

View File

@ -45,4 +45,4 @@ API_FEATURE_LEVEL = 38
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = "126.2"
PROVISION_VERSION = "126.3"