Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify flatteining and inlining of Coreschema #7523

Merged
merged 3 commits into from Sep 20, 2023

Conversation

adriangb
Copy link
Member

@adriangb adriangb commented Sep 20, 2023

Selected Reviewer: @davidhewitt

@cloudflare-pages
Copy link

cloudflare-pages bot commented Sep 20, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6d85d7c
Status: ✅  Deploy successful!
Preview URL: https://b62189bd.pydantic-docs2.pages.dev
Branch Preview URL: https://simplify-schema-flattening.pydantic-docs2.pages.dev

View logs

@adriangb
Copy link
Member Author

please review

Comment on lines 41 to 45
IntModel = Model[int]

assert IntModel.model_validate({'a': '1'}).a == 1

sig = signature(IntModel)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the cause of this is that the following code is firing on this branch from _model_construction.py:

    if collect_invalid_schemas(schema):
        set_model_mocks(cls, cls_name)
        return False

I suggest we understand this further - smells like a possible bug.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's xfail instead of modify, I will dig into this in parallel.

@adriangb adriangb enabled auto-merge (squash) September 20, 2023 15:03
@adriangb adriangb merged commit c5dce37 into main Sep 20, 2023
49 checks passed
@adriangb adriangb deleted the simplify-schema-flattening branch September 20, 2023 15:08
@davidhewitt davidhewitt added the relnotes-performance Used for performance improvements. label Sep 21, 2023
@JrooTJunior
Copy link

@dmontagu, @samuelcolvin, this changes breaks compatibility of https://github.com/aiogram/aiogram with pydantic 2.4

  File "/home/jrootjunior/work/aiogram/aiogram3/.hatch/dev/lib/python3.11/site-packages/pydantic/_internal/_core_utils.py", line 515, in count_refs
    recurse(state['definitions'][ref], count_refs)
            ~~~~~~~~~~~~~~~~~~~~^^^^^
KeyError: 'aiogram.types.input_text_message_content.InputTextMessageContent:94580207914144'

(full traceback)

You can check it by installing pip install aiogram==3.1.0 and then just import it - import aiogram.
I have temporary workaround - restrict to install pydantic 2.4 with aiogram, so, when you install pip install aiogram=3.1.1 and then import it - it works as well.

@davidhewitt
Copy link
Contributor

Thanks for the report, we're investigating.

Comment on lines 47 to 49
# we assume the shape of the core schema here, which is not a guarantee
# pydantic makes to its users but is useful to check here to make sure
# we are doing the right thing internally

This comment was marked as outdated.

@adriangb

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review relnotes-performance Used for performance improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants