From d39db4e50fce41992b87180af98a5599cc2fed87 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 30 Sep 2026 07:10:05 -1000 Subject: [PATCH] ruff check --target-version=py39 --fix --- httpx_gssapi/__init__.py | 14 +++++++------- httpx_gssapi/_version.py | 2 +- httpx_gssapi/exceptions.py | 2 +- httpx_gssapi/gssapi_.py | 15 +++++++-------- setup.py | 2 ++ tests/conftest.py | 16 ++++++++-------- tests/test_mocked.py | 8 +++----- versioneer.py | 19 +++++++++---------- 8 files changed, 38 insertions(+), 40 deletions(-) diff --git a/httpx_gssapi/__init__.py b/httpx_gssapi/__init__.py index 3c53224..b05268c 100644 --- a/httpx_gssapi/__init__.py +++ b/httpx_gssapi/__init__.py @@ -14,21 +14,21 @@ Both the sync and async HTTPX APIs should be fully supported. """ __all__ = ( + 'DISABLED', + 'OPTIONAL', + 'REQUIRED', + 'SPNEGO', 'HTTPSPNEGOAuth', 'MutualAuthenticationError', - 'SPNEGO', - 'REQUIRED', - 'OPTIONAL', - 'DISABLED', ) -import os import logging +import os -from .gssapi_ import HTTPSPNEGOAuth, SPNEGO, REQUIRED, OPTIONAL, DISABLED +from ._version import get_versions from .exceptions import MutualAuthenticationError +from .gssapi_ import DISABLED, OPTIONAL, REQUIRED, SPNEGO, HTTPSPNEGOAuth -from ._version import get_versions __version__ = get_versions()['version'] del get_versions diff --git a/httpx_gssapi/_version.py b/httpx_gssapi/_version.py index 72e8816..76ab495 100644 --- a/httpx_gssapi/_version.py +++ b/httpx_gssapi/_version.py @@ -12,12 +12,12 @@ """Git implementation of _version.py.""" import errno +import functools import os import re import subprocess import sys from typing import Any, Callable, Dict, List, Optional, Tuple -import functools def get_keywords() -> Dict[str, str]: diff --git a/httpx_gssapi/exceptions.py b/httpx_gssapi/exceptions.py index 86a6868..459da4e 100644 --- a/httpx_gssapi/exceptions.py +++ b/httpx_gssapi/exceptions.py @@ -8,7 +8,7 @@ from typing import Optional -from httpx import RequestError, Request, Response +from httpx import Request, RequestError, Response class MutualAuthenticationError(RequestError): diff --git a/httpx_gssapi/gssapi_.py b/httpx_gssapi/gssapi_.py index 0f5a99b..c29a7a4 100644 --- a/httpx_gssapi/gssapi_.py +++ b/httpx_gssapi/gssapi_.py @@ -1,16 +1,15 @@ -import re import logging -from itertools import chain +import re +from base64 import b64decode, b64encode +from collections.abc import Generator from functools import wraps -from typing import Generator, Optional, List, Any, Union - -from base64 import b64encode, b64decode +from itertools import chain +from typing import Any, List, Optional, Union import gssapi +import httpx from gssapi import SecurityContext from gssapi.exceptions import GSSError - -import httpx from httpx import Auth, Request, Response from .exceptions import MutualAuthenticationError, SPNEGOExchangeError @@ -36,7 +35,7 @@ # OID for the SPNEGO mechanism SPNEGO = gssapi.OID.from_int_seq("1.3.6.1.5.5.2") -_find_auth = re.compile(r'Negotiate\s*([^,]*)', re.I).search +_find_auth = re.compile(r'Negotiate\s*([^,]*)', re.IGNORECASE).search def _negotiate_value(response: Response) -> Optional[bytes]: diff --git a/setup.py b/setup.py index b347e22..6422ed7 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ #!/usr/bin/env python from pathlib import Path + from setuptools import setup + import versioneer path = Path(__file__).parent diff --git a/tests/conftest.py b/tests/conftest.py index 984faf2..6e414d3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,23 +1,23 @@ # TODO: Provide this through k5test? +import copy import os import re -import copy import threading as th -from contextlib import contextmanager from base64 import b64decode -from http.server import HTTPServer, BaseHTTPRequestHandler -from typing import Generator, cast - -import pytest -import k5test # type: ignore[import-untyped] +from collections.abc import Generator +from contextlib import contextmanager +from http.server import BaseHTTPRequestHandler, HTTPServer +from typing import cast import gssapi.exceptions +import k5test # type: ignore[import-untyped] +import pytest WWW_AUTHENTICATE = 'WWW-Authenticate' AUTHORIZATION = 'Authorization' NEGOTIATE = 'Negotiate' -_find_auth = re.compile(r'Negotiate\s*([^,]*)', re.I).search +_find_auth = re.compile(r'Negotiate\s*([^,]*)', re.IGNORECASE).search class KrbRequestHandler(BaseHTTPRequestHandler): diff --git a/tests/test_mocked.py b/tests/test_mocked.py index 770bfc3..9031abb 100644 --- a/tests/test_mocked.py +++ b/tests/test_mocked.py @@ -5,15 +5,13 @@ from base64 import b64encode from unittest.mock import Mock, patch -import pytest - -import httpx - import gssapi import gssapi.exceptions +import httpx +import pytest import httpx_gssapi -from httpx_gssapi import REQUIRED, OPTIONAL +from httpx_gssapi import OPTIONAL, REQUIRED logging.basicConfig() diff --git a/versioneer.py b/versioneer.py index 1e3753e..53c77c7 100644 --- a/versioneer.py +++ b/versioneer.py @@ -310,15 +310,14 @@ import configparser import errno +import functools import json import os import re import subprocess import sys from pathlib import Path -from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union -from typing import NoReturn -import functools +from typing import Any, Callable, Dict, List, NoReturn, Optional, Tuple, Union, cast have_tomllib = True if sys.version_info >= (3, 11): @@ -1517,10 +1516,10 @@ def versions_from_file(filename: str) -> Dict[str, Any]: except OSError: raise NotThisMethod("unable to read _version.py") mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_JSON", - contents, re.M | re.S) + contents, re.MULTILINE | re.DOTALL) if not mo: mo = re.search(r"version_json = '''\r\n(.*)''' # END VERSION_JSON", - contents, re.M | re.S) + contents, re.MULTILINE | re.DOTALL) if not mo: raise NotThisMethod("no version_json in _version.py") return json.loads(mo.group(1)) @@ -2233,7 +2232,7 @@ def scan_setup_py() -> int: setters = False errors = 0 with open("setup.py", "r") as f: - for line in f.readlines(): + for line in f: if "import versioneer" in line: found.add("import") if "versioneer.get_cmdclass()" in line: @@ -2245,21 +2244,21 @@ def scan_setup_py() -> int: if "versioneer.versionfile_source" in line: setters = True if len(found) != 3: - print("") + print() print("Your setup.py appears to be missing some important items") print("(but I might be wrong). Please make sure it has something") print("roughly like the following:") - print("") + print() print(" import versioneer") print(" setup( version=versioneer.get_version(),") print(" cmdclass=versioneer.get_cmdclass(), ...)") - print("") + print() errors += 1 if setters: print("You should remove lines like 'versioneer.VCS = ' and") print("'versioneer.versionfile_source = ' . This configuration") print("now lives in setup.cfg, and should be removed from setup.py") - print("") + print() errors += 1 return errors