Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python 3.9 #87

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"
packages = [{include = "bartender", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.9"
# TODO upgrade to pydantic v2
fastapi = "^0.99.0"
uvicorn = {version = "^0.21.1", extras = ["standard"]}
Expand Down
18 changes: 9 additions & 9 deletions src/bartender/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pathlib import Path
from tempfile import gettempdir
from typing import Annotated, Any
from typing import Annotated, Any, Union

from fastapi import Depends, Request
from jsonschema import Draft202012Validator
Expand Down Expand Up @@ -41,17 +41,17 @@ class ApplicatonConfiguration(BaseModel):
"""

command_template: str
input_schema: dict[Any, Any] | None = None
summary: str | None = None
description: str | None = None
input_schema: Union[dict[Any, Any], None] = None
summary: Union[str, None] = None
description: Union[str, None] = None
upload_needs: list[str] = []
allowed_roles: list[str] = []

@validator("input_schema")
def check_input_schema(
cls, # noqa: N805
v: dict[Any, Any] | None, # noqa: WPS111
) -> dict[Any, Any] | None:
v: Union[dict[Any, Any], None], # noqa: WPS111
) -> Union[dict[Any, Any], None]:
"""Validate input schema.

Args:
Expand Down Expand Up @@ -128,10 +128,10 @@ class InteractiveApplicationConfiguration(BaseModel):

command_template: str
input_schema: dict[Any, Any]
summary: str | None = None
description: str | None = None
summary: Union[str, None] = None
description: Union[str, None] = None
timeout: confloat(gt=0, le=60) = 30.0 # type: ignore
job_application: str | None = None
job_application: Union[str, None] = None

@validator("input_schema")
def check_input_schema(
Expand Down
8 changes: 4 additions & 4 deletions src/bartender/web/api/job/interactive_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import asynccontextmanager
from os.path import join
from pathlib import Path
from typing import Any, AsyncGenerator, Literal
from typing import Any, AsyncGenerator, Literal, Union

from aiofiles import open
from aiofiles.tempfile import TemporaryDirectory
Expand Down Expand Up @@ -75,10 +75,10 @@ def build_command(
return template.render(**payload)


MediaEncoding = Literal["base64"] | Literal["utf-8"] # -- 3.10>= union type
MediaEncoding = Union[Literal["base64"], Literal["utf-8"]]


def encoding_of_prop(prop: dict[Any, Any]) -> MediaEncoding | None:
def encoding_of_prop(prop: dict[Any, Any]) -> Union[MediaEncoding, None]:
"""
Determines the encoding of a property.

Expand Down Expand Up @@ -147,7 +147,7 @@ async def write_file(encoded_data: str, encoding: MediaEncoding, fn: str) -> Non
await fh.write(decoded_data)


def get_path_in_payload(data: dict[Any, Any], path: str) -> Any | None:
def get_path_in_payload(data: dict[Any, Any], path: str) -> Union[Any, None]:
"""
Get the value at the specified path in the given dictionary.

Expand Down
Loading