From: Harry Lees Date: Tue, 31 Jan 2023 13:07:56 +0000 (+0000) Subject: moved all fixed instances of set[] -> Set[] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=464bf5e3269ccd7810db741c7697db5509c08909;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git moved all fixed instances of set[] -> Set[] --- diff --git a/doc/build/orm/basic_relationships.rst b/doc/build/orm/basic_relationships.rst index 116c6b6d4b..eb4704f7e7 100644 --- a/doc/build/orm/basic_relationships.rst +++ b/doc/build/orm/basic_relationships.rst @@ -156,13 +156,13 @@ Using annotated Declarative mappings, the type of collection used for the :func:`_orm.relationship` is derived from the collection type passed to the :class:`_orm.Mapped` container type. The example from the previous section may be written to use a ``set`` rather than a ``list`` for the -``Parent.children`` collection using ``Mapped[set["Child"]]``:: +``Parent.children`` collection using ``Mapped[Set["Child"]]``:: class Parent(Base): __tablename__ = "parent_table" id: Mapped[int] = mapped_column(primary_key=True) - children: Mapped[set["Child"]] = relationship(back_populates="parent") + children: Mapped[Set["Child"]] = relationship(back_populates="parent") When using non-annotated forms including imperative mappings, the Python class to use as a collection may be passed using the @@ -523,7 +523,7 @@ such as ``set``:: __tablename__ = "left_table" id: Mapped[int] = mapped_column(primary_key=True) - children: Mapped[set["Child"]] = relationship(secondary=association_table) + children: Mapped[Set["Child"]] = relationship(secondary=association_table) When using non-annotated forms including imperative mappings, as is the case with one-to-many, the Python diff --git a/doc/build/orm/collection_api.rst b/doc/build/orm/collection_api.rst index f580b26c93..1f35c02267 100644 --- a/doc/build/orm/collection_api.rst +++ b/doc/build/orm/collection_api.rst @@ -59,6 +59,7 @@ below where ``list`` is used:: Or for a ``set``, illustrated in the same ``Parent.children`` collection:: + from typing import Set from sqlalchemy import ForeignKey from sqlalchemy.orm import DeclarativeBase @@ -77,7 +78,7 @@ Or for a ``set``, illustrated in the same parent_id: Mapped[int] = mapped_column(primary_key=True) # use a set - children: Mapped[set["Child"]] = relationship() + children: Mapped[Set["Child"]] = relationship() class Child(Base):