Skip to content

Conversation

youhogeon-meritz
Copy link

Starting with version 0.0.26, users of pyright (strict mode) encounter a typing error.
For more details, please refer to discussion #1598.

This occurs when importing Field and can be resolved by removing the unnecessary from __future__ import annotations.

User Code (to reproduce this bug)

from sqlmodel import Field # <- pyright error occurs here

# do something
pyright app
/root/sqlmodel/app/test.py
  /root/sqlmodel/app/test.py:1:22 - error: Type of "Field" is partially unknown
    Type of "Field" is "Overload[(default: Any = Undefined, *, default_factory: (() -> Any) | None = None, alias: str | None = None, title: str | None = None, description: str | None = None, exclude: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, include: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, max_digits: int | None = None, decimal_places: int | None = None, min_items: int | None = None, max_items: int | None = None, unique_items: bool | None = None, min_length: int | None = None, max_length: int | None = None, allow_mutation: bool = True, regex: str | None = None, discriminator: str | None = None, repr: bool = True, primary_key: bool | Unknown | PydanticUndefinedType = Undefined, foreign_key: Any = Undefined, unique: bool | Unknown | PydanticUndefinedType = Undefined, nullable: bool | Unknown | PydanticUndefinedType = Undefined, index: bool | Unknown | PydanticUndefinedType = Undefined, sa_type: Type[Any] | Unknown | PydanticUndefinedType = Undefined, sa_column_args: Sequence[Any] | Unknown | PydanticUndefinedType = Undefined, sa_column_kwargs: Mapping[str, Any] | Unknown | PydanticUndefinedType = Undefined, schema_extra: Dict[str, Any] | None = None) -> Any, (default: Any = Undefined, *, default_factory: (() -> Any) | None = None, alias: str | None = None, title: str | None = None, description: str | None = None, exclude: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, include: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, max_digits: int | None = None, decimal_places: int | None = None, min_items: int | None = None, max_items: int | None = None, unique_items: bool | None = None, min_length: int | None = None, max_length: int | None = None, allow_mutation: bool = True, regex: str | None = None, discriminator: str | None = None, repr: bool = True, primary_key: bool | Unknown | PydanticUndefinedType = Undefined, foreign_key: str, ondelete: Unknown | PydanticUndefinedType | Literal['CASCADE', 'SET NULL', 'RESTRICT'] = Undefined, unique: bool | Unknown | PydanticUndefinedType = Undefined, nullable: bool | Unknown | PydanticUndefinedType = Undefined, index: bool | Unknown | PydanticUndefinedType = Undefined, sa_type: Type[Any] | Unknown | PydanticUndefinedType = Undefined, sa_column_args: Sequence[Any] | Unknown | PydanticUndefinedType = Undefined, sa_column_kwargs: Mapping[str, Any] | Unknown | PydanticUndefinedType = Undefined, schema_extra: Dict[str, Any] | None = None) -> Any, (default: Any = Undefined, *, default_factory: (() -> Any) | None = None, alias: str | None = None, title: str | None = None, description: str | None = None, exclude: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, include: AbstractSet[int | str] | Mapping[int | str, Any] | Any = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, max_digits: int | None = None, decimal_places: int | None = None, min_items: int | None = None, max_items: int | None = None, unique_items: bool | None = None, min_length: int | None = None, max_length: int | None = None, allow_mutation: bool = True, regex: str | None = None, discriminator: str | None = None, repr: bool = True, sa_column: Column[Any] | Unknown | PydanticUndefinedType = Undefined, schema_extra: Dict[str, Any] | None = None) -> Any]" (reportUnknownVariableType)
1 errors, 0 warnings, 0 informations

@youhogeon-meritz youhogeon-meritz changed the title 🐛 fix: remove unused __future__ import (for pyright strict users) 🐛 fix: remove unused __future__ import (to resolve pyright type errors) Oct 13, 2025
@youhogeon-meritz youhogeon-meritz marked this pull request as draft October 13, 2025 09:25
@youhogeon-meritz youhogeon-meritz marked this pull request as ready for review October 13, 2025 09:33
@youhogeon-meritz
Copy link
Author

I apologize for the confusing PR log. I don't know how to add labels.

@youhogeon-meritz youhogeon-meritz changed the title 🐛 fix: remove unused __future__ import (to resolve pyright type errors) 🐛 fix: remove unused __future__ import (to resolve pyright type errors) and remove unnecessary mypy ignore comments Oct 13, 2025
@youhogeon-meritz youhogeon-meritz marked this pull request as draft October 13, 2025 09:56
@youhogeon-meritz
Copy link
Author

youhogeon-meritz commented Oct 13, 2025

To fix failure CI, #1603 must be merged.

@youhogeon-meritz youhogeon-meritz changed the title 🐛 fix: remove unused __future__ import (to resolve pyright type errors) and remove unnecessary mypy ignore comments 🐛 fix: remove unused __future__ import (to resolve pyright type errors) Oct 14, 2025
@youhogeon-meritz youhogeon-meritz marked this pull request as ready for review October 14, 2025 01:06
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