-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
AttributeError: __qualname__ on Python 3.9 with typing.Sequence, Collection, Iterable or other generic aliases #493
Comments
Somehow uv run --isolated --no-project --with pydantic-settings --with pydantic==2.10.0 --python python3.9 - <<EOF
from pydantic_settings import BaseSettings, CliSettingsSource
from typing import *
class S(BaseSettings):
s: Sequence[int] # or Collection, Iterable, etc.
CliSettingsSource(S)
print("success")
EOF Results in:
But: uv run --isolated --no-project --with pydantic-settings --with pydantic~=2.9.0 --python python3.9 - <<EOF
from pydantic_settings import BaseSettings, CliSettingsSource
from typing import *
class S(BaseSettings):
s: Sequence[int] # or Collection, Iterable, etc.
CliSettingsSource(S)
print("success")
EOF Prints:
|
Thanks @palotasb for reporting this issue. I could reproduce it. question: what do you want to achieve by |
That line creates an instance of The code I shared is just a minimal reproducible example for a more complex bug that we encountered in our internal codebase. The original code is proprietary so I can't share it, but this smaller example also makes it easier to identify and fix the underlying issue. In our real codebase |
To reproduce:
The error also happens when using types based on
typing._BaseGenericAlias
, liketyping.Collection
ortyping.Iterable
The call ultimately fails on this line:
https://github.com/python/cpython/blob/3.9/Lib/typing.py#L711
The support for
.__qualname__
for generic aliases was added only in Python 3.10:https://github.com/python/cpython/blob/3.10/Lib/typing.py#L977
Hence this call on Python 3.9 is wrong:
https://github.com/pydantic/pydantic-settings/blob/v2.6.1/pydantic_settings/sources.py#L1874
The text was updated successfully, but these errors were encountered: