Skip to content
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
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pdm_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Any, Dict
from typing import Any

from pdm.backend.hooks import Context

Expand All @@ -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
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Run and manage FastAPI apps from the command line with FastAPI CL
authors = [
{name = "Sebastián Ramírez", email = "[email protected]"},
]
requires-python = ">=3.8"
requires-python = ">=3.9"
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/fastapi_cli/cli.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}"

Expand Down
4 changes: 2 additions & 2 deletions src/fastapi_cli/config.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions src/fastapi_cli/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/fastapi_cli/utils/cli.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Generator
from collections.abc import Generator

import pytest
from typer import rich_utils
Expand Down
21 changes: 12 additions & 9 deletions tests/test_cli_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down