diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21d9ead3..3eed3e03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,8 +31,6 @@ jobs: os: [ ubuntu-latest, windows-latest, macos-latest ] python-version: ["3.14"] include: - - python-version: "3.8" - os: windows-latest - python-version: "3.9" os: macos-latest - python-version: "3.10" @@ -99,7 +97,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: - python-version: '3.8' + python-version: '3.9' - name: Setup uv uses: astral-sh/setup-uv@v7 with: diff --git a/pdm_build.py b/pdm_build.py index 67952131..e26d5878 100644 --- a/pdm_build.py +++ b/pdm_build.py @@ -1,5 +1,5 @@ import os -from typing import Any, Dict +from typing import Any from pdm.backend.hooks import Context @@ -9,12 +9,12 @@ def pdm_build_initialize(context: Context): metadata = context.config.metadata # Get custom config for the current package, from the env var - config: Dict[str, Any] = context.config.data["tool"]["tiangolo"][ + config: dict[str, Any] = context.config.data["tool"]["tiangolo"][ "_internal-slim-build" ]["packages"].get(TIANGOLO_BUILD_PACKAGE) if not config: return - project_config: Dict[str, Any] = config["project"] + project_config: dict[str, Any] = config["project"] # Override main [project] configs with custom configs for this package for key, value in project_config.items(): metadata[key] = value diff --git a/pyproject.toml b/pyproject.toml index b9a0c65e..cf52b1d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "Run and manage FastAPI apps from the command line with FastAPI CL authors = [ {name = "Sebastián Ramírez", email = "tiangolo@gmail.com"}, ] -requires-python = ">=3.8" +requires-python = ">=3.9" readme = "README.md" license = "MIT" license-files = ["LICENSE"] @@ -24,7 +24,6 @@ classifiers = [ "Framework :: FastAPI", "Intended Audience :: Developers", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/src/fastapi_cli/cli.py b/src/fastapi_cli/cli.py index ac2fc791..b4660bde 100644 --- a/src/fastapi_cli/cli.py +++ b/src/fastapi_cli/cli.py @@ -1,12 +1,11 @@ import logging from pathlib import Path -from typing import Any, List, Union +from typing import Annotated, Any, Union import typer from pydantic import ValidationError from rich import print from rich.tree import Tree -from typing_extensions import Annotated from fastapi_cli.config import FastAPIConfig from fastapi_cli.discover import get_import_data, get_import_data_from_import_string @@ -78,7 +77,7 @@ def callback( setup_logging(level=log_level) -def _get_module_tree(module_paths: List[Path]) -> Tree: +def _get_module_tree(module_paths: list[Path]) -> Tree: root = module_paths[0] name = f"🐍 {root.name}" if root.is_file() else f"📁 {root.name}" diff --git a/src/fastapi_cli/config.py b/src/fastapi_cli/config.py index a2e91d55..f2af18aa 100644 --- a/src/fastapi_cli/config.py +++ b/src/fastapi_cli/config.py @@ -1,6 +1,6 @@ import logging from pathlib import Path -from typing import Any, Dict, Optional +from typing import Any, Optional from pydantic import BaseModel, StrictStr @@ -11,7 +11,7 @@ class FastAPIConfig(BaseModel): entrypoint: Optional[StrictStr] = None @classmethod - def _read_pyproject_toml(cls) -> Dict[str, Any]: + def _read_pyproject_toml(cls) -> dict[str, Any]: """Read FastAPI configuration from pyproject.toml in current directory.""" pyproject_path = Path.cwd() / "pyproject.toml" diff --git a/src/fastapi_cli/discover.py b/src/fastapi_cli/discover.py index b174f8fb..116ed860 100644 --- a/src/fastapi_cli/discover.py +++ b/src/fastapi_cli/discover.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from logging import getLogger from pathlib import Path -from typing import List, Union +from typing import Union from fastapi_cli.exceptions import FastAPICLIException @@ -39,7 +39,7 @@ def get_default_path() -> Path: class ModuleData: module_import_str: str extra_sys_path: Path - module_paths: List[Path] + module_paths: list[Path] def get_module_data_from_path(path: Path) -> ModuleData: diff --git a/src/fastapi_cli/utils/cli.py b/src/fastapi_cli/utils/cli.py index dff93ee8..6c9c2ac5 100644 --- a/src/fastapi_cli/utils/cli.py +++ b/src/fastapi_cli/utils/cli.py @@ -1,5 +1,5 @@ import logging -from typing import Any, Dict +from typing import Any from rich_toolkit import RichToolkit, RichToolkitTheme from rich_toolkit.styles import TaggedStyle @@ -20,7 +20,7 @@ def formatMessage(self, record: logging.LogRecord) -> str: return result -def get_uvicorn_log_config() -> Dict[str, Any]: +def get_uvicorn_log_config() -> dict[str, Any]: return { "version": 1, "disable_existing_loggers": False, diff --git a/tests/conftest.py b/tests/conftest.py index ee744724..0ad27aee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ import sys -from typing import Generator +from collections.abc import Generator import pytest from typer import rich_utils diff --git a/tests/test_cli_pyproject.py b/tests/test_cli_pyproject.py index c8b072c4..f2b1678f 100644 --- a/tests/test_cli_pyproject.py +++ b/tests/test_cli_pyproject.py @@ -13,9 +13,10 @@ def test_dev_with_pyproject_app_config_uses() -> None: - with changing_dir(assets_path / "pyproject_config"), patch.object( - uvicorn, "run" - ) as mock_run: + with ( + changing_dir(assets_path / "pyproject_config"), + patch.object(uvicorn, "run") as mock_run, + ): result = runner.invoke(app, ["dev"]) assert result.exit_code == 0, result.output @@ -28,9 +29,10 @@ def test_dev_with_pyproject_app_config_uses() -> None: def test_run_with_pyproject_app_config() -> None: - with changing_dir(assets_path / "pyproject_config"), patch.object( - uvicorn, "run" - ) as mock_run: + with ( + changing_dir(assets_path / "pyproject_config"), + patch.object(uvicorn, "run") as mock_run, + ): result = runner.invoke(app, ["run"]) assert result.exit_code == 0, result.output @@ -43,9 +45,10 @@ def test_run_with_pyproject_app_config() -> None: def test_cli_arg_overrides_pyproject_config() -> None: - with changing_dir(assets_path / "pyproject_config"), patch.object( - uvicorn, "run" - ) as mock_run: + with ( + changing_dir(assets_path / "pyproject_config"), + patch.object(uvicorn, "run") as mock_run, + ): result = runner.invoke(app, ["dev", "another_module.py"]) assert result.exit_code == 0, result.output diff --git a/tests/utils.py b/tests/utils.py index 804454cb..c15ed32f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,7 +1,8 @@ import os +from collections.abc import Generator from contextlib import contextmanager from pathlib import Path -from typing import Generator, Union +from typing import Union @contextmanager