Skip pb files in linters

In isort, black, and flake8, respectively.

Add `format` in Makefile

Run top level packages only

With `setup.py`, to avoid running other unrelated directories.

Refactor
This commit is contained in:
mhchia 2019-08-03 18:02:27 +08:00 committed by Kevin Mai-Husan Chia
parent c8005c8113
commit 4fef80595c
3 changed files with 33 additions and 3 deletions

View File

@ -1,8 +1,15 @@
FILES_TO_LINT = libp2p tests examples setup.py
format:
black $(FILES_TO_LINT)
isort --recursive $(FILES_TO_LINT)
lintroll: lintroll:
# NOTE: disabling `mypy` until we get typing sorted in this repo # NOTE: disabling `mypy` until we get typing sorted in this repo
# mypy -p libp2p -p examples --config-file {toxinidir}/mypy.ini # mypy -p libp2p -p examples --config-file {toxinidir}/mypy.ini
black --check examples libp2p/__init__.py libp2p/host libp2p/kademlia libp2p/network libp2p/peer libp2p/protocol_muxer libp2p/pubsub/*.py libp2p/routing libp2p/security libp2p/stream_muxer libp2p/transport tests setup.py # TODO: add flake8
isort --recursive --check-only examples libp2p/__init__.py libp2p/host libp2p/kademlia libp2p/network libp2p/peer libp2p/protocol_muxer libp2p/pubsub/*.py libp2p/routing libp2p/security libp2p/stream_muxer libp2p/transport tests setup.py black --check $(FILES_TO_LINT)
isort --recursive --check-only $(FILES_TO_LINT)
protobufs: protobufs:
cd libp2p/pubsub/pb && protoc --python_out=. rpc.proto cd libp2p/pubsub/pb && protoc --python_out=. rpc.proto

22
pyproject.toml Normal file
View File

@ -0,0 +1,22 @@
[tool.black]
line-length = 88
target_version = ['py37']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| \w*_pb2\w*\.py # pb2 files
)
'''

View File

@ -7,7 +7,7 @@ envlist =
[flake8] [flake8]
max-line-length= 100 max-line-length= 100
exclude= exclude=*_pb2*.py
ignore= ignore=
[isort] [isort]
@ -18,6 +18,7 @@ include_trailing_comma=True
force_grid_wrap=0 force_grid_wrap=0
use_parentheses=True use_parentheses=True
line_length=88 line_length=88
skip_glob=*_pb2*.py
[testenv] [testenv]
deps = deps =