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

Lock dependencies by major version only #195

Merged
merged 2 commits into from Dec 11, 2023
Merged

Conversation

MarshalX
Copy link
Owner

@MarshalX MarshalX commented Dec 10, 2023

tests have been failed. because of not properly resolved union after upgrading:

Updating pydantic (2.4.2 -> 2.5.2)

probably related to https://github.com/pydantic/pydantic-core/pull/ 867 (del ref)

more details

we have these types:

UnknownRecordTypePydantic = te.Annotated[
    t.Union[
        'models.AppBskyActorProfile.Main',
        'models.AppBskyFeedGenerator.Main',
        'models.AppBskyFeedLike.Main',
        'models.AppBskyFeedPost.Main',
        'models.AppBskyFeedRepost.Main',
        'models.AppBskyFeedThreadgate.Main',
        'models.AppBskyGraphBlock.Main',
        'models.AppBskyGraphFollow.Main',
        'models.AppBskyGraphList.Main',
        'models.AppBskyGraphListblock.Main',
        'models.AppBskyGraphListitem.Main',
    ],
    Field(discriminator='py_type'),
]
UnknownType: te.TypeAlias = t.Union[UnknownRecordTypePydantic, 'dot_dict.DotDictType']

the logic that was before upgrading: try to match type one from UnknownRecordTypePydantic using py_type field; if there is no match fallback to DotDictType

the logic after upgrading: it resolved all types as DotDictType

BUT when i delete DotDictType from the Union it resolves fine (ofc doesn't fallback to DotDictType but resolved the UnknownRecordTypePydantic)!

UnknownType: te.TypeAlias = t.Union[UnknownRecordTypePydantic]

all the models in UnknownRecordTypePydantic Unioin use this config:

model_config = ConfigDict(extra='forbid', populate_by_name=True, strict=True)

so what should I do now to save strict=True, and exit from Union matching right after matching by discriminator (py_type) field?

upd. strict=False doesn't help

@MarshalX
Copy link
Owner Author

after upgrading pydantic (2.4.2 -> 2.5.2) it starts mutating input data somehow. it should not affect real cases. tests load test data for each test now

@MarshalX MarshalX merged commit 9ffc6d1 into main Dec 11, 2023
25 checks passed
@MarshalX MarshalX deleted the unlock-minor-vers-of-deps branch December 11, 2023 11:08
@davidhewitt
Copy link

@MarshalX thanks for the ping on the smart union PR, is there a minimal repro you can share which exhibits the tagged union interaction? I'm very happy to take a look.

@MarshalX
Copy link
Owner Author

MarshalX commented Dec 11, 2023

@davidhewitt happy to see you here! I tried to prepare a small script with reproducing but later found that failed unit tests work fine out of tests... That was something with the mutation of test data. Before pydantic 2.5.0 data wasn't mutated. Not the Union problem (ig). Sorry for disturb. I didn't investigate the mutation and what causes it

@MarshalX
Copy link
Owner Author

@davidhewitt i created a corresponding issue about data mutation with reproducing. just wondering why the behaviour was changed pydantic/pydantic#8349

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.

None yet

2 participants