Skip to content

Commit 981887e

Browse files
authored
Change Session.info type annotation from Mapping to MutableMapping (#144)
* Change `Session.info` type annotation from Mapping to MutableMapping Fixes #143 * Change the `info` prop to MutableMapping in other classes as well
1 parent 0503ece commit 981887e

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

sqlalchemy-stubs/engine/base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
22
from typing import Dict
33
from typing import List
4+
from typing import MutableMapping
45
from typing import Optional
56
from typing import TypeVar
67
from typing import Union
@@ -65,7 +66,7 @@ class Connection(Connectable):
6566
@property
6667
def default_isolation_level(self) -> Any: ...
6768
@property
68-
def info(self) -> Dict[Any, Any]: ...
69+
def info(self) -> MutableMapping[Any, Any]: ...
6970
def connect(self: _TConnection, close_with_result: bool = ...) -> _TConnection: ... # type: ignore[override]
7071
def invalidate(self, exception: Optional[Any] = ...) -> None: ...
7172
def detach(self) -> None: ...

sqlalchemy-stubs/ext/asyncio/engine.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from typing import Any
22
from typing import Callable
33
from typing import Generator
44
from typing import Mapping
5+
from typing import MutableMapping
56
from typing import NoReturn
67
from typing import Optional
78
from typing import TypeVar
@@ -48,7 +49,7 @@ class AsyncConnection(
4849
def connection(self) -> NoReturn: ...
4950
async def get_raw_connection(self) -> Any: ...
5051
@property
51-
def info(self) -> Mapping[Any, Any]: ...
52+
def info(self) -> MutableMapping[Any, Any]: ...
5253
def begin(self) -> AsyncTransaction: ...
5354
def begin_nested(self) -> AsyncTransaction: ...
5455
async def invalidate(self, exception: Optional[Any] = ...) -> None: ...

sqlalchemy-stubs/ext/asyncio/session.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing import ContextManager
44
from typing import Iterable
55
from typing import Iterator
66
from typing import Mapping
7+
from typing import MutableMapping
78
from typing import Optional
89
from typing import Sequence
910
from typing import TypeVar
@@ -140,7 +141,7 @@ class AsyncSession:
140141
self: _TAsyncSession,
141142
) -> ContextManager[_TAsyncSession]: ...
142143
@util.memoized_property
143-
def info(self) -> Mapping[Any, Any]: ...
144+
def info(self) -> MutableMapping[Any, Any]: ...
144145

145146
class _AsyncSessionContextManager:
146147
async_session: AsyncSession = ...

sqlalchemy-stubs/orm/session.pyi

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from typing import Iterable
88
from typing import Iterator
99
from typing import List
1010
from typing import Mapping
11+
from typing import MutableMapping
1112
from typing import Optional
1213
from typing import overload
1314
from typing import Sequence
@@ -70,7 +71,7 @@ class _SharedSessionProtocol(Protocol[_T]):
7071
self: _TSharedSessionProtocol,
7172
) -> ContextManager[_TSharedSessionProtocol]: ...
7273
@util.memoized_property
73-
def info(self) -> Mapping[Any, Any]: ...
74+
def info(self) -> MutableMapping[Any, Any]: ...
7475
def __contains__(self, instance: Any) -> bool: ...
7576
def __iter__(self) -> Iterator[Any]: ...
7677
def add(self, instance: Any, _warn: bool = ...) -> None: ...
@@ -405,7 +406,7 @@ class Session(_SessionClassMethods):
405406
twophase: bool = ...,
406407
binds: Optional[Mapping[Any, Union[Connection, Engine]]] = ...,
407408
enable_baked_queries: bool = ...,
408-
info: Optional[Mapping[Any, Any]] = ...,
409+
info: Optional[MutableMapping[Any, Any]] = ...,
409410
query_cls: Optional[
410411
Union[Type[Query[Any]], Callable[..., Query[Any]]]
411412
] = ...,
@@ -422,7 +423,7 @@ class Session(_SessionClassMethods):
422423
def get_transaction(self) -> Optional[SessionTransaction]: ...
423424
def get_nested_transaction(self) -> Optional[SessionTransaction]: ...
424425
@util.memoized_property
425-
def info(self) -> Mapping[Any, Any]: ...
426+
def info(self) -> MutableMapping[Any, Any]: ...
426427
def begin(
427428
self,
428429
subtransactions: bool = ..., # NOTE: Deprecated.
@@ -551,7 +552,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
551552
autoflush: bool = ...,
552553
autocommit: bool = ..., # NOTE: Deprecated.
553554
expire_on_commit: bool = ...,
554-
info: Optional[Mapping[Any, Any]] = ...,
555+
info: Optional[MutableMapping[Any, Any]] = ...,
555556
**kw: Any,
556557
) -> None: ...
557558
@overload
@@ -564,7 +565,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
564565
autoflush: bool = ...,
565566
autocommit: bool = ..., # NOTE: Deprecated.
566567
expire_on_commit: bool = ...,
567-
info: Optional[Mapping[Any, Any]] = ...,
568+
info: Optional[MutableMapping[Any, Any]] = ...,
568569
**kw: Any,
569570
) -> None: ...
570571
@overload
@@ -578,7 +579,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
578579
autoflush: bool = ...,
579580
autocommit: bool = ..., # NOTE: Deprecated.
580581
expire_on_commit: bool = ...,
581-
info: Optional[Mapping[Any, Any]] = ...,
582+
info: Optional[MutableMapping[Any, Any]] = ...,
582583
**kw: Any,
583584
) -> None: ...
584585
else:
@@ -590,7 +591,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
590591
autoflush: bool = ...,
591592
autocommit: bool = ..., # NOTE: Deprecated.
592593
expire_on_commit: bool = ...,
593-
info: Optional[Mapping[Any, Any]] = ...,
594+
info: Optional[MutableMapping[Any, Any]] = ...,
594595
**kw: Any,
595596
) -> None: ...
596597
@overload
@@ -601,7 +602,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
601602
autoflush: bool = ...,
602603
autocommit: bool = ..., # NOTE: Deprecated.
603604
expire_on_commit: bool = ...,
604-
info: Optional[Mapping[Any, Any]] = ...,
605+
info: Optional[MutableMapping[Any, Any]] = ...,
605606
**kw: Any,
606607
) -> None: ...
607608
@overload
@@ -613,7 +614,7 @@ class sessionmaker(_SessionClassMethods, Generic[_TSessionMakerType]):
613614
autoflush: bool = ...,
614615
autocommit: bool = ..., # NOTE: Deprecated.
615616
expire_on_commit: bool = ...,
616-
info: Optional[Mapping[Any, Any]] = ...,
617+
info: Optional[MutableMapping[Any, Any]] = ...,
617618
**kw: Any,
618619
) -> None: ...
619620
# NOTE: The return type of `begin()` isn't technically correct, but since

sqlalchemy-stubs/sql/schema.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from typing import Generic
55
from typing import Iterable
66
from typing import Iterator
77
from typing import List
8-
from typing import Mapping
8+
from typing import MutableMapping
99
from typing import Optional
1010
from typing import overload
1111
from typing import Sequence
@@ -59,7 +59,7 @@ class SchemaItem(SchemaEventTarget, visitors.Visitable):
5959
create_drop_stringify_dialect: str = ...
6060
dispatch: DDLEvents
6161
@util.memoized_property
62-
def info(self) -> Dict[Any, Any]: ...
62+
def info(self) -> MutableMapping[Any, Any]: ...
6363

6464
class Table(DialectKWArgs, SchemaItem, TableClause):
6565
__visit_name__: str = ...
@@ -165,7 +165,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_TE]):
165165
doc: Optional[str] = ...,
166166
key: Optional[str] = ...,
167167
index: Optional[bool] = ...,
168-
info: Mapping[Any, Any] = ...,
168+
info: MutableMapping[Any, Any] = ...,
169169
nullable: bool = ...,
170170
onupdate: Optional[Any] = ...,
171171
primary_key: bool = ...,
@@ -188,7 +188,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_TE]):
188188
doc: Optional[str] = ...,
189189
key: Optional[str] = ...,
190190
index: Optional[bool] = ...,
191-
info: Mapping[Any, Any] = ...,
191+
info: MutableMapping[Any, Any] = ...,
192192
nullable: bool = ...,
193193
onupdate: Optional[Any] = ...,
194194
primary_key: bool = ...,
@@ -213,7 +213,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_TE]):
213213
doc: Optional[str] = ...,
214214
key: Optional[str] = ...,
215215
index: Optional[bool] = ...,
216-
info: Mapping[Any, Any] = ...,
216+
info: MutableMapping[Any, Any] = ...,
217217
nullable: bool = ...,
218218
onupdate: Optional[Any] = ...,
219219
primary_key: bool = ...,
@@ -237,7 +237,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_TE]):
237237
doc: Optional[str] = ...,
238238
key: Optional[str] = ...,
239239
index: Optional[bool] = ...,
240-
info: Mapping[Any, Any] = ...,
240+
info: MutableMapping[Any, Any] = ...,
241241
nullable: bool = ...,
242242
onupdate: Optional[Any] = ...,
243243
primary_key: bool = ...,
@@ -279,7 +279,7 @@ class ForeignKey(DialectKWArgs, SchemaItem):
279279
initially: Optional[str] = ...,
280280
link_to_name: bool = ...,
281281
match: Optional[str] = ...,
282-
info: Optional[Dict[Any, Any]] = ...,
282+
info: Optional[MutableMapping[Any, Any]] = ...,
283283
**dialect_kw: Any,
284284
) -> None: ...
285285
def copy(self: _FK, schema: Optional[str] = ...) -> _FK: ...
@@ -459,7 +459,7 @@ class Constraint(DialectKWArgs, SchemaItem):
459459
deferrable: Optional[bool] = ...,
460460
initially: Optional[str] = ...,
461461
_create_rule: Optional[Any] = ...,
462-
info: Optional[Dict[Any, Any]] = ...,
462+
info: Optional[MutableMapping[Any, Any]] = ...,
463463
_type_bound: bool = ...,
464464
**dialect_kw: Any,
465465
) -> None: ...
@@ -495,7 +495,7 @@ class CheckConstraint(ColumnCollectionConstraint):
495495
deferrable: Optional[bool] = ...,
496496
initially: Optional[str] = ...,
497497
table: Optional[Table] = ...,
498-
info: Optional[Dict[Any, Any]] = ...,
498+
info: Optional[MutableMapping[Any, Any]] = ...,
499499
_create_rule: Optional[Any] = ...,
500500
_autoattach: bool = ...,
501501
_type_bound: bool = ...,
@@ -528,7 +528,7 @@ class ForeignKeyConstraint(ColumnCollectionConstraint):
528528
link_to_name: bool = ...,
529529
match: Optional[str] = ...,
530530
table: Optional[Table] = ...,
531-
info: Optional[Dict[Any, Any]] = ...,
531+
info: Optional[MutableMapping[Any, Any]] = ...,
532532
**dialect_kw: Any,
533533
) -> None: ...
534534
@property
@@ -592,7 +592,7 @@ class MetaData(SchemaItem):
592592
schema: Optional[str] = ...,
593593
quote_schema: Optional[bool] = ...,
594594
naming_convention: Optional[Dict[str, str]] = ...,
595-
info: Optional[Dict[Any, Any]] = ...,
595+
info: Optional[MutableMapping[Any, Any]] = ...,
596596
) -> None: ...
597597
def __contains__(self, table_or_key: Any) -> bool: ...
598598
def is_bound(self) -> bool: ...

0 commit comments

Comments
 (0)