FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

馃悰 fix: remove unused __future__ import (to resolve pyright type errors) by youhogeon-meritz 路 Pull Request #1604 路 fastapi/sqlmodel 路 GitHub

Repository navigation

馃悰 fix: remove unused __future__ import (to resolve pyright type errors) - #1604

Closed
youhogeon-meritz wants to merge 3 commits into
fastapi:mainfrom
youhogeon-meritz:fix/discussions_#1598
Closed

youhogeon-meritz wants to merge 3 commits into
fastapi:mainfrom
youhogeon-meritz:fix/discussions_#1598

Conversation

Copy link
Copy Markdown

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 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 marked this pull request as draft October 13, 2025 09:25
youhogeon-meritz marked this pull request as ready for review October 13, 2025 09:33

Copy link
Copy Markdown
Author

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

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 marked this pull request as draft October 13, 2025 09:56

youhogeon-meritz commented Oct 13, 2025 •
edited
Loading

Copy link
Copy Markdown
Author

To fix failure CI, #1603 must be merged.

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 marked this pull request as ready for review October 14, 2025 01:06

svlandeg commented Oct 21, 2025 •
edited
Loading

Copy link
Copy Markdown
Member

To fix failure CI, #1603 must be merged.

The unrelated CI failures were fixed by #1613.

However, we'll still have an issue here: Python 3.9 tests fail due to mypy warnings around the | syntax (i.e. the import removed by this PR was there for a reason...)

svlandeg marked this pull request as draft October 21, 2025 10:51
svlandeg added the internal Internal changes label Oct 21, 2025
youhogeon-meritz marked this pull request as ready for review November 5, 2025 02:04
youhogeon-meritz marked this pull request as draft November 5, 2025 02:05

Copy link
Copy Markdown

Hi, there's some discussion here: #1598
I have tracked down the root cause and proposed a fix (but I don't really know if its right). It does not remove the annotation.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL