API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -1,5 +1,5 @@
# ext/mypy/apply.py
# Copyright (C) 2021 the SQLAlchemy authors and contributors
# Copyright (C) 2021-2025 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -161,9 +161,9 @@ def re_apply_declarative_assignments(
# update the SQLAlchemyAttribute with the better
# information
mapped_attr_lookup[
stmt.lvalues[0].name
].type = python_type_for_type
mapped_attr_lookup[stmt.lvalues[0].name].type = (
python_type_for_type
)
update_cls_metadata = True
@@ -199,11 +199,15 @@ def apply_type_to_mapped_statement(
To one that describes the final Python behavior to Mypy::
... format: off
class User(Base):
# ...
attrname : Mapped[Optional[int]] = <meaningless temp node>
... format: on
"""
left_node = lvalue.node
assert isinstance(left_node, Var)
@@ -223,9 +227,11 @@ def apply_type_to_mapped_statement(
lvalue.is_inferred_def = False
left_node.type = api.named_type(
NAMED_TYPE_SQLA_MAPPED,
[AnyType(TypeOfAny.special_form)]
if python_type_for_type is None
else [python_type_for_type],
(
[AnyType(TypeOfAny.special_form)]
if python_type_for_type is None
else [python_type_for_type]
),
)
# so to have it skip the right side totally, we can do this: