Skip to content

Commit

Permalink
Upgrade syntax after dropping Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
br3ndonland committed Oct 5, 2024
1 parent ee33487 commit 7ac105f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
7 changes: 1 addition & 6 deletions inboard/app/main_fastapi.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = (
Expand Down
7 changes: 1 addition & 6 deletions inboard/app/utilities_fastapi.py
Original file line number Diff line number Diff line change
@@ -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())]


Expand Down
2 changes: 1 addition & 1 deletion inboard/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_app_module(logger: logging.Logger = logging.getLogger()) -> str:
app_module = os.getenv("APP_MODULE") or os.getenv("UVICORN_APP")
if not app_module:
raise ValueError("Please set the APP_MODULE environment variable")
if not importlib.util.find_spec((module := app_module.split(sep=":")[0])):
if not importlib.util.find_spec(module := app_module.split(sep=":")[0]):
raise ImportError(f"Unable to find or import {module}")
logger.debug(f"App module set to {app_module}.")
return app_module
Expand Down
7 changes: 4 additions & 3 deletions inboard/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion tests/test_logging_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_configure_logging_tmp_file_incorrect_extension(
logger.error.assert_called_once_with(
f"{logger_error_msg}: ImportError {import_error_msg}."
)
with open(incorrect_logging_conf, "r") as f:
with open(incorrect_logging_conf) as f:
contents = f.read()
assert "This file doesn't have the correct extension" in contents

Expand Down

0 comments on commit 7ac105f

Please sign in to comment.