Skip to content

Commit 1d8b74b

Browse files
authored
Merge branch 'main' into lint-type-checking-block
2 parents ce840fb + 64f3647 commit 1d8b74b

18 files changed

+347
-176
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: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
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:
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']
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
23-
tox-jobs:
35+
lint:
2436
strategy:
2537
fail-fast: false
2638
matrix:
27-
job: [manifest, pep8, setuppy]
39+
job: [pep8, release-check]
2840
runs-on: ubuntu-latest
2941
steps:
30-
- uses: actions/checkout@v3
31-
- uses: actions/setup-python@v4
42+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
persist-credentials: false
45+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3246
with:
3347
python-version: 3.x
3448
- run: pip install --upgrade pip

.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
---------------

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: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,35 @@
22
from collections import namedtuple
33
from enum import IntEnum
44

5-
from .__about__ import (
6-
__author__, __copyright__, __email__, __license__, __summary__, __title__,
7-
__uri__, __version__,
8-
)
5+
from .__about__ import __author__
6+
from .__about__ import __copyright__
7+
from .__about__ import __email__
8+
from .__about__ import __license__
9+
from .__about__ import __summary__
10+
from .__about__ import __title__
11+
from .__about__ import __uri__
12+
from .__about__ import __version__
913
from .stdlib_list import STDLIB_NAMES
1014

1115
__all__ = [
12-
"__title__", "__summary__", "__uri__", "__version__", "__author__",
13-
"__email__", "__license__", "__copyright__",
16+
"__title__",
17+
"__summary__",
18+
"__uri__",
19+
"__version__",
20+
"__author__",
21+
"__email__",
22+
"__license__",
23+
"__copyright__",
1424
]
1525

16-
DEFAULT_IMPORT_ORDER_STYLE = 'cryptography'
26+
DEFAULT_IMPORT_ORDER_STYLE = "cryptography"
1727

1828
ClassifiedImport = namedtuple(
1929
'ClassifiedImport',
2030
['type', 'is_from', 'modules', 'names', 'lineno', 'level', 'package',
2131
'type_checking'],
2232
)
23-
NewLine = namedtuple('NewLine', ['lineno'])
33+
NewLine = namedtuple("NewLine", ["lineno"])
2434

2535

2636
class ImportType(IntEnum):
@@ -49,7 +59,7 @@ def get_package_names(name):
4959
package_names = [last_package_name]
5060

5161
for part in reversed(parts):
52-
last_package_name = f'{last_package_name}.{part}'
62+
last_package_name = f"{last_package_name}.{part}"
5363
package_names.append(last_package_name)
5464

5565
return package_names
@@ -85,7 +95,12 @@ def visit_Import(self, node): # noqa: N802
8595
else:
8696
type_ = ImportType.MIXED
8797
classified_import = ClassifiedImport(
88-
type_, False, modules, [], node.lineno, 0,
98+
type_,
99+
False,
100+
modules,
101+
[],
102+
node.lineno,
103+
0,
89104
root_package_name(modules[0]),
90105
self._type_checking_import(node),
91106
)
@@ -100,8 +115,12 @@ def visit_ImportFrom(self, node): # noqa: N802
100115
type_ = self._classify_type(module)
101116
names = [alias.name for alias in node.names]
102117
classified_import = ClassifiedImport(
103-
type_, True, [module], names,
104-
node.lineno, node.level,
118+
type_,
119+
True,
120+
[module],
121+
names,
122+
node.lineno,
123+
node.level,
105124
root_package_name(module),
106125
self._type_checking_import(node),
107126
)

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

flake8_import_order/flake8_linter.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import optparse
22

33
from flake8_import_order import __version__
4-
from flake8_import_order.checker import (
5-
DEFAULT_IMPORT_ORDER_STYLE, ImportOrderChecker,
6-
)
7-
from flake8_import_order.styles import list_entry_points, lookup_entry_point
4+
from flake8_import_order.checker import DEFAULT_IMPORT_ORDER_STYLE
5+
from flake8_import_order.checker import ImportOrderChecker
6+
from flake8_import_order.styles import list_entry_points
7+
from flake8_import_order.styles import lookup_entry_point
88

99

1010
class Linter(ImportOrderChecker):
@@ -99,9 +99,9 @@ def register_opt(parser, *args, **kwargs):
9999
parser.add_option(*args, **kwargs)
100100
except (optparse.OptionError, TypeError):
101101
# Flake8 2.x registration
102-
parse_from_config = kwargs.pop('parse_from_config', False)
103-
kwargs.pop('comma_separated_list', False)
104-
kwargs.pop('normalize_paths', False)
102+
parse_from_config = kwargs.pop("parse_from_config", False)
103+
kwargs.pop("comma_separated_list", False)
104+
kwargs.pop("normalize_paths", False)
105105
parser.add_option(*args, **kwargs)
106106
if parse_from_config:
107-
parser.config_options.append(args[-1].lstrip('-'))
107+
parser.config_options.append(args[-1].lstrip("-"))

0 commit comments

Comments
 (0)