]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
repair type qualify in _ServerDefaultType; other pyright tweaks
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 16 Oct 2022 22:30:44 +0000 (18:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 16 Oct 2022 22:34:25 +0000 (18:34 -0400)
as we haven't done full pylance / pyright strict typing internally,
some of the things pyright reports on specifically will leak
out into user code, such as this mapped_column() issue.
So we will have to look more closely at pyright strict
mode going forward for the release.

Fixed typing issue where pylance strict mode would report "partially
unknown" datatype for the :func:`_orm.mapped_column` construct.

Also repaired a trailing comma and pyright complaining about overloads
for orm.composite.

Fixes: #8644
Change-Id: Ia48dc5dbd56bbceeacee4f0daf9810bfdea3bee3

doc/build/changelog/unreleased_20/8644.rst [new file with mode: 0644]
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/sql/schema.py

diff --git a/doc/build/changelog/unreleased_20/8644.rst b/doc/build/changelog/unreleased_20/8644.rst
new file mode 100644 (file)
index 0000000..5b21a27
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug, typing
+    :tickets: 8644
+
+    Fixed typing issue where pylance strict mode would report "partially
+    unknown" datatype for the :func:`_orm.mapped_column` construct.
index 38d9844380aa904c64e646de8ab4e2415e727f9c..e27a29729b271e50d37b6ed5a6ce8500e69a64ac 100644 (file)
@@ -403,7 +403,7 @@ def column_property(
 
 @overload
 def composite(
-    _class_or_attr: Type[_CC],
+    _class_or_attr: _CompositeAttrType[Any],
     *attrs: _CompositeAttrType[Any],
     group: Optional[str] = None,
     deferred: bool = False,
@@ -418,13 +418,13 @@ def composite(
     info: Optional[_InfoType] = None,
     doc: Optional[str] = None,
     **__kw: Any,
-) -> Composite[_CC]:
+) -> Composite[Any]:
     ...
 
 
 @overload
 def composite(
-    _class_or_attr: _CompositeAttrType[Any],
+    _class_or_attr: Type[_CC],
     *attrs: _CompositeAttrType[Any],
     group: Optional[str] = None,
     deferred: bool = False,
@@ -439,7 +439,7 @@ def composite(
     info: Optional[_InfoType] = None,
     doc: Optional[str] = None,
     **__kw: Any,
-) -> Composite[Any]:
+) -> Composite[_CC]:
     ...
 
 
index 20a683d8ca91bdc3c970a8364739119d2f300347..e4a69a352ae33f1c07ef423130294d3c9d331dd2 100644 (file)
@@ -77,7 +77,7 @@ class LoaderCallableStatus(Enum):
     """
 
     ATTR_EMPTY = 3
-    """Symbol used internally to indicate an attribute had no callable.""",
+    """Symbol used internally to indicate an attribute had no callable."""
 
     NO_VALUE = 4
     """Symbol which may be placed as the 'previous' value of an attribute,
index bbf78e6a1c18e2e252bcaa40aca342308b6cb352..5bfbd37c7cdfb49a2ef0966323fcc50d78015ced 100644 (file)
@@ -105,7 +105,7 @@ if typing.TYPE_CHECKING:
 
 _T = TypeVar("_T", bound="Any")
 _SI = TypeVar("_SI", bound="SchemaItem")
-_ServerDefaultType = Union["FetchedValue", str, TextClause, ColumnElement]
+_ServerDefaultType = Union["FetchedValue", str, TextClause, ColumnElement[Any]]
 _TAB = TypeVar("_TAB", bound="Table")