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 a8a4c59 commit 6ca4c1b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions fastenv/dotenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import os
import shlex
from typing import TYPE_CHECKING, MutableMapping
from collections.abc import MutableMapping
from typing import TYPE_CHECKING

import anyio

from fastenv.utilities import logger

if TYPE_CHECKING:
from typing import Iterator
from collections.abc import Iterator


class DotEnv(MutableMapping[str, str]):
Expand Down Expand Up @@ -82,7 +83,7 @@ def _parse_args_to_set(self, *args: str) -> tuple[tuple[str, str], ...]:
return tuple(
(split_arg[0].strip(" \n\"'").upper(), split_arg[1].strip(" \n\"'"))
for a in parsed_args
if len((split_arg := a.split(sep="=", maxsplit=1))) == 2
if len(split_arg := a.split(sep="=", maxsplit=1)) == 2
)

def _parse_kwargs(self, **kwargs: str) -> dict[str, str]:
Expand Down
4 changes: 2 additions & 2 deletions fastenv/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, List, TypedDict, Union
from typing import TYPE_CHECKING, TypedDict, Union

if TYPE_CHECKING:
import sys
Expand All @@ -10,7 +10,7 @@
else:
from typing import TypeAlias

UploadPolicyConditions: TypeAlias = List[Union[Dict[str, str], List[Union[str, int]]]]
UploadPolicyConditions: TypeAlias = list[Union[dict[str, str], list[Union[str, int]]]]


class UploadPolicy(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ src = ["fastenv", "tests"]
docstring-code-format = true

[tool.ruff.lint]
extend-select = ["I"]
extend-select = ["I", "UP"]

[tool.ruff.lint.isort]
known-first-party = ["fastenv", "tests"]
3 changes: 2 additions & 1 deletion tests/test_dotenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import fastenv.dotenv

if TYPE_CHECKING:
from typing import Any, MutableMapping
from collections.abc import MutableMapping
from typing import Any

from pytest_mock import MockerFixture

Expand Down
5 changes: 3 additions & 2 deletions tests/test_fastapi.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import os
from collections.abc import AsyncGenerator, AsyncIterator
from contextlib import asynccontextmanager
from typing import AsyncGenerator, AsyncIterator, Dict, TypedDict
from typing import TypedDict

import pytest
from anyio import Path
Expand Down Expand Up @@ -33,7 +34,7 @@ async def lifespan(_: FastAPI) -> AsyncIterator[LifespanState]:


@app.get("/settings")
async def get_settings(request: Request) -> Dict[str, str]:
async def get_settings(request: Request) -> dict[str, str]:
settings = request.state.settings
return dict(settings)

Expand Down

0 comments on commit 6ca4c1b

Please sign in to comment.