module documentation

Undocumented

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
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 Composite.
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_mapped Infer the type of mapping from a right side expression that returns Mapped.
Function _infer_type_from_relationship Infer the type of mapping from a relationship.
def extract_python_type_from_typeengine(api: SemanticAnalyzerPluginInterface, node: TypeInfo, type_args: Sequence[Expression]) -> ProperType: (source)

Undocumented

def infer_type_from_left_hand_type_only(api: SemanticAnalyzerPluginInterface, node: Var, left_hand_explicit_type: Optional[ProperType]) -> Optional[ProperType]: (source)

Determine the type based on explicit annotation only. if no annotation were present, note that we need one there to know the type.

def infer_type_from_right_hand_nameexpr(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType], infer_from_right_side: RefExpr) -> Optional[ProperType]: (source)

Undocumented

def _infer_collection_type_from_left_and_inferred_right(api: SemanticAnalyzerPluginInterface, node: Var, left_hand_explicit_type: Instance, python_type_for_type: Instance) -> Optional[ProperType]: (source)

Undocumented

def _infer_type_from_decl_column(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType], right_hand_expression: Optional[CallExpr] = None) -> Optional[ProperType]: (source)

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]

def _infer_type_from_decl_column_property(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType]) -> Optional[ProperType]: (source)

Infer the type of mapping from a ColumnProperty. This includes mappings against ``column_property()`` as well as the ``deferred()`` function.

def _infer_type_from_decl_composite_property(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType]) -> Optional[ProperType]: (source)

Infer the type of mapping from a Composite.

def _infer_type_from_left_and_inferred_right(api: SemanticAnalyzerPluginInterface, node: Var, left_hand_explicit_type: ProperType, python_type_for_type: ProperType, orig_left_hand_type: Optional[ProperType] = None, orig_python_type_for_type: Optional[ProperType] = None) -> Optional[ProperType]: (source)

Validate type when a left hand annotation is present and we also could infer the right hand side:: attrname: SomeType = Column(SomeDBType)

def _infer_type_from_mapped(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType], infer_from_right_side: RefExpr) -> Optional[ProperType]: (source)

Infer the type of mapping from a right side expression that returns Mapped.

def _infer_type_from_relationship(api: SemanticAnalyzerPluginInterface, stmt: AssignmentStmt, node: Var, left_hand_explicit_type: Optional[ProperType]) -> Optional[ProperType]: (source)

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"]