From 699c59dde472d56d4a8863ec407eff51cfc208a3 Mon Sep 17 00:00:00 2001 From: Brendon Smith Date: Sat, 5 Oct 2024 14:43:31 -0400 Subject: [PATCH] Upgrade syntax after dropping Python 3.8 https://docs.astral.sh/ruff/rules/#pyupgrade-up --- inboard/app/main_fastapi.py | 7 +------ inboard/app/utilities_fastapi.py | 7 +------ inboard/types.py | 7 ++++--- pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/inboard/app/main_fastapi.py b/inboard/app/main_fastapi.py index 88c0589..0134d5b 100644 --- a/inboard/app/main_fastapi.py +++ b/inboard/app/main_fastapi.py @@ -1,6 +1,6 @@ import os import sys -from typing import Optional +from typing import Annotated, Optional from fastapi import Depends, FastAPI, status from fastapi.middleware import Middleware @@ -9,11 +9,6 @@ from inboard.app.utilities_fastapi import basic_auth as fastapi_basic_auth -if sys.version_info < (3, 9): # pragma: no cover - from typing_extensions import Annotated -else: # pragma: no cover - from typing import Annotated - BasicAuth = Annotated[str, Depends(fastapi_basic_auth)] origin_regex = r"^(https?:\/\/)(localhost|([\w\.]+\.)?br3ndon.land)(:[0-9]+)?$" server = ( diff --git a/inboard/app/utilities_fastapi.py b/inboard/app/utilities_fastapi.py index 7031c6e..c742307 100644 --- a/inboard/app/utilities_fastapi.py +++ b/inboard/app/utilities_fastapi.py @@ -1,15 +1,10 @@ import os import secrets -import sys +from typing import Annotated from fastapi import Depends, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials -if sys.version_info < (3, 9): # pragma: no cover - from typing_extensions import Annotated -else: # pragma: no cover - from typing import Annotated - HTTPBasicCredentialsDependency = Annotated[HTTPBasicCredentials, Depends(HTTPBasic())] diff --git a/inboard/types.py b/inboard/types.py index 5c88684..6dfd087 100644 --- a/inboard/types.py +++ b/inboard/types.py @@ -5,8 +5,9 @@ if TYPE_CHECKING: import sys from asyncio import Protocol + from collections.abc import Sequence from os import PathLike - from typing import Any, Literal, Sequence, Type + from typing import Any, Literal if sys.version_info < (3, 11): from typing_extensions import Required @@ -106,8 +107,8 @@ class UvicornOptions(TypedDict, total=False): uds: str | None fd: int | None loop: LoopSetupType - http: Type[Protocol] | HTTPProtocolType - ws: Type[Protocol] | WSProtocolType + http: type[Protocol] | HTTPProtocolType + ws: type[Protocol] | WSProtocolType ws_max_queue: int ws_max_size: int ws_ping_interval: float | None diff --git a/pyproject.toml b/pyproject.toml index 8e0747e..9790078 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -164,7 +164,7 @@ src = ["inboard", "tests"] docstring-code-format = true [tool.ruff.lint] -extend-select = ["I"] +extend-select = ["I", "UP"] [tool.ruff.lint.isort] known-first-party = ["inboard", "tests"]