Skip to content

Commit

Permalink
Replace reorder-python-imports and flake8-import-order with isort, al…
Browse files Browse the repository at this point in the history
…ong 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.
  • Loading branch information
Sachaa-Thanasius committed Jul 3, 2024
1 parent c923049 commit 7fc9af0
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 31 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions src/rfc3986/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/rfc3986/_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the implementation of the URIMixin class."""

import typing as t
import warnings

Expand Down
6 changes: 2 additions & 4 deletions src/rfc3986/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
def to_str( # noqa: D103
b: t.Union[str, bytes],
encoding: str = "utf-8",
) -> str:
...
) -> str: ...


@t.overload
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/rfc3986/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exceptions module for rfc3986."""

import typing as t

from . import compat
Expand Down
2 changes: 1 addition & 1 deletion src/rfc3986/iri.py
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -22,7 +23,6 @@
from . import uri
from ._typing_compat import Self as _Self


try:
import idna
except ImportError: # pragma: no cover
Expand Down
3 changes: 1 addition & 2 deletions src/rfc3986/parseresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/rfc3986/uri.py
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
6 changes: 3 additions & 3 deletions src/rfc3986/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_parseresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion tests/test_unicode_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_uri.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
1 change: 1 addition & 0 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the validators module."""

import pytest

import rfc3986
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -36,7 +38,6 @@ skip_install = true
deps =
flake8
flake8-docstrings
flake8-import-order
commands = flake8 {posargs} src/rfc3986

[testenv:typing]
Expand Down Expand Up @@ -92,4 +93,3 @@ exclude =
.cache,
.eggs
max-complexity = 10
import-order-style = google

0 comments on commit 7fc9af0

Please sign in to comment.