From 7f93fe6fbcffaffe286628a6820fef4469947948 Mon Sep 17 00:00:00 2001 From: Harry Lees Date: Tue, 31 Jan 2023 13:10:05 +0000 Subject: [PATCH] updated instances of dict[] -> Dict[] --- doc/build/orm/collection_api.rst | 11 ++++++----- doc/build/orm/extensions/associationproxy.rst | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/build/orm/collection_api.rst b/doc/build/orm/collection_api.rst index 1f35c02267..2d56bb9b2b 100644 --- a/doc/build/orm/collection_api.rst +++ b/doc/build/orm/collection_api.rst @@ -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", ) diff --git a/doc/build/orm/extensions/associationproxy.rst b/doc/build/orm/extensions/associationproxy.rst index 54e18c55a4..fda0932721 100644 --- a/doc/build/orm/extensions/associationproxy.rst +++ b/doc/build/orm/extensions/associationproxy.rst @@ -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): -- 2.47.3