-
-
Notifications
You must be signed in to change notification settings - Fork 368
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
After upgrading to Pydantic v2.12, the BaseModel
construction fails with the following error for the class AuthOtpResponse
:
.nox/test/lib/python3.14/site-packages/supabase/__init__.py:1: in <module>
from supabase_auth.errors import (
.nox/test/lib/python3.14/site-packages/supabase_auth/__init__.py:3: in <module>
from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/supabase_auth/_async/gotrue_admin_api.py:6: in <module>
from ..helpers import (
.nox/test/lib/python3.14/site-packages/supabase_auth/helpers.py:27: in <module>
from .types import (
.nox/test/lib/python3.14/site-packages/supabase_auth/types.py:104: in <module>
class AuthOtpResponse(BaseModel):
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_model_construction.py:242: in __new__
set_model_fields(cls, config_wrapper=config_wrapper, ns_resolver=ns_resolver)
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_model_construction.py:566: in set_model_fields
fields, class_vars = collect_model_fields(cls, config_wrapper, ns_resolver, typevars_map=typevars_map)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_fields.py:364: in collect_model_fields
field_info = FieldInfo_.from_annotated_attribute(ann_type, assigned_value, _source=AnnotationSource.CLASS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/pydantic/fields.py:382: in from_annotated_attribute
raise PydanticUserError(
E pydantic.errors.PydanticUserError: Error when building FieldInfo from annotated attribute. Make sure you don't have any field name clashing with a type annotation.
E
E For further information visit https://errors.pydantic.dev/2.12/u/unevaluable-type-annotation
To Reproduce
- Add
supabase
as a dependency - Upgrade
pydantic
tov2.12.0
(required to get Python 3.14 support) - Create a client of Supabase in your test or application
- Run tests or application
- You'll see an error like:
.nox/test/lib/python3.14/site-packages/supabase/__init__.py:1: in <module>
from supabase_auth.errors import (
.nox/test/lib/python3.14/site-packages/supabase_auth/__init__.py:3: in <module>
from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/supabase_auth/_async/gotrue_admin_api.py:6: in <module>
from ..helpers import (
.nox/test/lib/python3.14/site-packages/supabase_auth/helpers.py:27: in <module>
from .types import (
.nox/test/lib/python3.14/site-packages/supabase_auth/types.py:104: in <module>
class AuthOtpResponse(BaseModel):
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_model_construction.py:242: in __new__
set_model_fields(cls, config_wrapper=config_wrapper, ns_resolver=ns_resolver)
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_model_construction.py:566: in set_model_fields
fields, class_vars = collect_model_fields(cls, config_wrapper, ns_resolver, typevars_map=typevars_map)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/pydantic/_internal/_fields.py:364: in collect_model_fields
field_info = FieldInfo_.from_annotated_attribute(ann_type, assigned_value, _source=AnnotationSource.CLASS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.nox/test/lib/python3.14/site-packages/pydantic/fields.py:382: in from_annotated_attribute
raise PydanticUserError(
E pydantic.errors.PydanticUserError: Error when building FieldInfo from annotated attribute. Make sure you don't have any field name clashing with a type annotation.
E
E For further information visit https://errors.pydantic.dev/2.12/u/unevaluable-type-annotation
The expectation is that importing any class from Supabase library shouldn't cause a Pydantic validation error.
Screenshots
None
System information
- OS: All
- Browser (if applies) [e.g. chrome, safari]: N/A
- Version of supabase-py: v2.22.0
- Version of Python: 3.14
Additional context
This is because the check in Pydantic looks like this:
if annotation is not MISSING and annotation is default:
raise PydanticUserError(
'Error when building FieldInfo from annotated attribute. '
"Make sure you don't have any field name clashing with a type annotation.",
code='unevaluable-type-annotation',
)
The validation fails because of a single class:
class AuthOtpResponse(BaseModel):
user: None = None
session: None = None
message_id: Optional[str] = None
Here, the check is that the annotation
(which is None
for both user
and session
) is the same as the default
value, which are None
.
Switching the type of those fields to Literal[None]
fixes the issue.
See PR #1252 for the fix.
anthonyatpll0utr3
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working