Open
Description
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
import sqlalchemy as sa
from sqlalchemy.orm import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
Base = declarative_base()
class Foo(Base):
deleted_at = sa.Column(sa.DateTime(), nullable=True)
@hybrid_property
def is_deleted(cls) -> bool:
return cls.deleted_at is not None
@is_deleted.expression # type: ignore[no-redef]
def is_deleted(cls, v):
return cls.deleted_at.is_not(None)
foo = Foo()
assert foo.is_deleted
Expected Behavior
mypy should report no error.
Actual Behavior
mypy reports the following error on the last line:
error: Function "Callable[..., Any]" could always be true in boolean context [truthy-function]
BTW, if there is no @is_deleted.expression
,just one @hybrid_property
,mypy reports no error.
Your Environment
- mypy version: 0.991
- python version: 3.11.0
- sqlalchemy2-stubs version: 0.0.2a29
- mypy config (in
pyproject.toml
)
[tool.mypy]
plugins = ['sqlalchemy.ext.mypy.plugin']
show_error_codes = true
warn_unused_ignores = true