MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _is_mapped_annotation

Function _is_mapped_annotation

lib/sqlalchemy/orm/util.py:2222–2240  ·  view source on GitHub ↗
(
    raw_annotation: _AnnotationScanType,
    cls: Type[Any],
    originating_cls: Type[Any],
)

Source from the content-addressed store, hash-verified

2220
2221
2222def _is_mapped_annotation(
2223 raw_annotation: _AnnotationScanType,
2224 cls: Type[Any],
2225 originating_cls: Type[Any],
2226) -> bool:
2227 try:
2228 annotated = de_stringify_annotation(
2229 cls, raw_annotation, originating_cls.__module__
2230 )
2231 except NameError:
2232 # in most cases, at least within our own tests, we can raise
2233 # here, which is more accurate as it prevents us from returning
2234 # false negatives. However, in the real world, try to avoid getting
2235 # involved with end-user annotations that have nothing to do with us.
2236 # see issue #8888 where we bypass using this function in the case
2237 # that we want to detect an unresolvable Mapped[] type.
2238 return False
2239 else:
2240 return is_origin_of_cls(annotated, _MappedAnnotationBase)
2241
2242
2243class _CleanupError(Exception):

Calls 2

de_stringify_annotationFunction · 0.85
is_origin_of_clsFunction · 0.85

Tested by

no test coverage detected