Skip to content

Fix boolean JSON Schema overrides for typed fields - #153

Merged
wRAR merged 1 commit into
scrapy:masterfrom
febug:fix/boolean-schema-overrides
Nov 13, 2026
Merged

wRAR merged 1 commit into
scrapy:masterfrom
febug:fix/boolean-schema-overrides

Conversation

@yuxino

@yuxino yuxino commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

ItemAdapter.get_json_schema() raises AttributeError when a typed mapping field uses json_schema_extra with additionalProperties: False, such as a quantity mapping that only allows named sizes. Boolean items overrides on typed sequences fail for the same reason.

Preserve explicit boolean schemas instead of trying to infer types into them. Dictionary-valued schemas and fields without overrides retain their existing type inference.

The five regression cases fail on the original implementation and pass with this fix. The test suite (excluding optional CodSpeed benchmarks), README examples, type/lint checks, and package checks pass on Python 3.14. Independent checks also verified the generated schemas and their validation behavior across dataclass, TypedDict, attrs, Pydantic and Scrapy items.

AI assistance: this change was prepared and checked with OpenAI Codex.

@AdrianAtZyte
AdrianAtZyte requested a review from wRAR November 13, 2026 11:43
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (9bab3af) to head (8c8f352).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #153   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files           6        6           
  Lines         842      844    +2     
  Branches      160      161    +1     
=======================================
+ Hits          841      843    +2     
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 24 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing febug:fix/boolean-schema-overrides (8c8f352) with master (9bab3af)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@wRAR
wRAR merged commit 4983811 into scrapy:master Nov 13, 2026
26 checks passed
@yuxino
yuxino deleted the fix/boolean-schema-overrides branch November 13, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants