Skip to content

Commit

Permalink
Backport pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
AllSeeingEyeTolledEweSew authored and arvidn committed Oct 9, 2021
1 parent 1e5ac61 commit 10849e4
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ on:

jobs:

pre-commit:
# TODO: matrix across python version and os
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: 3.6
- uses: pre-commit/[email protected]

build:
name: build
runs-on: ubuntu-20.04
Expand Down
196 changes: 196 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: |
(?x)^(
# These files are vendored from elsewhere, don't process them
LICENSE|
docs/hunspell/.*|
src/ed25519/.*|
include/libtorrent/aux_/route\.h|
test/.*\.xml|
test/ssl/.*\.pem
)$
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
#- id: trailing-whitespace
#- id: end-of-file-fixer
- id: check-yaml
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-xml
- id: debug-statements
- id: check-symlinks
- id: check-toml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
hooks:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
exclude: |
(?x)^(
# Enable these later, avoid bloating this PR
bindings/python/client.py|
bindings/python/dummy_data.py|
bindings/python/make_torrent.py|
bindings/python/setup.py|
bindings/python/simple_client.py|
bindings/python/test.py|
docs/gen_reference_doc.py|
examples/run_benchmarks.py|
fuzzers/tools/generate_initial_corpus.py|
fuzzers/tools/unify_corpus_names.py|
test/socks.py|
test/web_server.py|
tools/clean.py|
tools/dht_flood.py|
tools/parse_dht_log.py|
tools/parse_dht_rtt.py|
tools/parse_dht_stats.py|
tools/parse_session_stats.py|
tools/parse_utp_log.py|
tools/run_benchmark.py|
tools/set_version.py|
tools/update_copyright.py
)$
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: [--in-place, --remove-unused-variables, --remove-all-unused-imports, --remove-duplicate-keys]
# Avoiding PR bloat
exclude: |
(?x)^(
bindings/python/setup.py|
bindings/python/test.py
)
- repo: https://github.com/python/black
rev: 20.8b1
hooks:
- id: black
# Avoiding PR bloat
exclude: |
(?x)^(
bindings/python/client.py|
bindings/python/dummy_data.py|
bindings/python/make_torrent.py|
bindings/python/setup.py|
bindings/python/simple_client.py|
bindings/python/test.py|
docs/filter-rst.py|
docs/gen_settings_doc.py|
docs/gen_reference_doc.py|
docs/gen_stats_doc.py|
docs/gen_todo.py|
docs/join_rst.py|
examples/run_benchmarks.py|
fuzzers/tools/generate_initial_corpus.py|
fuzzers/tools/unify_corpus_names.py|
setup.py|
test/http_proxy.py|
test/socks.py|
test/web_server.py|
tools/clean.py|
tools/dht_flood.py|
tools/gen_fwd.py|
tools/parse_dht_log.py|
tools/parse_dht_rtt.py|
tools/parse_dht_stats.py|
tools/parse_lookup_log.py|
tools/parse_peer_log.py|
tools/parse_sample.py|
tools/parse_session_stats.py|
tools/parse_utp_log.py|
tools/run_benchmark.py|
tools/set_version.py|
tools/update_copyright.py
)$
# black doesn't run on *.pyi files by default, for reasons
- id: black
name: black (pyi)
types: [pyi]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
hooks:
- id: mypy
# Avoiding PR bloat
exclude: |
(?x)^(
bindings/python/client.py|
bindings/python/dummy_data.py|
bindings/python/make_torrent.py|
bindings/python/setup.py|
bindings/python/test.py|
docs/filter-rst.py|
docs/gen_reference_doc.py|
docs/gen_settings_doc.py|
docs/gen_stats_doc.py|
docs/gen_todo.py|
examples/run_benchmarks.py|
fuzzers/tools/generate_initial_corpus.py|
setup.py|
test/http_proxy.py|
test/socks.py|
test/web_server.py|
tools/clean.py|
tools/dht_flood.py|
tools/gen_fwd.py|
tools/parse_dht_log.py|
tools/parse_dht_stats.py|
tools/parse_lookup_log.py|
tools/parse_peer_log.py|
tools/parse_sample.py|
tools/parse_session_stats.py|
tools/parse_utp_log.py|
tools/run_benchmark.py|
tools/set_version.py|
tools/update_copyright.py
)$
- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.8.4
hooks:
- id: flake8
exclude: |
(?x)^(
# Enable these later, avoid bloating this PR
bindings/python/client.py|
bindings/python/make_torrent.py|
bindings/python/setup.py|
bindings/python/test.py|
docs/gen_settings_doc.py|
docs/gen_todo.py|
docs/gen_reference_doc.py|
docs/gen_stats_doc.py|
examples/run_benchmarks.py|
fuzzers/tools/generate_initial_corpus.py|
test/http_proxy.py|
test/socks.py|
test/web_server.py|
tools/dht_flood.py|
tools/gen_fwd.py|
tools/parse_dht_stats.py|
tools/parse_dht_log.py|
tools/parse_lookup_log.py|
tools/parse_peer_log.py|
tools/parse_sample.py|
tools/parse_session_stats.py|
tools/parse_utp_log.py|
tools/run_benchmark.py|
tools/set_version.py|
tools/update_copyright.py
)$
#- repo: local
# hooks:
# - id: gen_fwd
# name: gen_fwd
# language: system
# entry: ./tools/gen_fwd.py
# always_run: true
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.isort]
profile = "google"
single_line_exclusions = []
src_paths = ["."]
15 changes: 15 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
# https://black.readthedocs.io/en/stable/compatible_configs.html#flake8
max-line-length = 88
extend-ignore = E203, W503

[mypy]
warn_return_any = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_unreachable = True
warn_unused_configs = True
#disallow_any_unimported = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
mypy_path = bindings/python/install_data

0 comments on commit 10849e4

Please sign in to comment.