Skip to content

Commit 7fc9af0

Browse files
Replace reorder-python-imports and flake8-import-order with isort, along with some other minor changes.
- Update .pre-commit-config.yaml and tox.ini in accordance to the above. - Run `pre-commit autoupdate` while I'm at it. Can be reverted if need be. - Somewhat centralize black and isort config in pyproject.toml to avoid having to keep it in sync in multiple places.
1 parent c923049 commit 7fc9af0

17 files changed

+40
-31
lines changed

.pre-commit-config.yaml

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-yaml
66
- id: debug-statements
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
9-
- repo: https://github.com/asottile/reorder-python-imports
10-
rev: v3.12.0
9+
- repo: https://github.com/pycqa/isort
10+
rev: 5.13.2
1111
hooks:
12-
- id: reorder-python-imports
13-
args: [--application-directories, '.:src', --py37-plus]
12+
- id: isort
1413
- repo: https://github.com/psf/black
15-
rev: 23.12.1
14+
rev: 24.4.2
1615
hooks:
1716
- id: black
18-
args: [--line-length=79]
1917
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.15.0
18+
rev: v3.16.0
2119
hooks:
2220
- id: pyupgrade
23-
args: [--py37-plus]
21+
args: [--py38-plus]
2422
- repo: https://github.com/pycqa/flake8
25-
rev: 7.0.0
23+
rev: 7.1.0
2624
hooks:
2725
- id: flake8
2826
exclude: ^(tests/|docs/|setup.py)
2927
additional_dependencies:
3028
- flake8-docstrings
31-
- flake8-import-order
3229
- repo: https://github.com/asottile/setup-cfg-fmt
3330
rev: v2.5.0
3431
hooks:

pyproject.toml

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
[tool.black]
2+
line-length = 79
3+
target-version = ["py38"]
4+
5+
[tool.isort]
6+
profile = "black"
7+
line_length = 79
8+
force_single_line = true
9+
110
[tool.pyright]
211
include = ["src/rfc3986"]
312
ignore = ["tests"]

src/rfc3986/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
:copyright: (c) 2014 Rackspace
2020
:license: Apache v2.0, see LICENSE for details
2121
"""
22-
from .api import iri_reference
2322
from .api import IRIReference
23+
from .api import URIReference
24+
from .api import iri_reference
2425
from .api import is_valid_uri
2526
from .api import normalize_uri
2627
from .api import uri_reference
27-
from .api import URIReference
2828
from .api import urlparse
2929
from .parseresult import ParseResult
3030

src/rfc3986/_mixin.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the implementation of the URIMixin class."""
2+
23
import typing as t
34
import warnings
45

src/rfc3986/compat.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
def to_str( # noqa: D103
2525
b: t.Union[str, bytes],
2626
encoding: str = "utf-8",
27-
) -> str:
28-
...
27+
) -> str: ...
2928

3029

3130
@t.overload
@@ -47,8 +46,7 @@ def to_str(
4746
def to_bytes( # noqa: D103
4847
s: t.Union[str, bytes],
4948
encoding: str = "utf-8",
50-
) -> bytes:
51-
...
49+
) -> bytes: ...
5250

5351

5452
@t.overload

src/rfc3986/exceptions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Exceptions module for rfc3986."""
2+
23
import typing as t
34

45
from . import compat

src/rfc3986/iri.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the implementation of the IRIReference class."""
2+
23
# Copyright (c) 2014 Rackspace
34
# Copyright (c) 2015 Ian Stapleton Cordasco
45
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +23,6 @@
2223
from . import uri
2324
from ._typing_compat import Self as _Self
2425

25-
2626
try:
2727
import idna
2828
except ImportError: # pragma: no cover

src/rfc3986/parseresult.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class ParseResultMixin(t.Generic[t.AnyStr]):
4444
encoding: str
4545

4646
@property
47-
def authority(self) -> t.Optional[t.AnyStr]:
48-
...
47+
def authority(self) -> t.Optional[t.AnyStr]: ...
4948

5049
def _generate_authority(
5150
self,

src/rfc3986/uri.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the implementation of the URIReference class."""
2+
23
# Copyright (c) 2014 Rackspace
34
# Copyright (c) 2015 Ian Stapleton Cordasco
45
# Licensed under the Apache License, Version 2.0 (the "License");

src/rfc3986/validators.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def __init__(self) -> None:
6767
"query": False,
6868
"fragment": False,
6969
}
70-
self.validated_components: t.Dict[
71-
str, bool
72-
] = self.required_components.copy()
70+
self.validated_components: t.Dict[str, bool] = (
71+
self.required_components.copy()
72+
)
7373

7474
def allow_schemes(self, *schemes: str) -> _Self:
7575
"""Require the scheme to be one of the provided schemes.

tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
from rfc3986.api import URIReference
12
from rfc3986.api import is_valid_uri
23
from rfc3986.api import normalize_uri
34
from rfc3986.api import uri_reference
4-
from rfc3986.api import URIReference
55

66

77
def test_uri_reference():

tests/test_builder.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
import pytest
2121

22-
from rfc3986 import builder, uri_reference
22+
from rfc3986 import builder
23+
from rfc3986 import uri_reference
2324

2425

2526
def test_builder_default():

tests/test_parseresult.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
import pytest
1515

1616
import rfc3986
17-
from . import base
1817
from rfc3986 import exceptions
1918
from rfc3986 import parseresult as pr
2019

20+
from . import base
21+
2122
INVALID_PORTS = [
2223
"443:80",
2324
"443:80:443",

tests/test_unicode_support.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from rfc3986 import uri_reference
66
from rfc3986 import urlparse
77

8-
98
SNOWMAN = b"\xe2\x98\x83"
109
SNOWMAN_PARAMS = b"http://example.com?utf8=" + SNOWMAN
1110
SNOWMAN_HOST = b"http://" + SNOWMAN + b".com"

tests/test_uri.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pytest
22

3-
from . import base
43
from rfc3986.exceptions import InvalidAuthority
54
from rfc3986.exceptions import ResolutionError
65
from rfc3986.misc import URI_MATCHER
76
from rfc3986.uri import URIReference
87

8+
from . import base
9+
910

1011
@pytest.fixture
1112
def scheme_and_path_uri():

tests/test_validators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the validators module."""
2+
23
import pytest
34

45
import rfc3986

tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ basepython = python3
2525
skip_install = true
2626
deps =
2727
{[testenv:flake8]deps}
28+
isort
2829
black
2930
commands =
30-
black -l 79 {env:BLACK_ARGS:} -t py37 src/rfc3986 tests/
31+
isort src/rfc3986 tests/
32+
black {env:BLACK_ARGS:} src/rfc3986 tests/
3133
{[testenv:flake8]commands}
3234

3335
[testenv:flake8]
@@ -36,7 +38,6 @@ skip_install = true
3638
deps =
3739
flake8
3840
flake8-docstrings
39-
flake8-import-order
4041
commands = flake8 {posargs} src/rfc3986
4142

4243
[testenv:typing]
@@ -92,4 +93,3 @@ exclude =
9293
.cache,
9394
.eggs
9495
max-complexity = 10
95-
import-order-style = google

0 commit comments

Comments
 (0)