module documentation

Undocumented

Function ​_infer​_collection​_type​_from​_left​_and​_inferred​_right Undocumented
Function ​_infer​_type​_from​_decl​_column Infer the type of mapping from a Column.
Function ​_infer​_type​_from​_decl​_column​_property Infer the type of mapping from a ColumnProperty.
Function ​_infer​_type​_from​_decl​_composite​_property Infer the type of mapping from a CompositeProperty.
Function ​_infer​_type​_from​_left​_and​_inferred​_right Validate type when a left hand annotation is present and we also could infer the right hand side:
Function ​_infer​_type​_from​_relationship Infer the type of mapping from a relationship.
Function extract​_python​_type​_from​_typeengine Undocumented
Function infer​_type​_from​_left​_hand​_type​_only Determine the type based on explicit annotation only.
Function infer​_type​_from​_right​_hand​_nameexpr Undocumented
def _infer_collection_type_from_left_and_inferred_right(api, node, left_hand_explicit_type, python_type_for_type):

Undocumented

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:InstanceUndocumented
python​_type​_for​_type:InstanceUndocumented
Returns
Optional[ProperType]Undocumented
def _infer_type_from_decl_column(api, stmt, node, left_hand_explicit_type, right_hand_expression=None):

Infer the type of mapping from a Column.

E.g.:

@reg.mapped
class MyClass:
    # ...

    a = Column(Integer)

    b = Column("b", String)

    c: Mapped[int] = Column(Integer)

    d: bool = Column(Boolean)

Will resolve in MyPy as:

@reg.mapped
class MyClass:
    # ...

    a : Mapped[int]

    b : Mapped[str]

    c: Mapped[int]

    d: Mapped[bool]
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
right​_hand​_expression:Optional[CallExpr]Undocumented
Returns
Optional[ProperType]Undocumented
def _infer_type_from_decl_column_property(api, stmt, node, left_hand_explicit_type):

Infer the type of mapping from a ColumnProperty.

This includes mappings against column_property() as well as the deferred() function.

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
Returns
Optional[ProperType]Undocumented
def _infer_type_from_decl_composite_property(api, stmt, node, left_hand_explicit_type):
Infer the type of mapping from a CompositeProperty.
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
Returns
Optional[ProperType]Undocumented
def _infer_type_from_left_and_inferred_right(api, node, left_hand_explicit_type, python_type_for_type, orig_left_hand_type=None, orig_python_type_for_type=None):

Validate type when a left hand annotation is present and we also could infer the right hand side:

attrname: SomeType = Column(SomeDBType)
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:ProperTypeUndocumented
python​_type​_for​_type:ProperTypeUndocumented
orig​_left​_hand​_type:Optional[ProperType]Undocumented
orig​_python​_type​_for​_type:Optional[ProperType]Undocumented
Returns
Optional[ProperType]Undocumented
def _infer_type_from_relationship(api, stmt, node, left_hand_explicit_type):

Infer the type of mapping from a relationship.

E.g.:

@reg.mapped
class MyClass:
    # ...

    addresses = relationship(Address, uselist=True)

    order: Mapped["Order"] = relationship("Order")

Will resolve in mypy as:

@reg.mapped
class MyClass:
    # ...

    addresses: Mapped[List[Address]]

    order: Mapped["Order"]
Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
Returns
Optional[ProperType]Undocumented
def extract_python_type_from_typeengine(api, node, type_args):

Undocumented

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
node:TypeInfoUndocumented
type​_args:Sequence[Expression]Undocumented
Returns
ProperTypeUndocumented
def infer_type_from_left_hand_type_only(api, node, left_hand_explicit_type):

Determine the type based on explicit annotation only.

if no annotation were present, note that we need one there to know the type.

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
Returns
Optional[ProperType]Undocumented
def infer_type_from_right_hand_nameexpr(api, stmt, node, left_hand_explicit_type, infer_from_right_side):

Undocumented

Parameters
api:SemanticAnalyzerPluginInterfaceUndocumented
stmt:AssignmentStmtUndocumented
node:VarUndocumented
left​_hand​_explicit​_type:Optional[ProperType]Undocumented
infer​_from​_right​_side:RefExprUndocumented
Returns
Optional[ProperType]Undocumented