From b92d6f89f6df78fb8d17d6b76a88995d54b8affc Mon Sep 17 00:00:00 2001 From: NiceAesth Date: Sat, 10 Feb 2024 02:33:35 +0200 Subject: [PATCH] chore: actually use `isort` --- .pre-commit-config.yaml | 9 ++++----- aiordr/__init__.py | 1 - aiordr/client.py | 7 ++++--- aiordr/exceptions.py | 1 + aiordr/helpers.py | 1 + aiordr/models/__init__.py | 2 +- aiordr/models/base.py | 1 + aiordr/models/errorcode.py | 1 + aiordr/models/events.py | 1 + aiordr/models/render.py | 1 + aiordr/models/renderserver.py | 1 + aiordr/models/skin.py | 1 + pyproject.toml | 25 +++++++++++++++---------- tests/classes/__init__.py | 2 +- tests/test_client.py | 1 + 15 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5497aab..f2a89c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/asottile/pyupgrade @@ -19,11 +19,10 @@ repos: hooks: - id: pyupgrade args: [--py37-plus, --keep-runtime-typing] - - 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: [--py37-plus, --add-import, "from __future__ import annotations"] + - id: isort - repo: https://github.com/asottile/add-trailing-comma rev: v3.1.0 hooks: diff --git a/aiordr/__init__.py b/aiordr/__init__.py index a490eb6..81778ed 100644 --- a/aiordr/__init__.py +++ b/aiordr/__init__.py @@ -1,5 +1,4 @@ # isort: dont-add-imports -from __future__ import annotations from datetime import date from importlib import metadata diff --git a/aiordr/client.py b/aiordr/client.py index 5f019cc..9f3ca4d 100644 --- a/aiordr/client.py +++ b/aiordr/client.py @@ -1,9 +1,10 @@ """This module contains the client for interfacing with the o!rdr API.""" + from __future__ import annotations import functools -from typing import Literal from typing import TYPE_CHECKING +from typing import Literal from warnings import warn import aiohttp @@ -29,10 +30,10 @@ if TYPE_CHECKING: from types import TracebackType from typing import Any + from typing import Callable + from typing import Optional from typing import Type from typing import Union - from typing import Optional - from typing import Callable __all__ = ("DeveloperModes", "ordrClient") diff --git a/aiordr/exceptions.py b/aiordr/exceptions.py index c38b80a..1e042bb 100644 --- a/aiordr/exceptions.py +++ b/aiordr/exceptions.py @@ -1,6 +1,7 @@ """ This module contains custom exception types. """ + from __future__ import annotations from .models import ErrorCode diff --git a/aiordr/helpers.py b/aiordr/helpers.py index 096fec6..fd0cc9c 100644 --- a/aiordr/helpers.py +++ b/aiordr/helpers.py @@ -1,6 +1,7 @@ """ This module contains miscellaneous helper functions. """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/aiordr/models/__init__.py b/aiordr/models/__init__.py index 7400e3a..5b4d44b 100644 --- a/aiordr/models/__init__.py +++ b/aiordr/models/__init__.py @@ -1,6 +1,6 @@ """This module contains models for the o!rdr API.""" + # isort: dont-add-imports -from __future__ import annotations from .base import * from .errorcode import * diff --git a/aiordr/models/base.py b/aiordr/models/base.py index 7010bbe..e47f960 100644 --- a/aiordr/models/base.py +++ b/aiordr/models/base.py @@ -1,6 +1,7 @@ """ This module contains base models for objects. """ + from __future__ import annotations import pydantic diff --git a/aiordr/models/errorcode.py b/aiordr/models/errorcode.py index d635329..98a9296 100644 --- a/aiordr/models/errorcode.py +++ b/aiordr/models/errorcode.py @@ -1,6 +1,7 @@ """ This module contains o!rdr API Error Codes. """ + from __future__ import annotations from enum import IntEnum diff --git a/aiordr/models/events.py b/aiordr/models/events.py index 7cd36ca..f75b510 100644 --- a/aiordr/models/events.py +++ b/aiordr/models/events.py @@ -1,6 +1,7 @@ """ This module contains models for websocket events. """ + from __future__ import annotations from pydantic import Field diff --git a/aiordr/models/render.py b/aiordr/models/render.py index b14eaf8..70f6db9 100644 --- a/aiordr/models/render.py +++ b/aiordr/models/render.py @@ -1,6 +1,7 @@ """ This module contains models for renders. """ + from __future__ import annotations from datetime import datetime diff --git a/aiordr/models/renderserver.py b/aiordr/models/renderserver.py index 15fb5ac..5195954 100644 --- a/aiordr/models/renderserver.py +++ b/aiordr/models/renderserver.py @@ -1,6 +1,7 @@ """ This module contains models for render servers. """ + from __future__ import annotations from datetime import datetime diff --git a/aiordr/models/skin.py b/aiordr/models/skin.py index 086f693..64d26f1 100644 --- a/aiordr/models/skin.py +++ b/aiordr/models/skin.py @@ -1,6 +1,7 @@ """ This module contains models for skins. """ + from __future__ import annotations from pydantic import Field diff --git a/pyproject.toml b/pyproject.toml index 6a8b24f..0b06ba2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,11 @@ check_untyped_defs = true warn_unused_ignores = true show_error_codes = true +[tool.isort] +add_imports = ["from __future__ import annotations"] +force_single_line = true +profile = "black" + [tools.pytest.ini_options] testpaths = ["tests"] @@ -25,7 +30,7 @@ keywords = ["osu!", "osu", "api"] classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Typing :: Typed" + "Typing :: Typed", ] include = ["py.typed"] @@ -35,14 +40,14 @@ aiohttp = "^3.8.3" aiolimiter = "^1.0.0" orjson = "^3.8.3" pydantic = "^2.0.3" -pytest = {version="^7.2.0", optional = true} -pytest-asyncio = {version="^0.23.0", optional = true} -pytest-mock = {version="^3.10.0", optional = true} -toml = {version="^0.10.2", optional = true} -sphinx = {version="^7.0.0", optional = true} -furo = {version="^2023.5.20", optional = true} -types-toml = {version = "^0.10.8.1", optional = true} -python-socketio = {extras = ["asyncio-client"], version = "^5.7.2"} +pytest = { version = "^7.2.0", optional = true } +pytest-asyncio = { version = "^0.23.0", optional = true } +pytest-mock = { version = "^3.10.0", optional = true } +toml = { version = "^0.10.2", optional = true } +sphinx = { version = "^7.0.0", optional = true } +furo = { version = "^2023.5.20", optional = true } +types-toml = { version = "^0.10.8.1", optional = true } +python-socketio = { extras = ["asyncio-client"], version = "^5.7.2" } [tool.poetry.group.dev.dependencies] pytest = "^7.2.0" @@ -54,7 +59,7 @@ types-toml = "^0.10.8.1" sphinx = "^7.0.0" furo = "^2023.5.20" pytest-cov = "^4.0.0" -black = {version = "^23.0.0", allow-prereleases = true} +black = { version = "^23.0.0", allow-prereleases = true } pre-commit = "^3.2.2" [tool.poetry.extras] diff --git a/tests/classes/__init__.py b/tests/classes/__init__.py index 0b1e8bf..dc29f11 100644 --- a/tests/classes/__init__.py +++ b/tests/classes/__init__.py @@ -1,4 +1,4 @@ # isort: dont-add-imports -from __future__ import annotations + from .mock import MockResponse diff --git a/tests/test_client.py b/tests/test_client.py index 5a7b0fd..3b0568e 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -3,6 +3,7 @@ import pytest import aiordr + from .classes import MockResponse