This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# inspection.py
|
||||
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
|
||||
# sqlalchemy/inspect.py
|
||||
# Copyright (C) 2005-2023 the SQLAlchemy authors and contributors
|
||||
# <see AUTHORS file>
|
||||
#
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
@@ -74,7 +74,8 @@ class _InspectableTypeProtocol(Protocol[_TCov]):
|
||||
|
||||
"""
|
||||
|
||||
def _sa_inspect_type(self) -> _TCov: ...
|
||||
def _sa_inspect_type(self) -> _TCov:
|
||||
...
|
||||
|
||||
|
||||
class _InspectableProtocol(Protocol[_TCov]):
|
||||
@@ -83,31 +84,35 @@ class _InspectableProtocol(Protocol[_TCov]):
|
||||
|
||||
"""
|
||||
|
||||
def _sa_inspect_instance(self) -> _TCov: ...
|
||||
def _sa_inspect_instance(self) -> _TCov:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def inspect(
|
||||
subject: Type[_InspectableTypeProtocol[_IN]], raiseerr: bool = True
|
||||
) -> _IN: ...
|
||||
) -> _IN:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def inspect(
|
||||
subject: _InspectableProtocol[_IN], raiseerr: bool = True
|
||||
) -> _IN: ...
|
||||
def inspect(subject: _InspectableProtocol[_IN], raiseerr: bool = True) -> _IN:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def inspect(subject: Inspectable[_IN], raiseerr: bool = True) -> _IN: ...
|
||||
def inspect(subject: Inspectable[_IN], raiseerr: bool = True) -> _IN:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def inspect(subject: Any, raiseerr: Literal[False] = ...) -> Optional[Any]: ...
|
||||
def inspect(subject: Any, raiseerr: Literal[False] = ...) -> Optional[Any]:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def inspect(subject: Any, raiseerr: bool = True) -> Any: ...
|
||||
def inspect(subject: Any, raiseerr: bool = True) -> Any:
|
||||
...
|
||||
|
||||
|
||||
def inspect(subject: Any, raiseerr: bool = True) -> Any:
|
||||
@@ -157,7 +162,9 @@ def _inspects(
|
||||
def decorate(fn_or_cls: _F) -> _F:
|
||||
for type_ in types:
|
||||
if type_ in _registrars:
|
||||
raise AssertionError("Type %s is already registered" % type_)
|
||||
raise AssertionError(
|
||||
"Type %s is already " "registered" % type_
|
||||
)
|
||||
_registrars[type_] = fn_or_cls
|
||||
return fn_or_cls
|
||||
|
||||
@@ -169,6 +176,6 @@ _TT = TypeVar("_TT", bound="Type[Any]")
|
||||
|
||||
def _self_inspects(cls: _TT) -> _TT:
|
||||
if cls in _registrars:
|
||||
raise AssertionError("Type %s is already registered" % cls)
|
||||
raise AssertionError("Type %s is already " "registered" % cls)
|
||||
_registrars[cls] = True
|
||||
return cls
|
||||
|
||||
Reference in New Issue
Block a user