Skip to content

Fix warnings about the Config class being deprecated in Pydantic 3 #67

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samn
Copy link

@samn samn commented Apr 8, 2025

Also upgrades a couple of dev dependencies needed to get the build running.

Fixes the following warning that Pydantic v2 issues used with this library:

PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

Also upgrades a couple of dev dependencies needed to get
the build running.
Comment on lines +46 to +50
if _PYDANTIC_2_0:
model_config = pydantic.ConfigDict(populate_by_name=True)
else:

class Config:
Copy link
Author

Choose a reason for hiding this comment

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

Ran a little test in the repl to show that this works:

>>> class A:
...     if True:
...             a_field = 1
...     else:
...             class SubClass:
...                     b_field = 2
... 
>>> A().a_field
1
>>> A().b_field
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'A' object has no attribute 'b_field'. Did you mean: 'a_field'?
>>> class A:
...     if False:
...             a_field = 1
...     else:
...             class SubClass:
...                     b_field = 2
... 
>>> A().a_field
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'A' object has no attribute 'a_field'
>>> A().SubClass
<class '__main__.A.SubClass'>
>>> A().SubClass().b_field
2

@samn
Copy link
Author

samn commented Apr 8, 2025

@microsoft-github-policy-service agree [company="Upstream Tech"]

@samn
Copy link
Author

samn commented Apr 8, 2025

@microsoft-github-policy-service agree company="Upstream Tech"

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.

1 participant