Skip to content

Commit 50190e1

Browse files
committed
Address some PR comments
1 parent 0c2003b commit 50190e1

File tree

8 files changed

+23
-30
lines changed

8 files changed

+23
-30
lines changed

stubs/SQLAlchemy/@tests/stubtest_allowlist.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ sqlalchemy.engine.base.Engine.logging_name # initialized if not None
99
sqlalchemy.sql.lambdas.PyWrapper.__clause_element__
1010
sqlalchemy.testing.util.non_refcount_gc_collect
1111

12-
# wrong argument name in implementation ("self" instead of "cls")
13-
sqlalchemy.engine.URL.__new__
14-
sqlalchemy.engine.url.URL.__new__
15-
sqlalchemy.util.langhelpers._symbol.__new__
16-
1712
# abstract fields not present at runtime
1813
sqlalchemy.engine.Transaction.connection
1914
sqlalchemy.engine.Transaction.is_active
@@ -62,3 +57,9 @@ sqlalchemy.sql.quoted_name.lower
6257
sqlalchemy.sql.quoted_name.upper
6358
sqlalchemy.orm.ColumnProperty.Comparator.__clause_element__
6459
sqlalchemy.orm.properties.ColumnProperty.Comparator.__clause_element__
60+
61+
# Same error as in stdlib due to it being re-erported
62+
sqlalchemy.util.compat.StringIO.seek
63+
sqlalchemy.util.compat.StringIO.truncate
64+
sqlalchemy.util.StringIO.seek
65+
sqlalchemy.util.StringIO.truncate

stubs/SQLAlchemy/sqlalchemy/engine/url.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class _URLTuple(NamedTuple):
1919
_Query: TypeAlias = Mapping[str, str | Sequence[str]] | Sequence[tuple[str, str | Sequence[str]]]
2020

2121
class URL(_URLTuple):
22+
def __new__(self: type[Self], *arg, **kw) -> Self | URL: ...
2223
@classmethod
2324
def create(
2425
cls,

stubs/SQLAlchemy/sqlalchemy/orm/collections.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, SupportsKeysAndGetItem
22
from collections.abc import Iterable, Mapping
33
from typing import Any, TypeVar, overload
44
from typing_extensions import Literal, SupportsIndex
@@ -124,4 +124,7 @@ class MappedCollection(dict[_KT, _VT]):
124124
def setdefault(self, key: _KT, default: _T) -> _VT | _T: ...
125125
@overload
126126
def setdefault(self, key: _KT, default: None = None) -> _VT | None: ...
127-
def update(self, __other: Mapping[_KT, _VT] = ..., **kw: _VT) -> None: ... # type: ignore[override]
127+
@overload
128+
def update(self, __other: SupportsKeysAndGetItem[_KT, _VT] = ..., **kwargs: _VT) -> None: ...
129+
@overload
130+
def update(self, __other: Iterable[tuple[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...

stubs/SQLAlchemy/sqlalchemy/orm/strategy_options.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@ class _UnboundLoad(Load):
5151
# wich is callable with their original parameters.
5252
#
5353
# While both mypy and pyright's validation work, Pylance is unable to
54-
# show the parameters and return types.
55-
#
56-
# There is a workaround (define the method for Pylance, then reassign
57-
# an instance of loader_option to it for mypy, and add pyright+Flake8
58-
# suppressions), but it is too hacky and relies on some unsupported quirks.
59-
#
60-
# Asking Pylance to add support for these generic callables might be preferable.
54+
# show the parameters and return types without a hacky workaround.
6155
###
6256

6357
_F = TypeVar("_F", bound=Callable[..., loader_option[Any]])

stubs/SQLAlchemy/sqlalchemy/testing/config.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Config:
2626
is_async: Any
2727
def __init__(self, db, db_opts, options, file_config) -> None: ...
2828
@classmethod
29-
def register(cls, db, db_opts, options, file_config): ...
29+
def register(cls, db, db_opts, options, file_config) -> Config: ...
3030
@classmethod
3131
def set_as_current(cls, config, namespace) -> None: ...
3232
@classmethod

stubs/SQLAlchemy/sqlalchemy/testing/provision.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ def reap_dbs(idents_file) -> None: ...
2222
# wich is callable with their original parameters.
2323
#
2424
# While both mypy and pyright's validation work, Pylance is unable to
25-
# show the parameters and return types.
26-
#
27-
# There is a workaround (define the method for Pylance, then reassign
28-
# an instance of register to it for mypy, and add pyright+Flake8
29-
# suppressions), but it is too hacky and relies on some unsupported quirks.
30-
#
31-
# Asking Pylance to add support for these generic callables might be preferable.
25+
# show the parameters and return types without a hacky workaround.
3226
###
3327

3428
_F = TypeVar("_F", bound=Callable[..., str | URL | None])

stubs/SQLAlchemy/sqlalchemy/util/compat.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from collections import namedtuple as namedtuple # noqa: Y024 # Actual import
1010
from contextlib import contextmanager as contextmanager
1111
from datetime import timezone as timezone
1212
from functools import reduce as reduce
13-
from io import BytesIO, StringIO as _StringIO
13+
from io import BytesIO, StringIO as StringIO
1414
from itertools import zip_longest as zip_longest
1515
from time import perf_counter as perf_counter
1616
from typing import TYPE_CHECKING as TYPE_CHECKING, Any, NamedTuple
@@ -48,10 +48,6 @@ is64bit: bool
4848
has_refcount_gc: bool
4949
dottedgetter = operator.attrgetter
5050

51-
class StringIO(_StringIO):
52-
def seek(self, __pos: int, __whence: int = 0) -> int: ...
53-
def truncate(self, __pos: int | None = None) -> int: ...
54-
5551
class FullArgSpec(NamedTuple):
5652
args: Any
5753
varargs: Any

stubs/SQLAlchemy/sqlalchemy/util/langhelpers.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PluginLoader:
3030
def __init__(self, group, auto_fn: Incomplete | None = ...) -> None: ...
3131
def clear(self) -> None: ...
3232
def load(self, name): ...
33-
def register(self, name, modulepath, objname): ...
33+
def register(self, name, modulepath, objname) -> None: ...
3434

3535
def get_cls_kwargs(cls, _set: Incomplete | None = ...): ...
3636
def get_func_kwargs(func): ...
@@ -129,12 +129,16 @@ class hybridmethod:
129129
def classlevel(self, func): ...
130130

131131
class _symbol(int):
132-
def __new__(cls, name, doc: Incomplete | None = ..., canonical: Incomplete | None = ...): ...
132+
def __new__( # noqa: Y034 # Excplicitely instanciates _symbol
133+
self, name, doc: Incomplete | None = ..., canonical: Incomplete | None = ...
134+
) -> _symbol: ...
133135
def __reduce__(self): ...
134136

135137
class symbol:
136138
symbols: Any
137-
def __new__(cls, name, doc: Incomplete | None = ..., canonical: Incomplete | None = ...): ...
139+
def __new__( # type: ignore[misc] # Excplicitely instanciates _symbol
140+
cls, name, doc: Incomplete | None = ..., canonical: Incomplete | None = ...
141+
) -> _symbol: ...
138142
@classmethod
139143
def parse_user_argument(cls, arg, choices, name, resolve_symbol_names: bool = ...): ...
140144

0 commit comments

Comments
 (0)