Merged
Conversation
whitead
approved these changes
Mar 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores JSON schema generation for paperqa.Settings (used by downstream OpenAPI generation) by preventing Pydantic from attempting to generate schemas for callable/arbitrary-type fields.
Changes:
- Wrap several callable/arbitrary-type settings fields in
SkipJsonSchema[...]to avoidPydanticInvalidForJsonSchema. - Add a regression test that exercises
Settings.model_json_schema()during default settings instantiation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/paperqa/settings.py |
Marks several fields as SkipJsonSchema[...] to prevent JSON schema generation failures for callables/protocols. |
tests/test_configs.py |
Adds a regression test that calls Settings.model_json_schema() to ensure schema export doesn’t raise. |
Comments suppressed due to low confidence (1)
src/paperqa/settings.py:293
SkipJsonSchemawill omitparse_pdffrommodel_json_schema(), butParsingSettings’ custom@model_serializercan still includeparse_pdfin JSON (mode="json") as a stable string/FQN. That creates a mismatch between the generated schema/OpenAPI and the actual serialized output. Consider representingparse_pdfas a JSON-schema-friendly type (e.g., string/import-path with custom json schema) instead of skipping it entirely, or ensure it’s never serialized if it shouldn’t be part of the public JSON shape.
parse_pdf: SkipJsonSchema[PDFParserFn] = Field(
default_factory=get_default_pdf_parser,
description="Function to parse PDF, or a fully qualified name to import.",
examples=["paperqa_docling.parse_pdf_to_pages"],
exclude=True, # NOTE: a custom serializer is used below, so it's not excluded
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seen in dev logs when generating an OpenAPI spec:
This PR restores the ability to generate a JSON schema for
paperqa.Settings