MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _raise_for_expected

Method _raise_for_expected

lib/sqlalchemy/sql/coercions.py:500–528  ·  view source on GitHub ↗
(
        self,
        element: Any,
        argname: Optional[str] = None,
        resolved: Optional[Any] = None,
        *,
        advice: Optional[str] = None,
        code: Optional[str] = None,
        err: Optional[Exception] = None,
        **kw: Any,
    )

Source from the content-addressed store, hash-verified

498 self._raise_for_expected(element, argname, resolved)
499
500 def _raise_for_expected(
501 self,
502 element: Any,
503 argname: Optional[str] = None,
504 resolved: Optional[Any] = None,
505 *,
506 advice: Optional[str] = None,
507 code: Optional[str] = None,
508 err: Optional[Exception] = None,
509 **kw: Any,
510 ) -> NoReturn:
511 if resolved is not None and resolved is not element:
512 got = "%r object resolved from %r object" % (resolved, element)
513 else:
514 got = repr(element)
515
516 if argname:
517 msg = "%s expected for argument %r; got %s." % (
518 self.name,
519 argname,
520 got,
521 )
522 else:
523 msg = "%s expected, got %s." % (self.name, got)
524
525 if advice:
526 msg += " " + advice
527
528 raise exc.ArgumentError(msg, code=code) from err
529
530
531class _Deannotate:

Callers 15

_implicit_coercionsMethod · 0.95
expectFunction · 0.45
_implicit_coercionsMethod · 0.45
_implicit_coercionsMethod · 0.45
_literal_coercionMethod · 0.45
_literal_coercionMethod · 0.45
_implicit_coercionsMethod · 0.45
_raise_for_expectedMethod · 0.45
_implicit_coercionsMethod · 0.45
_implicit_coercionsMethod · 0.45
_raise_for_expectedMethod · 0.45
_literal_coercionMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected