fastapi - 💡(How to fix) Fix Ensure pydantic_extra_types Color encoder path is covered in tests

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

On current master (ecace74), this command passes one color case and skips the pydantic_extra_types.color case because pydantic_extra_types is not installed in the default test environment:

Code Example

$ uv run pytest tests/test_jsonable_encoder.py::test_encode_color -q -rs
.s                                                                       [100%]
=========================== short test summary info ===========================
SKIPPED [1] tests\test_jsonable_encoder.py:328: pydantic_extra_types.color not available
1 passed, 1 skipped in 0.44s

---

uv run pytest tests/test_jsonable_encoder.py::test_encode_color -q -rs
RAW_BUFFERClick to expand / collapse

Describe the bug

The new jsonable_encoder() coverage for pydantic_extra_types.color.Color can be skipped in the default test environment, so the modern color-type branch added in fastapi/encoders.py may not be exercised by normal test runs.

On current master (ecace74), this command passes one color case and skips the pydantic_extra_types.color case because pydantic_extra_types is not installed in the default test environment:

$ uv run pytest tests/test_jsonable_encoder.py::test_encode_color -q -rs
.s                                                                       [100%]
=========================== short test summary info ===========================
SKIPPED [1] tests\test_jsonable_encoder.py:328: pydantic_extra_types.color not available
1 passed, 1 skipped in 0.44s

To Reproduce

  1. Check out current master.
  2. Run:
uv run pytest tests/test_jsonable_encoder.py::test_encode_color -q -rs

Expected behavior

The newly added pydantic_extra_types.color.Color encoder path should be covered in at least one required CI/test environment, or the optional-extra coverage should live in an explicit extra-specific test job.

Suggested solution

One of these would make the coverage explicit:

  • Add pydantic-extra-types >=2.0.0 to the tests dependency group, or
  • Add an extra-specific CI/test job that installs fastapi[standard] or fastapi[all] and requires the pydantic_extra_types.color branch to run.

Environment

  • FastAPI commit: ecace74
  • Python via uv run: CPython 3.11.15 on Windows
  • Test command: uv run pytest tests/test_jsonable_encoder.py::test_encode_color -q -rs

Additional context

This is a low-severity coverage issue, not a runtime import failure. The runtime code intentionally treats pydantic_extra_types as optional.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The newly added pydantic_extra_types.color.Color encoder path should be covered in at least one required CI/test environment, or the optional-extra coverage should live in an explicit extra-specific test job.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING