Fixed the type annotation for ``__class_getitem__()`` as applied to the
``Visitable`` class at the base of expression constructs to accept ``Any``
for a key, rather than ``str``, which helps with some IDEs such as PyCharm
when attempting to write typing annotations for SQL constructs which
include generic selectors. Pull request courtesy Jordan Macdonald.
Fixes: #9878
Closes: #9881
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9881
Pull-request-sha:
5aefaaf1065d1f946137a8b2f5be0767856cf9b0
Change-Id: I956e6d41142c50d870a142c3e99567a7ed2f7114
--- /dev/null
+.. change::
+ :tags: bug, typing
+ :tickets: 9878
+
+ Fixed the type annotation for ``__class_getitem__()`` as applied to the
+ ``Visitable`` class at the base of expression constructs to accept ``Any``
+ for a key, rather than ``str``, which helps with some IDEs such as PyCharm
+ when attempting to write typing annotations for SQL constructs which
+ include generic selectors. Pull request courtesy Jordan Macdonald.
+
if hasattr(cls, "__class_getitem__"):
- def __class_getitem__(cls: Type[_T], key: str) -> Type[_T]:
+ def __class_getitem__(cls: Type[_T], key: Any) -> Type[_T]:
# allow generic classes in py3.9+
return cls
cls._original_compiler_dispatch
) = _compiler_dispatch
- def __class_getitem__(cls, key: str) -> Any:
+ def __class_getitem__(cls, key: Any) -> Any:
# allow generic classes in py3.9+
return cls