Skip to content

Commit a742ef5

Browse files
authored
Merge branch 'main' into patch-2
2 parents 75d6353 + 64f3647 commit a742ef5

19 files changed

+386
-207
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily

.github/workflows/tox.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1-
name: tox
1+
name: tests
22
on:
33
pull_request:
4-
branches: [master]
54
push:
6-
branches: [master]
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
9+
cancel-in-progress: true
10+
11+
env:
12+
FORCE_COLOR: "1"
13+
TOX_TESTENV_PASSENV: "FORCE_COLOR"
14+
MIN_PYTHON_VERSION: "3.9"
15+
DEFAULT_PYTHON_VERSION: "3.13"
16+
717
jobs:
8-
tox-jobs:
18+
tests:
919
strategy:
1020
fail-fast: false
1121
matrix:
1222
os: [ubuntu-latest] # [macos-latest, ubuntu-latest, windows-latest]
13-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] # ,pypy3.9,pep8,py3pep8,setuppy,manifest]
23+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1424
runs-on: ${{ matrix.os }}
1525
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions/setup-python@v4
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
persist-credentials: false
29+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
1830
with:
1931
python-version: ${{ matrix.python-version }}
2032
- run: pip install --upgrade pip
2133
- run: pip install tox
2234
- run: tox -e py
35+
lint:
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
job: [pep8, release-check]
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
persist-credentials: false
45+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
46+
with:
47+
python-version: 3.x
48+
- run: pip install --upgrade pip
49+
- run: pip install tox
50+
- run: tox -e ${{ matrix.job }}

.pre-commit-config.yaml

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,70 @@
11
# To enable this pre-commit hook run:
22
# `pip install pre-commit` or `brew install pre-commit`
33
# Then run `pre-commit install`
4+
exclude: 'tests\/test_cases'
45

56
# Learn more about this config here: https://pre-commit.com/
67
repos:
78
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.4.0
9+
rev: v5.0.0
910
hooks:
10-
- id: check-yaml
11-
- id: detect-private-key
12-
- id: end-of-file-fixer
13-
- id: mixed-line-ending
14-
- id: trailing-whitespace
11+
- id: check-added-large-files
12+
- id: check-toml
13+
types: [toml]
14+
- id: check-yaml
15+
types: [yaml]
16+
- id: end-of-file-fixer
17+
types: [text]
18+
stages: [pre-commit, pre-push, manual]
19+
- id: trailing-whitespace
20+
types: [text]
21+
stages: [pre-commit, pre-push, manual]
22+
- id: detect-private-key
23+
- id: mixed-line-ending
1524

1625
- repo: https://github.com/codespell-project/codespell
17-
rev: v2.2.2
26+
rev: v2.4.1
1827
hooks:
19-
- id: codespell
20-
additional_dependencies:
21-
- tomli
28+
- id: codespell
29+
additional_dependencies:
30+
- tomli
2231

2332
- repo: https://github.com/asottile/pyupgrade
24-
rev: v3.2.3
33+
rev: v3.20.0
2534
hooks:
26-
- id: pyupgrade
27-
args:
28-
- --py37-plus
35+
- id: pyupgrade
36+
args: [--py39-plus]
37+
38+
- repo: https://github.com/PyCQA/isort
39+
rev: 6.0.1
40+
hooks:
41+
- id: isort
42+
43+
- repo: https://github.com/psf/black
44+
rev: 25.1.0
45+
hooks:
46+
- id: black
47+
48+
# - repo: https://github.com/pre-commit/mirrors-mypy
49+
# rev: v1.16.0
50+
# hooks:
51+
# - id: mypy
52+
# additional_dependencies:
53+
# - types-python-dateutil
54+
# - types-requests
55+
# exclude: ^(docs/|tests/)
56+
# - repo: https://github.com/jorisroovers/gitlint
57+
# rev: v0.19.1
58+
# hooks:
59+
# - id: gitlint
60+
#
61+
- repo: https://github.com/asottile/setup-cfg-fmt
62+
rev: v2.8.0
63+
hooks:
64+
- id: setup-cfg-fmt
65+
args: [--min-py3-version, '3.9']
66+
67+
- repo: https://github.com/gitleaks/gitleaks
68+
rev: v8.27.2
69+
hooks:
70+
- id: gitleaks

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
custom styles (that use the nodes directly). This also drops the
4141
asttokens dependency as it is no longer required.
4242
* Understand the existence of namespaced packages, thereby allowing
43-
different namespaced pacakages to be defined as local or third party.
43+
different namespaced packages to be defined as local or third party.
4444

4545
0.15 2017-11-06
4646
---------------

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include .pre-commit-config.yaml
12
include CHANGELOG.rst
23
include COPYING
34
include README.md

flake8_import_order/__about__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
__all__ = [
2-
"__title__", "__summary__", "__uri__", "__version__", "__author__",
3-
"__email__", "__license__", "__copyright__", '__maintainer__',
4-
'__maintainer_email__',
2+
"__title__",
3+
"__summary__",
4+
"__uri__",
5+
"__version__",
6+
"__author__",
7+
"__email__",
8+
"__license__",
9+
"__copyright__",
10+
"__maintainer__",
11+
"__maintainer_email__",
512
]
613

714
__title__ = "flake8-import-order"
@@ -15,8 +22,8 @@
1522
__author__ = "Alex Stapleton"
1623
__email__ = "alexs@prol.etari.at"
1724

18-
__maintainer__ = 'Phil Jones'
19-
__maintainer_email__ = 'philip.graham.jones+flake8-import@gmail.com'
25+
__maintainer__ = "Phil Jones"
26+
__maintainer_email__ = "philip.graham.jones+flake8-import@gmail.com"
2027

2128
__license__ = "LGPLv3"
2229
__copyright__ = "Copyright 2013-2016 %s" % __author__

flake8_import_order/__init__.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,39 @@
33
from collections import namedtuple
44
from enum import IntEnum
55

6-
from .__about__ import (
7-
__author__, __copyright__, __email__, __license__, __summary__, __title__,
8-
__uri__, __version__,
9-
)
106
if sys.version_info >= (3, 10):
117
STDLIB_NAMES = sys.stdlib_module_names | {"__main__", "test"}
128
else:
139
from .stdlib_list import STDLIB_NAMES
1410

11+
from .__about__ import __author__
12+
from .__about__ import __copyright__
13+
from .__about__ import __email__
14+
from .__about__ import __license__
15+
from .__about__ import __summary__
16+
from .__about__ import __title__
17+
from .__about__ import __uri__
18+
from .__about__ import __version__
19+
20+
1521
__all__ = [
16-
"__title__", "__summary__", "__uri__", "__version__", "__author__",
17-
"__email__", "__license__", "__copyright__",
22+
"__title__",
23+
"__summary__",
24+
"__uri__",
25+
"__version__",
26+
"__author__",
27+
"__email__",
28+
"__license__",
29+
"__copyright__",
1830
]
1931

20-
DEFAULT_IMPORT_ORDER_STYLE = 'cryptography'
32+
DEFAULT_IMPORT_ORDER_STYLE = "cryptography"
2133

2234
ClassifiedImport = namedtuple(
23-
'ClassifiedImport',
24-
['type', 'is_from', 'modules', 'names', 'lineno', 'level', 'package'],
35+
"ClassifiedImport",
36+
["type", "is_from", "modules", "names", "lineno", "level", "package"],
2537
)
26-
NewLine = namedtuple('NewLine', ['lineno'])
38+
NewLine = namedtuple("NewLine", ["lineno"])
2739

2840

2941
class ImportType(IntEnum):
@@ -52,7 +64,7 @@ def get_package_names(name):
5264
package_names = [last_package_name]
5365

5466
for part in reversed(parts):
55-
last_package_name = f'{last_package_name}.{part}'
67+
last_package_name = f"{last_package_name}.{part}"
5668
package_names.append(last_package_name)
5769

5870
return package_names
@@ -83,22 +95,31 @@ def visit_Import(self, node): # noqa: N802
8395
else:
8496
type_ = ImportType.MIXED
8597
classified_import = ClassifiedImport(
86-
type_, False, modules, [], node.lineno, 0,
98+
type_,
99+
False,
100+
modules,
101+
[],
102+
node.lineno,
103+
0,
87104
root_package_name(modules[0]),
88105
)
89106
self.imports.append(classified_import)
90107

91108
def visit_ImportFrom(self, node): # noqa: N802
92109
if node.col_offset == 0:
93-
module = node.module or ''
110+
module = node.module or ""
94111
if node.level > 0:
95112
type_ = ImportType.APPLICATION_RELATIVE
96113
else:
97114
type_ = self._classify_type(module)
98115
names = [alias.name for alias in node.names]
99116
classified_import = ClassifiedImport(
100-
type_, True, [module], names,
101-
node.lineno, node.level,
117+
type_,
118+
True,
119+
[module],
120+
names,
121+
node.lineno,
122+
node.level,
102123
root_package_name(module),
103124
)
104125
self.imports.append(classified_import)

flake8_import_order/checker.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import pycodestyle
66

7-
from flake8_import_order import ImportVisitor, NewLine
7+
from flake8_import_order import ImportVisitor
8+
from flake8_import_order import NewLine
89
from flake8_import_order.styles import lookup_entry_point
910

10-
DEFAULT_IMPORT_ORDER_STYLE = 'cryptography'
11+
DEFAULT_IMPORT_ORDER_STYLE = "cryptography"
1112
NOQA_INLINE_REGEXP = re.compile(
1213
# We're looking for items that look like this:
1314
# ``# noqa``
@@ -18,11 +19,11 @@
1819
# We do not care about the ``: `` that follows ``noqa``
1920
# We do not care about the casing of ``noqa``
2021
# We want a comma-separated list of errors
21-
r'# noqa(?:: (?P<codes>([A-Z][0-9]+(?:[,\s]+)?)+))?',
22-
re.IGNORECASE
22+
r"# noqa(?:: (?P<codes>([A-Z][0-9]+(?:[,\s]+)?)+))?",
23+
re.IGNORECASE,
2324
)
24-
COMMA_SEPARATED_LIST_RE = re.compile(r'[,\s]')
25-
BLANK_LINE_RE = re.compile(r'\s*\n')
25+
COMMA_SEPARATED_LIST_RE = re.compile(r"[,\s]")
26+
BLANK_LINE_RE = re.compile(r"\s*\n")
2627

2728

2829
class ImportOrderChecker:
@@ -42,7 +43,7 @@ def load_file(self):
4243
self.lines = pycodestyle.readlines(self.filename)
4344

4445
if self.tree is None:
45-
self.tree = ast.parse(''.join(self.lines))
46+
self.tree = ast.parse("".join(self.lines))
4647

4748
def error(self, error):
4849
return error
@@ -52,19 +53,19 @@ def check_order(self):
5253
self.load_file()
5354

5455
try:
55-
style_entry_point = self.options['import_order_style']
56+
style_entry_point = self.options["import_order_style"]
5657
except KeyError:
5758
style_entry_point = lookup_entry_point(DEFAULT_IMPORT_ORDER_STYLE)
5859
style_cls = style_entry_point.load()
5960

6061
if style_cls.accepts_application_package_names:
6162
visitor = self.visitor_class(
62-
self.options.get('application_import_names', []),
63-
self.options.get('application_package_names', []),
63+
self.options.get("application_import_names", []),
64+
self.options.get("application_package_names", []),
6465
)
6566
else:
6667
visitor = self.visitor_class(
67-
self.options.get('application_import_names', []),
68+
self.options.get("application_import_names", []),
6869
[],
6970
)
7071
visitor.visit(self.tree)
@@ -90,7 +91,7 @@ def error_is_ignored(self, error):
9091
if noqa_match is None:
9192
return False
9293

93-
codes_str = noqa_match.group('codes')
94+
codes_str = noqa_match.group("codes")
9495
if codes_str is None:
9596
return True
9697

0 commit comments

Comments
 (0)