diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 098a010..405e529 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,34 +1,31 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-yaml - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/asottile/reorder-python-imports - rev: v3.12.0 +- repo: https://github.com/pycqa/isort + rev: 5.13.2 hooks: - - id: reorder-python-imports - args: [--application-directories, '.:src', --py37-plus] + - id: isort - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.4.2 hooks: - id: black - args: [--line-length=79] - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.16.0 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.1.0 hooks: - id: flake8 exclude: ^(tests/|docs/|setup.py) additional_dependencies: - flake8-docstrings - - flake8-import-order - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.5.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 7cb2895..f2ffbab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,12 @@ +[tool.black] +line-length = 79 +target-version = ["py38"] + +[tool.isort] +profile = "black" +line_length = 79 +force_single_line = true + [tool.pyright] include = ["src/rfc3986"] ignore = ["tests"] diff --git a/src/rfc3986/__init__.py b/src/rfc3986/__init__.py index bc2da11..e71de1f 100644 --- a/src/rfc3986/__init__.py +++ b/src/rfc3986/__init__.py @@ -19,12 +19,12 @@ :copyright: (c) 2014 Rackspace :license: Apache v2.0, see LICENSE for details """ -from .api import iri_reference from .api import IRIReference +from .api import URIReference +from .api import iri_reference from .api import is_valid_uri from .api import normalize_uri from .api import uri_reference -from .api import URIReference from .api import urlparse from .parseresult import ParseResult diff --git a/src/rfc3986/_mixin.py b/src/rfc3986/_mixin.py index 1c4d067..b03b772 100644 --- a/src/rfc3986/_mixin.py +++ b/src/rfc3986/_mixin.py @@ -1,4 +1,5 @@ """Module containing the implementation of the URIMixin class.""" + import typing as t import warnings diff --git a/src/rfc3986/compat.py b/src/rfc3986/compat.py index 5d5146c..b66e1db 100644 --- a/src/rfc3986/compat.py +++ b/src/rfc3986/compat.py @@ -24,8 +24,7 @@ def to_str( # noqa: D103 b: t.Union[str, bytes], encoding: str = "utf-8", -) -> str: - ... +) -> str: ... @t.overload @@ -47,8 +46,7 @@ def to_str( def to_bytes( # noqa: D103 s: t.Union[str, bytes], encoding: str = "utf-8", -) -> bytes: - ... +) -> bytes: ... @t.overload diff --git a/src/rfc3986/exceptions.py b/src/rfc3986/exceptions.py index ecdd666..d0e853b 100644 --- a/src/rfc3986/exceptions.py +++ b/src/rfc3986/exceptions.py @@ -1,4 +1,5 @@ """Exceptions module for rfc3986.""" + import typing as t from . import compat diff --git a/src/rfc3986/iri.py b/src/rfc3986/iri.py index e2a292e..205221e 100644 --- a/src/rfc3986/iri.py +++ b/src/rfc3986/iri.py @@ -1,4 +1,5 @@ """Module containing the implementation of the IRIReference class.""" + # Copyright (c) 2014 Rackspace # Copyright (c) 2015 Ian Stapleton Cordasco # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +23,6 @@ from . import uri from ._typing_compat import Self as _Self - try: import idna except ImportError: # pragma: no cover diff --git a/src/rfc3986/parseresult.py b/src/rfc3986/parseresult.py index 1241d64..80cc300 100644 --- a/src/rfc3986/parseresult.py +++ b/src/rfc3986/parseresult.py @@ -44,8 +44,7 @@ class ParseResultMixin(t.Generic[t.AnyStr]): encoding: str @property - def authority(self) -> t.Optional[t.AnyStr]: - ... + def authority(self) -> t.Optional[t.AnyStr]: ... def _generate_authority( self, diff --git a/src/rfc3986/uri.py b/src/rfc3986/uri.py index 235a89b..e382498 100644 --- a/src/rfc3986/uri.py +++ b/src/rfc3986/uri.py @@ -1,4 +1,5 @@ """Module containing the implementation of the URIReference class.""" + # Copyright (c) 2014 Rackspace # Copyright (c) 2015 Ian Stapleton Cordasco # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/rfc3986/validators.py b/src/rfc3986/validators.py index fe22ba4..862663a 100644 --- a/src/rfc3986/validators.py +++ b/src/rfc3986/validators.py @@ -67,9 +67,9 @@ def __init__(self) -> None: "query": False, "fragment": False, } - self.validated_components: t.Dict[ - str, bool - ] = self.required_components.copy() + self.validated_components: t.Dict[str, bool] = ( + self.required_components.copy() + ) def allow_schemes(self, *schemes: str) -> _Self: """Require the scheme to be one of the provided schemes. diff --git a/tests/test_api.py b/tests/test_api.py index 3b310ed..dacae72 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,7 +1,7 @@ +from rfc3986.api import URIReference from rfc3986.api import is_valid_uri from rfc3986.api import normalize_uri from rfc3986.api import uri_reference -from rfc3986.api import URIReference def test_uri_reference(): diff --git a/tests/test_builder.py b/tests/test_builder.py index 338b3a2..fb6ec3c 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -19,7 +19,8 @@ import pytest -from rfc3986 import builder, uri_reference +from rfc3986 import builder +from rfc3986 import uri_reference def test_builder_default(): diff --git a/tests/test_parseresult.py b/tests/test_parseresult.py index 3e94138..5788448 100644 --- a/tests/test_parseresult.py +++ b/tests/test_parseresult.py @@ -14,10 +14,11 @@ import pytest import rfc3986 -from . import base from rfc3986 import exceptions from rfc3986 import parseresult as pr +from . import base + INVALID_PORTS = [ "443:80", "443:80:443", diff --git a/tests/test_unicode_support.py b/tests/test_unicode_support.py index 6a35244..8c388fb 100644 --- a/tests/test_unicode_support.py +++ b/tests/test_unicode_support.py @@ -5,7 +5,6 @@ from rfc3986 import uri_reference from rfc3986 import urlparse - SNOWMAN = b"\xe2\x98\x83" SNOWMAN_PARAMS = b"http://example.com?utf8=" + SNOWMAN SNOWMAN_HOST = b"http://" + SNOWMAN + b".com" diff --git a/tests/test_uri.py b/tests/test_uri.py index 1c5b0ff..06ac2a8 100644 --- a/tests/test_uri.py +++ b/tests/test_uri.py @@ -1,11 +1,12 @@ import pytest -from . import base from rfc3986.exceptions import InvalidAuthority from rfc3986.exceptions import ResolutionError from rfc3986.misc import URI_MATCHER from rfc3986.uri import URIReference +from . import base + @pytest.fixture def scheme_and_path_uri(): diff --git a/tests/test_validators.py b/tests/test_validators.py index 0ec7449..2bab3a1 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -1,4 +1,5 @@ """Tests for the validators module.""" + import pytest import rfc3986 diff --git a/tox.ini b/tox.ini index 539879a..7099d8b 100644 --- a/tox.ini +++ b/tox.ini @@ -25,9 +25,11 @@ basepython = python3 skip_install = true deps = {[testenv:flake8]deps} + isort black commands = - black -l 79 {env:BLACK_ARGS:} -t py37 src/rfc3986 tests/ + isort src/rfc3986 tests/ + black {env:BLACK_ARGS:} src/rfc3986 tests/ {[testenv:flake8]commands} [testenv:flake8] @@ -36,7 +38,6 @@ skip_install = true deps = flake8 flake8-docstrings - flake8-import-order commands = flake8 {posargs} src/rfc3986 [testenv:typing] @@ -92,4 +93,3 @@ exclude = .cache, .eggs max-complexity = 10 -import-order-style = google