module documentation

Undocumented

Function ​_apply​_placeholder​_attr​_to​_class Undocumented
Function add​_additional​_orm​_attributes Apply __init__, __table__ and other attributes to the mapped class.
Function apply​_mypy​_mapped​_attr Undocumented
Function apply​_type​_to​_mapped​_statement Apply the Mapped[<type>] annotation and right hand object to a declarative assignment statement.
Function re​_apply​_declarative​_assignments For multiple class passes, re-apply our left-hand side types as mypy seems to reset them in place.
def _apply_placeholder_attr_to_class(api, cls, qualified_name, attrname):

Undocumented

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
cls:ClassDefUndocumented
qualified​_name:strUndocumented
attrname:strUndocumented
def add_additional_orm_attributes(cls, api, attributes):
Apply __init__, __table__ and other attributes to the mapped class.
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
attributes:List[util.SQLAlchemyAttribute]Undocumented
def apply_mypy_mapped_attr(cls, api, item, attributes):

Undocumented

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
item:Union[NameExpr, StrExpr]Undocumented
attributes:List[util.SQLAlchemyAttribute]Undocumented
def apply_type_to_mapped_statement(api, stmt, lvalue, left_hand_explicit_type, python_type_for_type):

Apply the Mapped[<type>] annotation and right hand object to a declarative assignment statement.

This converts a Python declarative class statement such as:

class User(Base):
    # ...

    attrname = Column(Integer)

To one that describes the final Python behavior to Mypy:

class User(Base):
    # ...

    attrname : Mapped[Optional[int]] = <meaningless temp node>
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
lvalue:NameExprUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
python​_type​_for​_type:Optional[ProperType]Undocumented
def re_apply_declarative_assignments(cls, api, attributes):
For multiple class passes, re-apply our left-hand side types as mypy seems to reset them in place.
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
attributes:List[util.SQLAlchemyAttribute]Undocumented