(
raw_annotation: _AnnotationScanType,
cls: Type[Any],
originating_cls: Type[Any],
)
| 2220 | |
| 2221 | |
| 2222 | def _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 | |
| 2243 | class _CleanupError(Exception): |
no test coverage detected