From: Mike Bayer Date: Sun, 16 Oct 2022 22:30:44 +0000 (-0400) Subject: repair type qualify in _ServerDefaultType; other pyright tweaks X-Git-Tag: rel_2_0_0b2~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2056ca03f187abd0840093bb5409a449d0e18f6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git repair type qualify in _ServerDefaultType; other pyright tweaks 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 --- diff --git a/doc/build/changelog/unreleased_20/8644.rst b/doc/build/changelog/unreleased_20/8644.rst new file mode 100644 index 0000000000..5b21a27468 --- /dev/null +++ b/doc/build/changelog/unreleased_20/8644.rst @@ -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. diff --git a/lib/sqlalchemy/orm/_orm_constructors.py b/lib/sqlalchemy/orm/_orm_constructors.py index 38d9844380..e27a29729b 100644 --- a/lib/sqlalchemy/orm/_orm_constructors.py +++ b/lib/sqlalchemy/orm/_orm_constructors.py @@ -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]: ... diff --git a/lib/sqlalchemy/orm/base.py b/lib/sqlalchemy/orm/base.py index 20a683d8ca..e4a69a352a 100644 --- a/lib/sqlalchemy/orm/base.py +++ b/lib/sqlalchemy/orm/base.py @@ -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, diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index bbf78e6a1c..5bfbd37c7c 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -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")