From c4ccd1a49ffcb6195ff5f9f0db2893930491af86 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov <andrew.svetlov@gmail.com> Date: Thu, 29 Oct 2020 19:57:10 +0200 Subject: [PATCH 1/2] Tune pre-commit config file --- .pre-commit-config.yaml | 49 ++++++++++++++++++++-------------------- Makefile | 7 +----- examples/cli_app.py | 1 + examples/client_auth.py | 1 + examples/client_json.py | 1 + examples/fake_server.py | 1 + examples/static_files.py | 1 + 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbe9a39f809..9317757ebfd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,11 @@ repos: +- repo: local + hooks: + - id: check-changes + name: Check CHANGES + language: system + entry: ./tools/check_changes.py + pass_filenames: false - repo: https://github.com/pre-commit/pre-commit-hooks rev: 'v3.3.0' hooks: @@ -19,39 +26,31 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: 'v3.3.0' hooks: + - id: end-of-file-fixer + exclude: >- + ^docs/[^/]*\.svg$ + - id: requirements-txt-fixer + - id: trailing-whitespace + - id: file-contents-sorter + files: | + CONTRIBUTORS.txt| + docs/spelling_wordlist.txt| + .gitignore| + .gitattributes - id: check-case-conflict - id: check-json - id: check-xml + - id: check-executables-have-shebangs + - id: check-toml + - id: check-xml - id: check-yaml - id: debug-statements - id: check-added-large-files - - id: end-of-file-fixer - exclude: >- - ^docs/[^/]*\.svg$ - - id: requirements-txt-fixer - - id: trailing-whitespace - id: check-symlinks - - id: file-contents-sorter - files: CONTRIBUTORS.txt - id: debug-statements -# Another entry is required to apply file-contents-sorter to another file -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: 'v3.3.0' - hooks: - - id: file-contents-sorter - files: docs/spelling_wordlist.txt -# Another entry is required to apply file-contents-sorter to another file -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: 'v3.3.0' - hooks: - - id: file-contents-sorter - files: .gitignore -# Another entry is required to apply file-contents-sorter to another file -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: 'v3.3.0' - hooks: - - id: file-contents-sorter - files: .gitattributes + - id: detect-aws-credentials + - id: detect-private-key + exclude: ^examples/ - repo: https://github.com/asottile/pyupgrade rev: 'v2.7.3' hooks: diff --git a/Makefile b/Makefile index 0a39d49749a..6327d654fbc 100644 --- a/Makefile +++ b/Makefile @@ -49,18 +49,13 @@ cythonize: .install-cython $(PYXS:.pyx=.c) lint: fmt mypy .PHONY: fmt format -fmt format: check_changes +fmt format: python -m pre_commit run --all-files --show-diff-on-failure .PHONY: mypy mypy: mypy aiohttp -.PHONY: check_changes -check_changes: - ./tools/check_changes.py - - .develop: .install-deps $(call to-md5,$(PYS) $(CYS) $(CS)) pip install -e . @touch .develop diff --git a/examples/cli_app.py b/examples/cli_app.py index e481795978c..9fbd3b76049 100755 --- a/examples/cli_app.py +++ b/examples/cli_app.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ Example of serving an Application using the `aiohttp.web` CLI. diff --git a/examples/client_auth.py b/examples/client_auth.py index b52896f0ffb..52b4f6cc0a3 100755 --- a/examples/client_auth.py +++ b/examples/client_auth.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import asyncio import aiohttp diff --git a/examples/client_json.py b/examples/client_json.py index 78a111a2a8c..8a9a609bc91 100755 --- a/examples/client_json.py +++ b/examples/client_json.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import asyncio import aiohttp diff --git a/examples/fake_server.py b/examples/fake_server.py index 98789eae056..74767f5f126 100755 --- a/examples/fake_server.py +++ b/examples/fake_server.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import asyncio import pathlib import socket diff --git a/examples/static_files.py b/examples/static_files.py index 3d55bd53a4f..65f6bb9c764 100755 --- a/examples/static_files.py +++ b/examples/static_files.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import pathlib from aiohttp import web From bfd1ac6ddafaff3b89fa4c0ac2ce43483cef80bb Mon Sep 17 00:00:00 2001 From: Andrew Svetlov <andrew.svetlov@gmail.com> Date: Thu, 29 Oct 2020 20:05:05 +0200 Subject: [PATCH 2/2] Fix false positive --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9317757ebfd..55826f603ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,7 @@ repos: - id: check-symlinks - id: debug-statements - id: detect-aws-credentials + args: ['--allow-missing-credentials'] - id: detect-private-key exclude: ^examples/ - repo: https://github.com/asottile/pyupgrade