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: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Items marked with :fire: are high priority.
- Medium-term typing direction: replace runtime-injected reverse accessors
with explicit reverse relationship declarations in model classes so
reverse-side usage is mypy-friendly without casts or TYPE_CHECKING hacks.
- Short-term typing upgrade for user code: improve library type hints for
dynamic ORM relationship APIs (reverse FK descriptors, M2M managers, and
prefetched relation result types) to reduce required casts in normal
application code and tests.
- Registry lifetime: global registry can cause cross-talk when models are
defined repeatedly in one process (e.g., tests). Current mitigation exists
via `ModelRegistry.reset()` and snapshot/restore helpers; longer-term option:
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ convention = "google"
[tool.ruff.lint.extend-per-file-ignores]
"tests/**/*.py" = [
"S101", # we can (and MUST!) use 'assert' in test files.
"ANN001", # annotations for fixtures are sometimes a pain for test files
"ARG00", # test fixtures often are not directly used
"PLR2004", # magic numbers are often used in test files
"SLF001", # sometimes we need to test private methods
Expand All @@ -155,10 +154,6 @@ plugins = ["pydantic.mypy"]
python_version = "3.9"
exclude = ["docs"]

[[tool.mypy.overrides]]
disable_error_code = ["method-assign", "no-untyped-def", "attr-defined"]
module = "tests.*"

[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@

if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path


memory_db = ":memory:"


@pytest.hookimpl(tryfirst=True)
def pytest_configure(config) -> None:
def pytest_configure(config: pytest.Config) -> None:
"""Clear the screen before running tests."""
os.system("cls" if os.name == "nt" else "clear") # noqa: S605


@contextmanager
def not_raises(exception) -> Generator[None, Any, None]:
def not_raises(exception: type[BaseException]) -> Generator[None, Any, None]:
"""Fake a pytest.raises context manager that does not raise an exception.

Use: `with not_raises(Exception):`
Expand Down Expand Up @@ -198,7 +199,7 @@ def db_mock_complex_debug() -> SqliterDB:


@pytest.fixture
def temp_db_path(tmp_path) -> str:
def temp_db_path(tmp_path: Path) -> str:
"""Fixture to create a temporary database file path."""
return str(tmp_path / "test_db.sqlite")

Expand Down
Loading