]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
updated instances of dict[] -> Dict[]
authorHarry Lees <harry.lees@gmail.com>
Tue, 31 Jan 2023 13:10:05 +0000 (13:10 +0000)
committerHarry Lees <harry.lees@gmail.com>
Tue, 31 Jan 2023 13:10:05 +0000 (13:10 +0000)
doc/build/orm/collection_api.rst
doc/build/orm/extensions/associationproxy.rst

index 1f35c022672b5694109c7ef704997b26b5303e6f..2d56bb9b2b083d775e076c6d4bcc2d426c2d47f1 100644 (file)
@@ -155,6 +155,7 @@ the :paramref:`_orm.relationship.collection_class` parameter
 is required in this case so that the :func:`.attribute_keyed_dict`
 may be appropriately parametrized::
 
+    from typing import Dict
     from typing import Optional
 
     from sqlalchemy import ForeignKey
@@ -174,7 +175,7 @@ may be appropriately parametrized::
 
         id: Mapped[int] = mapped_column(primary_key=True)
 
-        notes: Mapped[dict[str, "Note"]] = relationship(
+        notes: Mapped[Dict[str, "Note"]] = relationship(
             collection_class=attribute_keyed_dict("keyword"),
             cascade="all, delete-orphan",
         )
@@ -221,7 +222,7 @@ of the ``Note.text`` field::
 
         id: Mapped[int] = mapped_column(primary_key=True)
 
-        notes: Mapped[dict[str, "Note"]] = relationship(
+        notes: Mapped[Dict[str, "Note"]] = relationship(
             collection_class=attribute_keyed_dict("note_key"),
             back_populates="item",
             cascade="all, delete-orphan",
@@ -269,7 +270,7 @@ object directly::
 
         id: Mapped[int] = mapped_column(primary_key=True)
 
-        notes: Mapped[dict[str, "Note"]] = relationship(
+        notes: Mapped[Dict[str, "Note"]] = relationship(
             collection_class=column_keyed_dict(Note.__table__.c.keyword),
             cascade="all, delete-orphan",
         )
@@ -286,7 +287,7 @@ with a ``@property`` as mentioned earlier::
 
         id: Mapped[int] = mapped_column(primary_key=True)
 
-        notes: Mapped[dict[str, "Note"]] = relationship(
+        notes: Mapped[Dict[str, "Note"]] = relationship(
             collection_class=mapped_collection(lambda note: note.text[0:10]),
             cascade="all, delete-orphan",
         )
@@ -312,7 +313,7 @@ to populate an attribute mapped collection.  Given the following::
 
         id: Mapped[int] = mapped_column(primary_key=True)
 
-        bs: Mapped[dict[str, "B"]] = relationship(
+        bs: Mapped[Dict[str, "B"]] = relationship(
             collection_class=attribute_keyed_dict("data"),
             back_populates="a",
         )
index 54e18c55a4b9437f7363dd6c95ec16373f0a3206..fda09327215eb3f1fdf6bd52f7ccca7862310cb7 100644 (file)
@@ -315,6 +315,7 @@ argument to the ``User.keywords`` proxy so that these values are assigned approp
 when new elements are added to the dictionary::
 
     from __future__ import annotations
+    from typing import Dict
 
     from sqlalchemy import ForeignKey
     from sqlalchemy import String
@@ -338,7 +339,7 @@ when new elements are added to the dictionary::
 
         # user/user_keyword_associations relationship, mapping
         # user_keyword_associations with a dictionary against "special_key" as key.
-        user_keyword_associations: Mapped[dict[str, UserKeywordAssociation]] = relationship(
+        user_keyword_associations: Mapped[Dict[str, UserKeywordAssociation]] = relationship(
             back_populates="user",
             collection_class=attribute_keyed_dict("special_key"),
             cascade="all, delete-orphan",
@@ -346,7 +347,7 @@ when new elements are added to the dictionary::
         # proxy to 'user_keyword_associations', instantiating
         # UserKeywordAssociation assigning the new key to 'special_key',
         # values to 'keyword'.
-        keywords: AssociationProxy[dict[str, Keyword]] = association_proxy(
+        keywords: AssociationProxy[Dict[str, Keyword]] = association_proxy(
             "user_keyword_associations",
             "keyword",
             creator=lambda k, v: UserKeywordAssociation(special_key=k, keyword=v),
@@ -426,14 +427,14 @@ present on ``UserKeywordAssociation``::
         id: Mapped[int] = mapped_column(primary_key=True)
         name: Mapped[str] = mapped_column(String(64))
 
-        user_keyword_associations: Mapped[dict[str, UserKeywordAssociation]] = relationship(
+        user_keyword_associations: Mapped[Dict[str, UserKeywordAssociation]] = relationship(
             back_populates="user",
             collection_class=attribute_keyed_dict("special_key"),
             cascade="all, delete-orphan",
         )
         # the same 'user_keyword_associations'->'keyword' proxy as in
         # the basic dictionary example.
-        keywords: AssociationProxy[dict[str, str]] = association_proxy(
+        keywords: AssociationProxy[Dict[str, str]] = association_proxy(
             "user_keyword_associations",
             "keyword",
             creator=lambda k, v: UserKeywordAssociation(special_key=k, keyword=v),
@@ -458,7 +459,7 @@ present on ``UserKeywordAssociation``::
 
         # 'keyword' is changed to be a proxy to the
         # 'keyword' attribute of 'Keyword'
-        keyword: AssociationProxy[dict[str, str]] = association_proxy("kw", "keyword")
+        keyword: AssociationProxy[Dict[str, str]] = association_proxy("kw", "keyword")
 
 
     class Keyword(Base):