U kf@sUdZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z d d l mZd dlmZd dlmZe dedZe deddZe dedefdZe dedZiZded<GdddeeZGdddeeZGdddeeZe d9d d!dd"d#d$Ze d:d%d!dd"d&d$Ze d;d'd!dd"d(d$Ze dd)d!d)d"d.d$Zd/d0d1d2d3Ze d4d/dZd4d4d5d6d7Zd8S)?a7The inspection module provides the :func:`_sa.inspect` function, which delivers runtime information about a wide variety of SQLAlchemy objects, both within the Core as well as the ORM. The :func:`_sa.inspect` function is the entry point to SQLAlchemy's public API for viewing the configuration and construction of in-memory objects. Depending on the type of object passed to :func:`_sa.inspect`, the return value will either be a related object which provides a known interface, or in many cases it will return the object itself. The rationale for :func:`_sa.inspect` is twofold. One is that it replaces the need to be aware of a large variety of "information getting" functions in SQLAlchemy, such as :meth:`_reflection.Inspector.from_engine` (deprecated in 1.4), :func:`.orm.attributes.instance_state`, :func:`_orm.class_mapper`, and others. The other is that the return value of :func:`_sa.inspect` is guaranteed to obey a documented API, thus allowing third party tools which build on top of SQLAlchemy configurations to be constructed in a forwards-compatible way. ) annotations)Any)Callable)Dict)Generic)Optional)overload)Type)TypeVar)Union)exc)Literal)Protocol_T)bound_TCovT)r covariant_F._INz6Dict[type, Union[Literal[True], Callable[[Any], Any]]] _registrarsc@seZdZdZdZdS) Inspectablea8define a class as inspectable. This allows typing to set up a linkage between an object that can be inspected and the type of inspection it returns. Unfortunately we cannot at the moment get all classes that are returned by inspection to suit this interface as we get into MRO issues. N)__name__ __module__ __qualname____doc__ __slots__rrrE/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/inspection.pyr8s rc@seZdZdZddddZdS)_InspectableTypeProtocolzla protocol defining a method that's used when a type (ie the class itself) is passed to inspect(). rreturncCsdSNrselfrrr_sa_inspect_typeMz)_InspectableTypeProtocol._sa_inspect_typeN)rrrrr%rrrrrGsrc@seZdZdZddddZdS)_InspectableProtocolz[a protocol defining a method that's used when an instance is passed to inspect(). rr cCsdSr"rr#rrr_sa_inspect_instanceVr&z)_InspectableProtocol._sa_inspect_instanceN)rrrrr(rrrrr'Psr'z#Type[_InspectableTypeProtocol[_IN]]bool)subjectraiseerrr!cCsdSr"rr*r+rrrinspectYsr-z_InspectableProtocol[_IN]cCsdSr"rr,rrrr-_szInspectable[_IN]cCsdSr"rr,rrrr-esrzLiteral[False]z Optional[Any]cCsdSr"rr,rrrr-iscCsdSr"rr,rrrr-mscCst|}|jD]L}|tkrt|d}|dkr2qn|dkrB|S||}|dk r|Sqd}}|r|dksx|dkrtd||S)aProduce an inspection object for the given target. The returned value in some cases may be the same object as the one given, such as if a :class:`_orm.Mapper` object is passed. In other cases, it will be an instance of the registered inspection type for the given object, such as if an :class:`_engine.Engine` is passed, an :class:`_reflection.Inspector` object is returned. :param subject: the subject to be inspected. :param raiseerr: When ``True``, if the given subject does not correspond to a known SQLAlchemy inspected type, :class:`sqlalchemy.exc.NoInspectionAvailable` is raised. If ``False``, ``None`` is returned. NTz7No inspection system is available for object of type %s)type__mro__rgetr ZNoInspectionAvailable)r*r+type_clsregretrrrr-qs&   z Type[Any]zCallable[[_F], _F])typesr!csdddfdd }|S)Nr) fn_or_clsr!cs*D] }|tkrtd||t|<q|S)NType %s is already registeredrAssertionError)r6r1r5rrdecorates   z_inspects..decorater)r5r;rr:r _inspectssr<_TT)r2r!cCs |tkrtd|dt|<|S)Nr7Tr8)r2rrr_self_inspectss r>N)T)T)T).)T)T)r __future__rtypingrrrrrrr r r r Z util.typingrrrrrrr__annotations__rrr'r-r<r=r>rrrrsJ                  )