Skip to content

Commit 28d2fa0

Browse files
authored
Use isort (#377)
Simplifies refactoring work by letting the tools handle import formatting.
1 parent 353f270 commit 28d2fa0

File tree

14 files changed

+51
-30
lines changed

14 files changed

+51
-30
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ repos:
2323
hooks:
2424
- id: black
2525

26+
- repo: https://github.com/PyCQA/isort
27+
rev: 5.6.4
28+
hooks:
29+
- id: isort
30+
2631
- repo: https://gitlab.com/PyCQA/flake8
2732
rev: "3.7.8"
2833
hooks:

noxfile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# mypy: disallow-untyped-defs=False, disallow-untyped-calls=False
22

3-
import time
4-
import re
5-
import os
6-
import sys
3+
import contextlib
4+
import datetime
5+
import difflib
76
import glob
7+
import os
8+
import re
89
import shutil
9-
import difflib
10+
import subprocess
11+
import sys
1012
import tempfile
1113
import textwrap
12-
import datetime
13-
import contextlib
14-
import subprocess
14+
import time
1515
from pathlib import Path
1616

1717
import nox

packaging/markers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
import platform
99
import sys
1010

11-
from pyparsing import ParseException, ParseResults, stringStart, stringEnd
12-
from pyparsing import ZeroOrMore, Group, Forward, QuotedString
13-
from pyparsing import Literal as L # noqa
11+
from pyparsing import ( # noqa: N817
12+
Forward,
13+
Group,
14+
Literal as L,
15+
ParseException,
16+
ParseResults,
17+
QuotedString,
18+
ZeroOrMore,
19+
stringEnd,
20+
stringStart,
21+
)
1422

1523
from ._compat import string_types
1624
from ._typing import TYPE_CHECKING
17-
from .specifiers import Specifier, InvalidSpecifier
25+
from .specifiers import InvalidSpecifier, Specifier
1826

1927
if TYPE_CHECKING: # pragma: no cover
2028
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

packaging/requirements.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
# for complete details.
44
from __future__ import absolute_import, division, print_function
55

6-
import string
76
import re
7+
import string
88
import sys
99

10-
from pyparsing import stringStart, stringEnd, originalTextFor, ParseException
11-
from pyparsing import ZeroOrMore, Word, Optional, Regex, Combine
12-
from pyparsing import Literal as L # noqa
10+
from pyparsing import ( # noqa: N817
11+
Combine,
12+
Literal as L,
13+
Optional,
14+
ParseException,
15+
Regex,
16+
Word,
17+
ZeroOrMore,
18+
originalTextFor,
19+
stringEnd,
20+
stringStart,
21+
)
1322

1423
from ._typing import TYPE_CHECKING
1524
from .markers import MARKER_EXPR, Marker

packaging/specifiers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from ._compat import string_types, with_metaclass
1313
from ._typing import TYPE_CHECKING
1414
from .utils import canonicalize_version
15-
from .version import Version, LegacyVersion, parse
15+
from .version import LegacyVersion, Version, parse
1616

1717
if TYPE_CHECKING: # pragma: no cover
18-
from typing import List, Dict, Union, Iterable, Iterator, Optional, Callable, Tuple
18+
from typing import Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
1919

2020
ParsedVersion = Union[Version, LegacyVersion]
2121
UnparsedVersion = Union[Version, LegacyVersion, str]

packaging/tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
if TYPE_CHECKING: # pragma: no cover
2929
from typing import (
30+
IO,
3031
Dict,
3132
FrozenSet,
32-
IO,
3333
Iterable,
3434
Iterator,
3535
List,

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
[bdist_wheel]
22
universal=1
3+
4+
[isort]
5+
profile = black
6+
combine_as_imports = true

tasks/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
# for complete details.
44

5-
import json
65
import itertools
6+
import json
77
import os.path
88

99
try:

tasks/paths.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import os.path
66

7-
87
PROJECT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
98

109
CACHE = os.path.join(PROJECT, ".cache")

tests/test_markers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
import pytest
1414

1515
from packaging.markers import (
16-
Node,
1716
InvalidMarker,
17+
Marker,
18+
Node,
1819
UndefinedComparison,
1920
UndefinedEnvironmentName,
20-
Marker,
2121
default_environment,
2222
format_full_version,
2323
)
2424

25-
2625
VARIABLES = [
2726
"extra",
2827
"implementation_name",

0 commit comments

Comments
 (0)