Skip to content

Commit 450b851

Browse files
authored
Merge pull request #366 from nicoddemus/improve-pre-commit
Add reorder-python-imports and autoflake hooks
2 parents 38561d7 + 5d21bc9 commit 450b851

File tree

19 files changed

+154
-123
lines changed

19 files changed

+154
-123
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ jobs:
3131
"ubuntu-py311",
3232
"ubuntu-pypy3",
3333
"ubuntu-benchmark",
34-
35-
"linting",
36-
"docs",
3734
]
3835

3936
include:
@@ -87,14 +84,6 @@ jobs:
8784
python: "3.8"
8885
os: ubuntu-latest
8986
tox_env: "benchmark"
90-
- name: "linting"
91-
python: "3.8"
92-
os: ubuntu-latest
93-
tox_env: "linting"
94-
- name: "docs"
95-
python: "3.8"
96-
os: ubuntu-latest
97-
tox_env: "docs"
9887

9988
steps:
10089
- uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 22.10.0
2+
- repo: https://github.com/PyCQA/autoflake
3+
rev: v1.7.7
44
hooks:
5-
- id: black
6-
args: [--safe, --quiet]
7-
- repo: https://github.com/asottile/blacken-docs
8-
rev: v1.12.1
5+
- id: autoflake
6+
name: autoflake
7+
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
8+
language: python
9+
files: \.py$
10+
- repo: https://github.com/asottile/reorder_python_imports
11+
rev: v3.9.0
912
hooks:
10-
- id: blacken-docs
11-
additional_dependencies: [black==22.10.0]
13+
- id: reorder-python-imports
14+
args: ['--application-directories=.:src', --py37-plus]
1215
- repo: https://github.com/pre-commit/pre-commit-hooks
1316
rev: v2.1.0
1417
hooks:
1518
- id: trailing-whitespace
1619
- id: end-of-file-fixer
1720
- id: flake8
1821
additional_dependencies: [flake8-typing-imports]
19-
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v0.990
22+
- repo: https://github.com/pre-commit/pygrep-hooks
23+
rev: v1.9.0
2124
hooks:
22-
- id: mypy
23-
files: ^(src/|testing/)
24-
args: []
25-
additional_dependencies: [pytest]
25+
- id: rst-backticks
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v3.2.2
28+
hooks:
29+
- id: pyupgrade
30+
args: [--py37-plus]
31+
- repo: https://github.com/psf/black
32+
rev: 22.10.0
33+
hooks:
34+
- id: black
35+
args: [--safe, --quiet]
36+
- repo: https://github.com/asottile/blacken-docs
37+
rev: v1.12.1
38+
hooks:
39+
- id: blacken-docs
40+
additional_dependencies: [black==22.10.0]
2641
- repo: local
2742
hooks:
2843
- id: rst
@@ -31,12 +46,10 @@ repos:
3146
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
3247
language: python
3348
additional_dependencies: [pygments, restructuredtext_lint]
34-
- repo: https://github.com/pre-commit/pygrep-hooks
35-
rev: v1.9.0
36-
hooks:
37-
- id: rst-backticks
38-
- repo: https://github.com/asottile/pyupgrade
39-
rev: v3.2.2
49+
- repo: https://github.com/pre-commit/mirrors-mypy
50+
rev: v0.990
4051
hooks:
41-
- id: pyupgrade
42-
args: [--py37-plus]
52+
- id: mypy
53+
files: ^(src/|testing/)
54+
args: []
55+
additional_dependencies: [pytest]

docs/examples/eggsample/eggsample/host.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import itertools
22
import random
33

4-
import pluggy
4+
from eggsample import hookspecs
5+
from eggsample import lib
56

6-
from eggsample import hookspecs, lib
7+
import pluggy
78

89
condiments_tray = {"pickled walnuts": 13, "steak sauce": 4, "mushy peas": 2}
910

docs/examples/eggsample/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import find_packages
2+
from setuptools import setup
23

34
setup(
45
name="eggsample",

scripts/release.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import sys
66
from subprocess import check_call
77

8-
from colorama import init, Fore
9-
from git import Repo, Remote
8+
from colorama import Fore
9+
from colorama import init
10+
from git import Remote
11+
from git import Repo
1012

1113

1214
def create_branch(version):

src/pluggy/_callers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
Call loop machinery
33
"""
44
import sys
5-
from typing import cast, Generator, List, Mapping, Sequence, Union
5+
from typing import cast
6+
from typing import Generator
7+
from typing import List
8+
from typing import Mapping
9+
from typing import Sequence
610
from typing import TYPE_CHECKING
11+
from typing import Union
712

8-
from ._result import HookCallError, _Result, _raise_wrapfail
13+
from ._result import _raise_wrapfail
14+
from ._result import _Result
15+
from ._result import HookCallError
916

1017
if TYPE_CHECKING:
1118
from ._hooks import HookImpl

src/pluggy/_hooks.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
import sys
66
import warnings
77
from types import ModuleType
8-
from typing import (
9-
AbstractSet,
10-
Any,
11-
Callable,
12-
Generator,
13-
List,
14-
Mapping,
15-
Optional,
16-
overload,
17-
Sequence,
18-
Tuple,
19-
TypeVar,
20-
TYPE_CHECKING,
21-
Union,
22-
)
8+
from typing import AbstractSet
9+
from typing import Any
10+
from typing import Callable
11+
from typing import Generator
12+
from typing import List
13+
from typing import Mapping
14+
from typing import Optional
15+
from typing import overload
16+
from typing import Sequence
17+
from typing import Tuple
18+
from typing import TYPE_CHECKING
19+
from typing import TypeVar
20+
from typing import Union
2321

2422
from ._result import _Result
2523

src/pluggy/_manager.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,32 @@
22
import sys
33
import types
44
import warnings
5-
from typing import (
6-
Any,
7-
Callable,
8-
cast,
9-
Dict,
10-
Iterable,
11-
List,
12-
Mapping,
13-
Optional,
14-
Sequence,
15-
Set,
16-
Tuple,
17-
TYPE_CHECKING,
18-
Union,
19-
)
5+
from typing import Any
6+
from typing import Callable
7+
from typing import cast
8+
from typing import Dict
9+
from typing import Iterable
10+
from typing import List
11+
from typing import Mapping
12+
from typing import Optional
13+
from typing import Sequence
14+
from typing import Set
15+
from typing import Tuple
16+
from typing import TYPE_CHECKING
17+
from typing import Union
2018

2119
from . import _tracing
22-
from ._result import _Result
2320
from ._callers import _multicall
24-
from ._hooks import (
25-
HookImpl,
26-
HookSpec,
27-
_HookCaller,
28-
_SubsetHookCaller,
29-
_HookImplFunction,
30-
_HookRelay,
31-
_Namespace,
32-
normalize_hookimpl_opts,
33-
_Plugin,
34-
)
21+
from ._hooks import _HookCaller
22+
from ._hooks import _HookImplFunction
23+
from ._hooks import _HookRelay
24+
from ._hooks import _Namespace
25+
from ._hooks import _Plugin
26+
from ._hooks import _SubsetHookCaller
27+
from ._hooks import HookImpl
28+
from ._hooks import HookSpec
29+
from ._hooks import normalize_hookimpl_opts
30+
from ._result import _Result
3531

3632
if sys.version_info >= (3, 8):
3733
from importlib import metadata as importlib_metadata

src/pluggy/_result.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
"""
44
import sys
55
from types import TracebackType
6-
from typing import (
7-
Callable,
8-
cast,
9-
Generator,
10-
Generic,
11-
Optional,
12-
Tuple,
13-
Type,
14-
TYPE_CHECKING,
15-
TypeVar,
16-
)
6+
from typing import Callable
7+
from typing import cast
8+
from typing import Generator
9+
from typing import Generic
10+
from typing import Optional
11+
from typing import Tuple
12+
from typing import Type
13+
from typing import TYPE_CHECKING
14+
from typing import TypeVar
1715

1816
if TYPE_CHECKING:
1917
from typing import NoReturn

testing/benchmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
Benchmarking and performance tests.
33
"""
44
import pytest
5-
from pluggy import HookspecMarker, HookimplMarker, PluginManager
6-
from pluggy._hooks import HookImpl
5+
6+
from pluggy import HookimplMarker
7+
from pluggy import HookspecMarker
8+
from pluggy import PluginManager
79
from pluggy._callers import _multicall
10+
from pluggy._hooks import HookImpl
811

912

1013
hookspec = HookspecMarker("example")

0 commit comments

Comments
 (0)