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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uv-resolution:
- highest
include:
- python-version: "3.10"
- python-version: "3.11"
os: ubuntu-latest
uv-resolution: lowest-direct
- python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10
3.11
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "fastapi-cloud-cli"
dynamic = ["version"]
description = "Deploy and manage FastAPI Cloud apps from the command line 🚀"
authors = [{ name = "Patrick Arminio", email = "patrick@fastapilabs.com" }]
requires-python = ">=3.10"
requires-python = ">=3.11"
readme = "README.md"
license = { text = "MIT" }
classifiers = [
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down
4 changes: 2 additions & 2 deletions scripts/prepare_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re
from datetime import date
from enum import Enum
from enum import StrEnum
from pathlib import Path
from typing import Annotated

Expand All @@ -14,7 +14,7 @@
LATEST_CHANGES_HEADER = "## Latest Changes"


class BumpType(str, Enum):
class BumpType(StrEnum):
major = "major"
minor = "minor"
patch = "patch"
Expand Down
6 changes: 3 additions & 3 deletions src/fastapi_cloud_cli/api/_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum
from typing import Annotated, Literal

from pydantic import BaseModel, Field, TypeAdapter
Expand Down Expand Up @@ -50,7 +50,7 @@ class BuildFailure(BaseModel):
)


class CustomDomainStatus(str, Enum):
class CustomDomainStatus(StrEnum):
internal_dcv_pending = "internal_dcv_pending"
internal_dcv_missing = "internal_dcv_missing"
internal_dcv_invalid = "internal_dcv_invalid"
Expand Down Expand Up @@ -96,7 +96,7 @@ class CustomDomainsAPIResponse(BaseModel):
count: int


class DeploymentStatus(str, Enum):
class DeploymentStatus(StrEnum):
waiting_upload = "waiting_upload"
upload_cancelled = "upload_cancelled"
ready_for_build = "ready_for_build"
Expand Down
3 changes: 1 addition & 2 deletions src/fastapi_cloud_cli/api/_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from contextlib import contextmanager
from datetime import timedelta
from functools import wraps
from typing import TypeVar
from typing import ParamSpec, TypeVar

import httpx
from typing_extensions import ParamSpec

from ._errors import StreamLogError, TooManyRetriesError

Expand Down
2 changes: 1 addition & 1 deletion src/fastapi_cloud_cli/commands/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _get_log_bullet(log: AppLogEntry) -> str:
def _format_log_line(log: AppLogEntry) -> str:
"""Format a log entry for display"""
# Parse the timestamp string to format it consistently
timestamp = datetime.fromisoformat(log.timestamp.replace("Z", "+00:00"))
timestamp = datetime.fromisoformat(log.timestamp)
timestamp_str = timestamp.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"

return f"[dim]{timestamp_str}[/dim] {escape(log.message)}"
Expand Down
4 changes: 2 additions & 2 deletions src/fastapi_cloud_cli/commands/setup_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import shutil
import subprocess
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path, PurePath
from typing import Annotated, Any

Expand Down Expand Up @@ -418,7 +418,7 @@ def setup_ci(

if should_create_token:
# Create unique token name with timestamp to avoid duplicates
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
timestamp = datetime.now(UTC).strftime("%Y-%m-%d %H:%M UTC")
token_name = f"GitHub Actions — {repo_slug} ({timestamp})"

with (
Expand Down
8 changes: 4 additions & 4 deletions src/fastapi_cloud_cli/utils/dates.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from datetime import datetime, timezone
from datetime import UTC, datetime


def format_last_updated(updated_at: str | None) -> str:
if updated_at is None:
return "-"

try:
updated = datetime.fromisoformat(updated_at.replace("Z", "+00:00"))
updated = datetime.fromisoformat(updated_at)
except ValueError:
return updated_at

if updated.tzinfo is None:
updated = updated.replace(tzinfo=timezone.utc)
updated = updated.replace(tzinfo=UTC)

now = datetime.now(timezone.utc)
now = datetime.now(UTC)
seconds = int((now - updated).total_seconds())

if seconds < 60:
Expand Down
6 changes: 3 additions & 3 deletions src/fastapi_cloud_cli/utils/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import threading
from contextlib import suppress
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from pathlib import Path

import httpx
Expand Down Expand Up @@ -68,7 +68,7 @@ def read_cached_latest_version(
*,
ttl: timedelta = VERSION_CHECK_CACHE_TTL,
) -> str | None:
now = datetime.now(timezone.utc)
now = datetime.now(UTC)

try:
cache = VersionCheckCache.model_validate_json(
Expand All @@ -93,7 +93,7 @@ def write_latest_version_cache(
latest_version: str,
now: datetime | None = None,
) -> None:
now = now or datetime.now(timezone.utc)
now = now or datetime.now(UTC)
data = {
"latest_version": latest_version,
"checked_at": now.isoformat(),
Expand Down
8 changes: 4 additions & 4 deletions tests/domains/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any
from unittest.mock import patch

Expand Down Expand Up @@ -90,7 +90,7 @@ def test_domains_list_requires_app_context(logged_in_cli: None) -> None:


@pytest.mark.respx
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=UTC), tick=False)
def test_domains_list_uses_linked_app_and_renders_rows(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_domains_get_resolves_normalized_hostname_or_id_as_json(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=UTC), tick=False)
def test_domains_get_prompts_with_selector_and_renders_details(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down Expand Up @@ -480,7 +480,7 @@ def test_domains_get_gates_zero_downtime_records_by_phase(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 9, 1, 10, 1, tzinfo=UTC), tick=False)
def test_domains_get_shows_url_and_no_action_when_live(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down
6 changes: 3 additions & 3 deletions tests/integrations/resources/test_get.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path
from typing import Literal

Expand Down Expand Up @@ -216,7 +216,7 @@ def test_gets_resource_json_requires_app_without_linked_app(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 9, 1, 10, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 9, 1, 10, tzinfo=UTC), tick=False)
def test_gets_database_resource_in_human_output(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_gets_database_resource_in_human_output(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 9, 1, 10, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 9, 1, 10, tzinfo=UTC), tick=False)
def test_gets_logfire_resource_in_human_output_without_environment_variables(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import sys
from collections.abc import Callable, Iterator
from datetime import datetime, timezone
from datetime import UTC, datetime
from inspect import signature
from types import FunctionType
from typing import Any
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_toolkit_json_mode_suppresses_update_message(
write_latest_version_cache(
get_version_check_cache_path(),
latest_version="999.0.0",
now=datetime.now(timezone.utc),
now=datetime.now(UTC),
)

@test_app.command()
Expand Down Expand Up @@ -545,7 +545,7 @@ def test_embedded_fastapi_cli_prints_forced_update_message(
write_latest_version_cache(
get_version_check_cache_path(),
latest_version="999.0.0",
now=datetime.now(timezone.utc),
now=datetime.now(UTC),
)

result = runner.invoke(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli_apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path
from unittest.mock import patch

Expand Down Expand Up @@ -944,7 +944,7 @@ def test_get_app_dashboard_url_uses_settings_team_and_app_slugs() -> None:


@pytest.mark.respx
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
def test_lists_apps_in_human_output(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli_deployments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any
from unittest.mock import patch

Expand Down Expand Up @@ -119,7 +119,7 @@ def test_lists_deployments_as_json_uses_linked_app(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
def test_lists_deployments_human_output_shows_id_status_and_created(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_gets_deployment_json_returns_missing_required_input_without_app_context


@pytest.mark.respx
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
def test_gets_deployment_in_human_output(
logged_in_cli: None,
respx_mock: respx.MockRouter,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli_login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path
from unittest.mock import patch

Expand Down Expand Up @@ -91,7 +91,7 @@ def test_full_login(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 11, 2, 12, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 11, 2, 12, tzinfo=UTC), tick=False)
def test_login_saves_token_expiry(
respx_mock: respx.MockRouter, temp_auth_config: Path, settings: Settings
) -> None:
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_login_saves_token_expiry(

assert result.exit_code == 0

expires_at = datetime(2026, 11, 10, 11, 59, 50, tzinfo=timezone.utc)
expires_at = datetime(2026, 11, 10, 11, 59, 50, tzinfo=UTC)
assert json.loads(temp_auth_config.read_text()) == {
"access_token": "test_token_1234",
"expires_at": int(expires_at.timestamp()),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dates.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime, timezone
from datetime import UTC, datetime

import pytest
import time_machine

from fastapi_cloud_cli.utils.dates import format_last_updated


@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
@pytest.mark.parametrize(
("updated_at", "expected"),
[
Expand Down
8 changes: 4 additions & 4 deletions tests/test_env_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path

import pytest
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_lists_environment_variables_as_json_with_path(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
def test_shows_environment_variables_in_compact_table(
logged_in_cli: None, respx_mock: respx.MockRouter, configured_app: ConfiguredApp
) -> None:
Expand Down Expand Up @@ -225,7 +225,7 @@ def test_shows_environment_variables_in_compact_table(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=UTC), tick=False)
def test_truncates_values_and_marks_secrets_in_compact_table(
logged_in_cli: None, respx_mock: respx.MockRouter, configured_app: ConfiguredApp
) -> None:
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_truncates_values_and_marks_secrets_in_compact_table(


@pytest.mark.respx
@time_machine.travel(datetime(2026, 8, 13, 12, tzinfo=timezone.utc), tick=False)
@time_machine.travel(datetime(2026, 8, 13, 12, tzinfo=UTC), tick=False)
def test_shows_secret_environment_variables_without_value(
logged_in_cli: None, respx_mock: respx.MockRouter, configured_app: ConfiguredApp
) -> None:
Expand Down
10 changes: 3 additions & 7 deletions tests/test_progress_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import io
from datetime import datetime, timezone
from datetime import UTC, datetime
from unittest.mock import Mock, call

import time_machine
Expand Down Expand Up @@ -38,9 +38,7 @@ def test_callback_called_after_interval_elapses() -> None:
file = _make_file(b"abcdef")
mock_callback = Mock()

with time_machine.travel(
datetime(2026, 1, 1, tzinfo=timezone.utc), tick=False
) as traveller:
with time_machine.travel(datetime(2026, 1, 1, tzinfo=UTC), tick=False) as traveller:
pf = ProgressFile(file, progress_callback=mock_callback)

pf.read(3)
Expand All @@ -54,9 +52,7 @@ def test_callback_tracks_cumulative_bytes() -> None:
file = _make_file(b"a" * 100)
mock_callback = Mock()

with time_machine.travel(
datetime(2026, 1, 1, tzinfo=timezone.utc), tick=False
) as traveller:
with time_machine.travel(datetime(2026, 1, 1, tzinfo=UTC), tick=False) as traveller:
pf = ProgressFile(file, progress_callback=mock_callback)

pf.read(10) # Should trigger callback with 10 bytes read
Expand Down
Loading
Loading