Skip to content

Commit 9d015cd

Browse files
Appease mypy
1 parent 84b0b22 commit 9d015cd

File tree

4 files changed

+16
-2157
lines changed

4 files changed

+16
-2157
lines changed

pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,3 @@ known-third-party = ["typer", "fastapi"]
121121
[tool.ruff.lint.pyupgrade]
122122
# Preserve types, even if a file imports `from __future__ import annotations`.
123123
keep-runtime-typing = true
124-
125-
[dependency-groups]
126-
dev = [
127-
"coverage>=7.6.1",
128-
"pytest>=8.3.5",
129-
"respx>=0.22.0",
130-
]

src/fastapi_cloud_cli/commands/new.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
class ProjectConfig:
2424
name: str
2525
path: pathlib.Path
26-
extra_args: list = field(default_factory=list)
26+
extra_args: list[str] = field(default_factory=list)
2727

2828
def _generate_readme(project_name: str) -> str:
2929
return f"""# {project_name}
@@ -62,7 +62,7 @@ def _exit_with_error(toolkit: RichToolkit, error_msg: str) -> None:
6262
toolkit.print(f"[bold red]Error:[/bold red] {error_msg}", tag="error")
6363
raise typer.Exit(code=1)
6464

65-
def _validate_python_version_in_args(extra_args: list) -> Optional[str]:
65+
def _validate_python_version_in_args(extra_args: list[str]) -> Optional[str]:
6666
"""
6767
Check if --python is specified in extra_args and validate it's >= 3.8.
6868
Returns error message if < 3.8, None otherwise.
@@ -86,6 +86,7 @@ def _validate_python_version_in_args(extra_args: list) -> Optional[str]:
8686
except (ValueError, IndexError):
8787
# Malformed version - let uv handle the error
8888
return None
89+
return None
8990

9091
def _setup(toolkit: RichToolkit, config: ProjectConfig) -> None:
9192
error = _validate_python_version_in_args(config.extra_args)

tests/test_cli_new.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import shutil
2+
from pathlib import Path
3+
from typing import Any
24

35
import pytest
46
from typer.testing import CliRunner
@@ -9,22 +11,22 @@
911

1012

1113
@pytest.fixture
12-
def temp_project_dir(tmp_path, monkeypatch):
14+
def temp_project_dir(tmp_path: Path, monkeypatch: Any) -> Path:
1315
"""Create a temporary directory and cd into it."""
1416
monkeypatch.chdir(tmp_path)
1517
return tmp_path
1618

1719

1820
@pytest.fixture(autouse=True)
19-
def check_uv_installed():
21+
def check_uv_installed() -> None:
2022
"""Skip tests if uv is not installed."""
2123
if not shutil.which("uv"):
2224
pytest.skip("uv is not installed")
2325

2426

2527
class TestNewCommand:
2628

27-
def test_creates_project_successfully(self, temp_project_dir):
29+
def test_creates_project_successfully(self, temp_project_dir: Path) -> None:
2830
result = runner.invoke(app, ["new", "my_fastapi_project"])
2931

3032
assert result.exit_code == 0
@@ -35,7 +37,7 @@ def test_creates_project_successfully(self, temp_project_dir):
3537
assert "Success!" in result.output
3638
assert "my_fastapi_project" in result.output
3739

38-
def test_creates_project_with_python_flag(self, temp_project_dir):
40+
def test_creates_project_with_python_flag(self, temp_project_dir: Path) -> None:
3941
result = runner.invoke(app, ["new", "my_fastapi_project", "--python", "3.12"])
4042

4143
assert result.exit_code == 0
@@ -47,7 +49,7 @@ def test_creates_project_with_python_flag(self, temp_project_dir):
4749
assert "3.12" in python_version_file
4850
assert "Success!" in result.output
4951

50-
def test_creates_project_with_python_flag_short(self, temp_project_dir):
52+
def test_creates_project_with_python_flag_short(self, temp_project_dir: Path) -> None:
5153
result = runner.invoke(app, ["new", "another_project", "-p", "3.9"])
5254
assert result.exit_code == 0
5355
project_path = temp_project_dir / "another_project"
@@ -56,7 +58,7 @@ def test_creates_project_with_python_flag_short(self, temp_project_dir):
5658
assert "3.9" in python_version_file
5759

5860

59-
def test_creates_project_with_multiple_flags(self, temp_project_dir):
61+
def test_creates_project_with_multiple_flags(self, temp_project_dir: Path) -> None:
6062
result = runner.invoke(app, ["new", "my_fastapi_project", "--python", "3.12", "--lib"])
6163

6264
assert result.exit_code == 0
@@ -67,14 +69,14 @@ def test_creates_project_with_multiple_flags(self, temp_project_dir):
6769
assert (project_path / "main.py").exists()
6870
assert (project_path / "README.md").exists()
6971

70-
def test_rejects_python_below_3_8(self, temp_project_dir):
72+
def test_rejects_python_below_3_8(self, temp_project_dir: Path) -> None:
7173
result = runner.invoke(app, ["new", "my_fastapi_project", "--python", "3.7"])
7274

7375
assert result.exit_code == 1
7476
assert "Python 3.7 is not supported" in result.output
7577
assert "FastAPI requires Python 3.8" in result.output
7678

77-
def test_rejects_existing_directory(self, temp_project_dir):
79+
def test_rejects_existing_directory(self, temp_project_dir: Path) -> None:
7880
existing_dir = temp_project_dir / "existing_project"
7981
existing_dir.mkdir()
8082

@@ -83,7 +85,7 @@ def test_rejects_existing_directory(self, temp_project_dir):
8385
assert result.exit_code == 1
8486
assert f"Directory 'existing_project' already exists." in result.output
8587

86-
def test_initializes_in_current_directory_when_no_name_provided(self, temp_project_dir):
88+
def test_initializes_in_current_directory_when_no_name_provided(self, temp_project_dir: Path) -> None:
8789
result = runner.invoke(app, ["new"])
8890

8991
assert result.exit_code == 0
@@ -97,7 +99,7 @@ def test_initializes_in_current_directory_when_no_name_provided(self, temp_proje
9799
assert (temp_project_dir / "README.md").exists()
98100
assert (temp_project_dir / "pyproject.toml").exists()
99101

100-
def test_validate_file_contents(self, temp_project_dir):
102+
def test_validate_file_contents(self, temp_project_dir: Path) -> None:
101103
result = runner.invoke(app, ["new", "sample_project"])
102104

103105
assert result.exit_code == 0
@@ -111,7 +113,7 @@ def test_validate_file_contents(self, temp_project_dir):
111113
assert "# sample_project" in readme_content
112114
assert "A project created with FastAPI Cloud CLI." in readme_content
113115

114-
def test_validate_pyproject_toml_contents(self, temp_project_dir):
116+
def test_validate_pyproject_toml_contents(self, temp_project_dir: Path) -> None:
115117
result = runner.invoke(app, ["new", "test_project"])
116118

117119
assert result.exit_code == 0

0 commit comments

Comments
 (0)