diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-16 20:01:15 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-16 20:01:15 -0500 |
commit | b59304b99037431913781a3506998533618598ef (patch) | |
tree | 50295fb7b0ac60e0e8c3aba1eb99ac478a5f3bba /lib/sqlalchemy/ext/mypy/apply.py | |
parent | 1762c40490182fc511b71f5044f7252e2937162b (diff) | |
download | sqlalchemy-fix_mypy.tar.gz |
fixes for mypy, error in stubsfix_mypy
There's a critical mistake in the stubs that we may want to fix.
Or we might just keep it that way as this is all obsolete
anyway. not sure yet.
Change-Id: I380a1dc177de571b94a176e0f5e5b5d8d4ea2453
Diffstat (limited to 'lib/sqlalchemy/ext/mypy/apply.py')
-rw-r--r-- | lib/sqlalchemy/ext/mypy/apply.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/mypy/apply.py b/lib/sqlalchemy/ext/mypy/apply.py index 99be194cd..745a8d759 100644 --- a/lib/sqlalchemy/ext/mypy/apply.py +++ b/lib/sqlalchemy/ext/mypy/apply.py @@ -44,6 +44,7 @@ def apply_mypy_mapped_attr( api: SemanticAnalyzerPluginInterface, item: Union[NameExpr, StrExpr], attributes: List[util.SQLAlchemyAttribute], + reset_statement_type: bool = False, ) -> None: if isinstance(item, NameExpr): name = item.name @@ -91,6 +92,11 @@ def apply_mypy_mapped_attr( api, stmt, stmt.lvalues[0], left_hand_explicit_type, None ) + if reset_statement_type: + stmt.type = api.named_type( + NAMED_TYPE_SQLA_MAPPED, [AnyType(TypeOfAny.special_form)] + ) + def re_apply_declarative_assignments( cls: ClassDef, @@ -226,6 +232,10 @@ def apply_type_to_mapped_statement( # internally stmt.rvalue = util.expr_to_mapped_constructor(stmt.rvalue) + # this works for every test except the dataclasses one + if stmt.type is not None and python_type_for_type is not None: + stmt.type = python_type_for_type + def add_additional_orm_attributes( cls: ClassDef, |