Skip to content

fix!: ignore private attributes doing equality pydantic#2035

Merged
eakmanrq merged 1 commit intomainfrom
eakmanrq/fix_pydantic_equality_check
Jan 30, 2024
Merged

fix!: ignore private attributes doing equality pydantic#2035
eakmanrq merged 1 commit intomainfrom
eakmanrq/fix_pydantic_equality_check

Conversation

@eakmanrq
Copy link
Contributor

We have an issue that Pydantic includes private attributes in the equality check:
https://github.com/pydantic/pydantic/blob/b785d5b1db4eccb922dd2bf17faea5fc842e6a57/pydantic/main.py#L880

We use these for caching values. When we do equality checks our intent is to check if the public attributes of the class are the same and not if the cached attributes are equal.

This PR has a way of solving this problem but involves mutating the actual objects themselves so it would be best if we had a solution that didn't involve that. Are there Pydantic config properties that can help us here? @izeigerman do you have any ideas? I want to find a solution that works for all Pydantic classes instead requiring each one to provide an override if they introduce private attributes.

@eakmanrq eakmanrq requested a review from izeigerman January 28, 2024 02:13
@eakmanrq eakmanrq force-pushed the eakmanrq/fix_pydantic_equality_check branch 6 times, most recently from 1185463 to 46eb15a Compare January 30, 2024 00:29
@eakmanrq eakmanrq force-pushed the eakmanrq/fix_pydantic_equality_check branch 2 times, most recently from 687e755 to 20d64fb Compare January 30, 2024 00:35
@eakmanrq eakmanrq enabled auto-merge (squash) January 30, 2024 00:36
@eakmanrq eakmanrq force-pushed the eakmanrq/fix_pydantic_equality_check branch from 20d64fb to 12a077b Compare January 30, 2024 00:46
@eakmanrq eakmanrq force-pushed the eakmanrq/fix_pydantic_equality_check branch from 12a077b to e2720c2 Compare January 30, 2024 00:55
@eakmanrq eakmanrq merged commit b906682 into main Jan 30, 2024
@eakmanrq eakmanrq deleted the eakmanrq/fix_pydantic_equality_check branch January 30, 2024 01:03
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.

2 participants