Skip to content

fix Infer SQLAlchemy mapped_column type #1600#1908

Open
asukaminato0721 wants to merge 6 commits into
facebook:mainfrom
asukaminato0721:1600
Open

fix Infer SQLAlchemy mapped_column type #1600#1908
asukaminato0721 wants to merge 6 commits into
facebook:mainfrom
asukaminato0721:1600

Conversation

@asukaminato0721

Copy link
Copy Markdown
Contributor

Summary

Fixes #1600

Added a dedicated FunctionKind::SqlAlchemyMappedColumn plus a SpecialExport::SqlAlchemyMappedColumn / ClassKind match so that references to sqlalchemy.orm.mapped_column (and the re-exported MappedColumn class) are treated as dataclass-style field specifiers instead of opaque callables.

Introduced a special-call path for mapped_column(...) that inspects the supplied column type (positional or type_= keyword), walks the TypeEngine[T] hierarchy to recover the Python type argument, and rewrites the returned descriptor so its generic argument is that inferred type.

Test Plan

Added a regression test with a minimal SQLAlchemy stub package; the test asserts that reveal_type now shows MappedColumn[str] / MappedColumn[int] when using mapped_column(String()) and mapped_column(Integer).

@meta-cla meta-cla Bot added the cla signed label Dec 20, 2025
@asukaminato0721 asukaminato0721 marked this pull request as ready for review December 20, 2025 12:03
Copilot AI review requested due to automatic review settings December 20, 2025 12:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds type inference support for SQLAlchemy's mapped_column() function to correctly infer the Python type from the column type specification. When mapped_column(String()) or mapped_column(Integer) is used, the type checker now infers MappedColumn[str] or MappedColumn[int] respectively, instead of the generic MappedColumn[Any].

Key changes:

  • Introduced FunctionKind::SqlAlchemyMappedColumn and SpecialExport::SqlAlchemyMappedColumn to recognize the mapped_column function
  • Implemented type inference logic that walks the TypeEngine[T] hierarchy to extract the Python type argument
  • Configured MappedColumn class to be treated as a DataclassField for proper field handling

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyrefly/lib/test/sqlalchemy.rs Adds regression test with SQLAlchemy stubs verifying type inference for both instance and class column type specifications
pyrefly/lib/test/mod.rs Registers the new sqlalchemy test module
pyrefly/lib/export/special.rs Adds SpecialExport variant for mapped_column and module matching logic
pyrefly/lib/alt/special_calls.rs Implements the core type inference logic to extract Python types from TypeEngine hierarchy and apply them to MappedColumn
pyrefly/lib/alt/call.rs Integrates the special call handler into the call dispatch logic
crates/pyrefly_types/src/class.rs Maps MappedColumn class kind to DataclassField for consistent field handling
crates/pyrefly_types/src/callable.rs Adds FunctionKind variant and module/name matching for mapped_column function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyrefly/lib/alt/special_calls.rs Outdated
@rchen152

Copy link
Copy Markdown
Contributor

Hey @asukaminato0721 - just want to give you a heads up that a lot of our team is out for the rest of the year, so it may take us a little longer than usual to get to your PRs. Thanks for all the excellent work, and happy holidays!

@grievejia grievejia self-assigned this Dec 22, 2025
@meta-codesync

meta-codesync Bot commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

@grievejia has imported this pull request. If you are a Meta employee, you can view this in D89687087.

@rchen152 rchen152 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@grievejia grievejia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for the late response! @rchen152 was kind enough to perform an in-depth review of the PR. I'm just forwarding her comments here.

Comment on lines +865 to +868
("sqlalchemy.orm", None, "mapped_column")
| ("sqlalchemy.orm._orm_constructors", None, "mapped_column") => {
Self::SqlAlchemyMappedColumn
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you mind elaborating why 2 entires are added here? I'd usually expect sqlalchemy.orm.mapped_column to be the canonical name and the other one just an implementation detail that's ok to drop, unless things get moved around between Python versions or something like that.

Comment thread crates/pyrefly_types/src/class.rs Outdated
Comment thread pyrefly/lib/export/special.rs
Comment thread pyrefly/lib/alt/special_calls.rs Outdated
Comment thread pyrefly/lib/alt/special_calls.rs Outdated
Comment thread pyrefly/lib/alt/special_calls.rs
}
}

fn python_type_from_type_engine_class(&self, cls: &ClassType) -> Option<Type> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Using get_mro_for_class + ancestors_no_object might be cleaner and more consistent with pre-existing patterns in the codebase.

Comment thread pyrefly/lib/alt/special_calls.rs Outdated
Comment thread pyrefly/lib/alt/special_calls.rs Outdated
Comment thread pyrefly/lib/test/sqlalchemy.rs Outdated
@github-actions

This comment has been minimized.

@asukaminato0721 asukaminato0721 marked this pull request as draft January 14, 2026 10:51
@github-actions

This comment has been minimized.

@asukaminato0721

Copy link
Copy Markdown
Contributor Author

seems there are some problems with MappedColumn and Mapped.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

asukaminato0721 and others added 6 commits June 21, 2026 23:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
.
.

.
@github-actions

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

optuna (https://github.com/optuna/optuna)
+ ERROR optuna/storages/_rdb/models.py:214:22-43: Argument `Column[float] | Mapped[_N | None]` is not assignable to parameter `column` with type `(() -> ColumnElement[float]) | ColumnElement[float] | ExpressionElementRole[float] | LambdaElement | SQLCoreOperations[float] | TypedColumnsClauseRole[float] | _HasClauseElement[float] | str` in function `sqlalchemy.sql._elements_constructors.desc` [bad-argument-type]
+ ERROR optuna/storages/_rdb/models.py:249:21-42: Argument `Column[float] | Mapped[_N | None]` is not assignable to parameter `column` with type `(() -> ColumnElement[float]) | ColumnElement[float] | ExpressionElementRole[float] | LambdaElement | SQLCoreOperations[float] | TypedColumnsClauseRole[float] | _HasClauseElement[float] | str` in function `sqlalchemy.sql._elements_constructors.asc` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:347:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:347:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | Mapped[str | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:359:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:359:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | Mapped[str | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:366:16-24: Returned type `Column[int] | MappedColumn[Any]` is not assignable to declared return type `int` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:366:16-24: Returned type `Column[int] | Mapped[int]` is not assignable to declared return type `int` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:373:16-26: Returned type `Column[str] | MappedColumn[Any]` is not assignable to declared return type `str` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:373:16-26: Returned type `Column[str] | Mapped[str]` is not assignable to declared return type `str` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:387:48-63: Argument `Column[str] | MappedColumn[Any]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:387:48-63: Argument `Column[str] | Mapped[str | None]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:389:16-26: Returned type `dict[Column[str] | MappedColumn[Any], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:389:16-26: Returned type `dict[Column[str] | Mapped[str | None], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:396:50-65: Argument `Column[str] | MappedColumn[Any]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:396:50-65: Argument `Column[str] | Mapped[str | None]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:398:16-28: Returned type `dict[Column[str] | MappedColumn[Any], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:398:16-28: Returned type `dict[Column[str] | Mapped[str | None], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:406:48-63: Argument `Column[str] | MappedColumn[Any]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:406:48-63: Argument `Column[str] | Mapped[str | None]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:408:16-26: Returned type `dict[Column[str] | MappedColumn[Any], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:408:16-26: Returned type `dict[Column[str] | Mapped[str | None], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:416:50-65: Argument `Column[str] | MappedColumn[Any]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:416:50-65: Argument `Column[str] | Mapped[str | None]` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:418:16-28: Returned type `dict[Column[str] | MappedColumn[Any], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:418:16-28: Returned type `dict[Column[str] | Mapped[str | None], Any]` is not assignable to declared return type `dict[str, Any]` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:485:33-45: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `value` with type `int` in function `optuna.trial._frozen.FrozenTrial.number` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:485:33-45: Argument `Column[int] | Mapped[int | None]` is not assignable to parameter `value` with type `int` in function `optuna.trial._frozen.FrozenTrial.number` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:486:41-61: Argument `Column[datetime] | MappedColumn[Any]` is not assignable to parameter `value` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.datetime_start` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:486:41-61: Argument `Column[datetime] | Mapped[datetime | None]` is not assignable to parameter `value` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.datetime_start` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:487:36-50: `Column[int] | MappedColumn[Any]` is not assignable to attribute `_trial_id` with type `int` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:487:36-50: `Column[int] | Mapped[int]` is not assignable to attribute `_trial_id` with type `int` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:490:24-36: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `number` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:490:24-36: Argument `Column[int] | Mapped[int | None]` is not assignable to parameter `number` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:491:23-34: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `state` with type `TrialState` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:491:23-34: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `state` with type `TrialState` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:494:32-52: Argument `Column[datetime] | MappedColumn[Any]` is not assignable to parameter `datetime_start` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:494:32-52: Argument `Column[datetime] | Mapped[datetime | None]` is not assignable to parameter `datetime_start` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:501:26-40: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:501:26-40: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:576:30-44: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_param_without_commit` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:576:30-44: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_param_without_commit` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:581:62-76: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_attr_without_commit` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:581:62-76: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_attr_without_commit` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:586:64-78: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_attr_without_commit` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:586:64-78: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_attr_without_commit` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:591:30-44: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_intermediate_value_without_commit` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:591:30-44: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `RDBStorage._set_trial_intermediate_value_without_commit` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:594:27-47: `TrialState` is not assignable to attribute `state` with type `Column[Unknown] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:594:27-47: `TrialState` is not assignable to attribute `state` with type `Column[Unknown] | Mapped[str]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:596:24-56: `int` is not assignable to attribute `number` with type `Column[int] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:596:24-56: `int` is not assignable to attribute `number` with type `Column[int] | Mapped[int | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:638:49-60: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:638:49-60: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:650:21-54: Argument `Column[str] | MappedColumn[Any]` is not assignable to parameter `json_str` with type `str` in function `optuna.distributions.json_to_distribution` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:650:21-54: Argument `Column[str] | Mapped[str | None]` is not assignable to parameter `json_str` with type `str` in function `optuna.distributions.json_to_distribution` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:673:16-27: Returned type `Column[float] | MappedColumn[Any]` is not assignable to declared return type `float` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:673:16-27: Returned type `Column[float] | Mapped[_N | None]` is not assignable to declared return type `float` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:681:57-68: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:681:57-68: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:690:31-36: `TrialState` is not assignable to attribute `state` with type `Column[Unknown] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:690:31-36: `TrialState` is not assignable to attribute `state` with type `Column[Unknown] | Mapped[str]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:693:44-58: `datetime` is not assignable to attribute `datetime_start` with type `Column[datetime] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:693:44-58: `datetime` is not assignable to attribute `datetime_start` with type `Column[datetime] | Mapped[datetime | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:696:47-61: `datetime` is not assignable to attribute `datetime_complete` with type `Column[datetime] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:696:47-61: `datetime` is not assignable to attribute `datetime_complete` with type `Column[datetime] | Mapped[datetime | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:708:39-53: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:708:39-53: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:708:55-66: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:708:55-66: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:721:33-45: `float | None` is not assignable to attribute `value` with type `Column[float] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:721:33-45: `float | None` is not assignable to attribute `value` with type `Column[float] | Mapped[_N | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:722:38-48: `TrialValueModel.TrialValueType` is not assignable to attribute `value_type` with type `Column[Unknown] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:722:38-48: `TrialValueModel.TrialValueType` is not assignable to attribute `value_type` with type `Column[Unknown] | Mapped[str]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:740:49-60: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:740:49-60: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:760:59-71: `float | None` is not assignable to attribute `intermediate_value` with type `Column[float] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:760:59-71: `float | None` is not assignable to attribute `intermediate_value` with type `Column[float] | Mapped[_N | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:761:64-74: `TrialIntermediateValueModel.TrialIntermediateValueType` is not assignable to attribute `intermediate_value_type` with type `Column[Unknown] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:761:64-74: `TrialIntermediateValueModel.TrialIntermediateValueType` is not assignable to attribute `intermediate_value_type` with type `Column[Unknown] | Mapped[str]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:792:49-60: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:792:49-60: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `trial_state` with type `TrialState` in function `optuna.storages._base.BaseStorage.check_trial_is_updatable` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:827:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:827:40-57: `str` is not assignable to attribute `value_json` with type `Column[str] | Mapped[str | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:944:20-32: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `number` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:944:20-32: Argument `Column[int] | Mapped[int | None]` is not assignable to parameter `number` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:945:19-30: Argument `Column[Unknown] | MappedColumn[Any]` is not assignable to parameter `state` with type `TrialState` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:945:19-30: Argument `Column[Unknown] | Mapped[str]` is not assignable to parameter `state` with type `TrialState` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:948:28-48: Argument `Column[datetime] | MappedColumn[Any]` is not assignable to parameter `datetime_start` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:948:28-48: Argument `Column[datetime] | Mapped[datetime | None]` is not assignable to parameter `datetime_start` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:949:31-54: Argument `Column[datetime] | MappedColumn[Any]` is not assignable to parameter `datetime_complete` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:949:31-54: Argument `Column[datetime] | Mapped[datetime | None]` is not assignable to parameter `datetime_complete` with type `datetime | None` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:970:22-36: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
+ ERROR optuna/storages/_rdb/storage.py:970:22-36: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `optuna.trial._frozen.FrozenTrial.__init__` [bad-argument-type]
- ERROR optuna/storages/_rdb/storage.py:1057:39-86: `Any | None` is not assignable to attribute `heartbeat` with type `Column[datetime] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:1057:39-86: `Any | None` is not assignable to attribute `heartbeat` with type `Column[datetime] | Mapped[datetime]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:1090:16-31: Returned type `list[Column[int] | MappedColumn[Any]]` is not assignable to declared return type `list[int]` [bad-return]
+ ERROR optuna/storages/_rdb/storage.py:1090:16-31: Returned type `list[Column[int] | Mapped[int]]` is not assignable to declared return type `list[int]` [bad-return]
- ERROR optuna/storages/_rdb/storage.py:1215:43-64: `Literal[12]` is not assignable to attribute `schema_version` with type `Column[int] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:1215:43-64: `Literal[12]` is not assignable to attribute `schema_version` with type `Column[int] | Mapped[int | None]` [bad-assignment]
- ERROR optuna/storages/_rdb/storage.py:1216:44-63: `str` is not assignable to attribute `library_version` with type `Column[str] | MappedColumn[Any]` [bad-assignment]
+ ERROR optuna/storages/_rdb/storage.py:1216:44-63: `str` is not assignable to attribute `library_version` with type `Column[str] | Mapped[str | None]` [bad-assignment]
- ERROR tests/storages_tests/rdb_tests/test_models.py:53:60-74: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:53:60-74: Argument `Column[int] | Mapped[int]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:66:60-74: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:66:60-74: Argument `Column[int] | Mapped[int]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:71:60-74: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:71:60-74: Argument `Column[int] | Mapped[int]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudyDirectionModel.where_study_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:99:66-87: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudySystemAttributeModel.where_study_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:99:66-87: Argument `Column[int] | Mapped[int]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudySystemAttributeModel.where_study_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:100:66-86: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudySystemAttributeModel.where_study_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:100:66-86: Argument `Column[int] | Mapped[int]` is not assignable to parameter `study_id` with type `int` in function `optuna.storages._rdb.models.StudySystemAttributeModel.where_study_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:301:55-69: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `optuna.storages._rdb.models.TrialValueModel.where_trial_id` [bad-argument-type]
+ ERROR tests/storages_tests/rdb_tests/test_models.py:301:55-69: Argument `Column[int] | Mapped[int]` is not assignable to parameter `trial_id` with type `int` in function `optuna.storages._rdb.models.TrialValueModel.where_trial_id` [bad-argument-type]
- ERROR tests/storages_tests/rdb_tests/test_models.py:316:56-70: Argument `Column[int] | MappedColumn[Any]` is not assignable to parameter `trial_id` with type `int` in function `optuna.storages._rdb.models.TrialValueModel.where_trial_id` [bad-argument-type]

... (truncated 19 lines) ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment