From 2283c136fd04f36e6a59d7e93b69831df187c1fe Mon Sep 17 00:00:00 2001 From: LilSpazJoekp Date: Mon, 29 Jan 2024 15:07:43 +0000 Subject: [PATCH] Update pre-commit hooks --- .pre-commit-config.yaml | 4 ++-- asyncprawcore/auth.py | 17 +++++++++++------ asyncprawcore/codes.py | 1 + asyncprawcore/const.py | 1 + asyncprawcore/exceptions.py | 1 + asyncprawcore/rate_limit.py | 1 + asyncprawcore/requestor.py | 7 ++++--- asyncprawcore/sessions.py | 1 + asyncprawcore/util.py | 1 + tests/conftest.py | 1 + tests/integration/__init__.py | 1 + tests/integration/test_authenticator.py | 1 + tests/integration/test_authorizer.py | 1 + tests/integration/test_sessions.py | 1 + tests/unit/test_authenticator.py | 1 + tests/unit/test_authorizer.py | 1 + tests/unit/test_rate_limit.py | 1 + tests/unit/test_requestor.py | 1 + tests/unit/test_sessions.py | 1 + tests/utils.py | 1 + 20 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8a0d8b..c5eb802 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: files: ^(.*\.toml)$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.1.14 hooks: - id: ruff args: [ --exit-non-zero-on-fix, --fix ] @@ -33,7 +33,7 @@ repos: - repo: https://github.com/psf/black hooks: - id: black - rev: 23.12.1 + rev: 24.1.1 - repo: https://github.com/LilSpazJoekp/docstrfmt hooks: diff --git a/asyncprawcore/auth.py b/asyncprawcore/auth.py index 0a4b1bb..ac1c63f 100644 --- a/asyncprawcore/auth.py +++ b/asyncprawcore/auth.py @@ -1,4 +1,5 @@ """Provides Authentication and Authorization classes.""" + from __future__ import annotations import inspect @@ -241,12 +242,16 @@ def __init__( self, authenticator: BaseAuthenticator, *, - post_refresh_callback: Callable[[Authorizer], Awaitable[None]] - | Callable[[Authorizer], None] - | None = None, - pre_refresh_callback: Callable[[Authorizer], Awaitable[None]] - | Callable[[Authorizer], None] - | None = None, + post_refresh_callback: ( + Callable[[Authorizer], Awaitable[None]] + | Callable[[Authorizer], None] + | None + ) = None, + pre_refresh_callback: ( + Callable[[Authorizer], Awaitable[None]] + | Callable[[Authorizer], None] + | None + ) = None, refresh_token: str | None = None, ): """Represent a single authorization to Reddit's API. diff --git a/asyncprawcore/codes.py b/asyncprawcore/codes.py index 8ddcd1e..69ce03e 100644 --- a/asyncprawcore/codes.py +++ b/asyncprawcore/codes.py @@ -1,4 +1,5 @@ """Use our own codes instead of importing them.""" + from __future__ import annotations diff --git a/asyncprawcore/const.py b/asyncprawcore/const.py index 47dd4e6..e487786 100644 --- a/asyncprawcore/const.py +++ b/asyncprawcore/const.py @@ -1,4 +1,5 @@ """Constants for the asyncprawcore package.""" + import os ACCESS_TOKEN_PATH = "/api/v1/access_token" # noqa: S105 diff --git a/asyncprawcore/exceptions.py b/asyncprawcore/exceptions.py index e12569c..afa1fb4 100644 --- a/asyncprawcore/exceptions.py +++ b/asyncprawcore/exceptions.py @@ -1,4 +1,5 @@ """Provide exception classes for the asyncprawcore package.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/asyncprawcore/rate_limit.py b/asyncprawcore/rate_limit.py index 18280c5..c05d0fb 100644 --- a/asyncprawcore/rate_limit.py +++ b/asyncprawcore/rate_limit.py @@ -1,4 +1,5 @@ """Provide the RateLimiter class.""" + from __future__ import annotations import asyncio diff --git a/asyncprawcore/requestor.py b/asyncprawcore/requestor.py index 65e3caa..7d15d32 100644 --- a/asyncprawcore/requestor.py +++ b/asyncprawcore/requestor.py @@ -1,4 +1,5 @@ """Provides the HTTP request handling interface.""" + from __future__ import annotations import asyncio @@ -59,9 +60,9 @@ def __init__( self._http = session or aiohttp.ClientSession( loop=self.loop, timeout=aiohttp.ClientTimeout(total=None) ) - self._http._default_headers[ - "User-Agent" - ] = f"{user_agent} asyncprawcore/{__version__}" + self._http._default_headers["User-Agent"] = ( + f"{user_agent} asyncprawcore/{__version__}" + ) self.oauth_url = oauth_url self.reddit_url = reddit_url diff --git a/asyncprawcore/sessions.py b/asyncprawcore/sessions.py index d90633d..c724f3e 100644 --- a/asyncprawcore/sessions.py +++ b/asyncprawcore/sessions.py @@ -1,4 +1,5 @@ """asyncprawcore.sessions: Provides asyncprawcore.Session and asyncprawcore.session.""" + from __future__ import annotations import asyncio diff --git a/asyncprawcore/util.py b/asyncprawcore/util.py index 61bb77a..6589e8d 100644 --- a/asyncprawcore/util.py +++ b/asyncprawcore/util.py @@ -1,4 +1,5 @@ """Provide utility for the asyncprawcore package.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/tests/conftest.py b/tests/conftest.py index 2b89054..6be894b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Prepare pytest.""" + import asyncio import os from base64 import b64encode diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 79494b3..ea9c9ad 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -1,4 +1,5 @@ """asyncprawcore Integration test suite.""" + import os import pytest diff --git a/tests/integration/test_authenticator.py b/tests/integration/test_authenticator.py index 7a7c630..9cbe01a 100644 --- a/tests/integration/test_authenticator.py +++ b/tests/integration/test_authenticator.py @@ -1,4 +1,5 @@ """Test for subclasses of asyncprawcore.auth.BaseAuthenticator class.""" + import pytest import asyncprawcore diff --git a/tests/integration/test_authorizer.py b/tests/integration/test_authorizer.py index f344713..23e4cae 100644 --- a/tests/integration/test_authorizer.py +++ b/tests/integration/test_authorizer.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.auth.Authorizer classes.""" + import pytest import asyncprawcore diff --git a/tests/integration/test_sessions.py b/tests/integration/test_sessions.py index 302d751..e9c202f 100644 --- a/tests/integration/test_sessions.py +++ b/tests/integration/test_sessions.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.Sessions module.""" + import logging from json import dumps diff --git a/tests/unit/test_authenticator.py b/tests/unit/test_authenticator.py index d0f60fa..e5352b0 100644 --- a/tests/unit/test_authenticator.py +++ b/tests/unit/test_authenticator.py @@ -1,4 +1,5 @@ """Test for subclasses of asyncprawcore.auth.BaseAuthenticator class.""" + import pytest import asyncprawcore diff --git a/tests/unit/test_authorizer.py b/tests/unit/test_authorizer.py index 5fc9ca2..1e49180 100644 --- a/tests/unit/test_authorizer.py +++ b/tests/unit/test_authorizer.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.auth.Authorizer classes.""" + import pytest import asyncprawcore diff --git a/tests/unit/test_rate_limit.py b/tests/unit/test_rate_limit.py index ac7ff60..790bd71 100644 --- a/tests/unit/test_rate_limit.py +++ b/tests/unit/test_rate_limit.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.Sessions module.""" + from copy import copy from unittest.mock import patch diff --git a/tests/unit/test_requestor.py b/tests/unit/test_requestor.py index 5390688..01688ce 100644 --- a/tests/unit/test_requestor.py +++ b/tests/unit/test_requestor.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.self.requestor.Requestor class.""" + import asyncio from unittest.mock import MagicMock, patch diff --git a/tests/unit/test_sessions.py b/tests/unit/test_sessions.py index bc22456..1fd938e 100644 --- a/tests/unit/test_sessions.py +++ b/tests/unit/test_sessions.py @@ -1,4 +1,5 @@ """Test for asyncprawcore.Sessions module.""" + import logging from unittest.mock import AsyncMock, patch diff --git a/tests/utils.py b/tests/utils.py index 3cb5917..0b76855 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,4 +1,5 @@ """Pytest utils for integration tests.""" + from __future__ import annotations import json import os