MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _instrument_class

Function _instrument_class

lib/sqlalchemy/orm/collections.py:826–844  ·  view source on GitHub ↗

Modify methods in a class and install instrumentation.

(cls)

Source from the content-addressed store, hash-verified

824
825
826def _instrument_class(cls):
827 """Modify methods in a class and install instrumentation."""
828
829 # In the normal call flow, a request for any of the 3 basic collection
830 # types is transformed into one of our trivial subclasses
831 # (e.g. InstrumentedList). Catch anything else that sneaks in here...
832 if cls.__module__ == "__builtin__":
833 raise sa_exc.ArgumentError(
834 "Can not instrument a built-in type. Use a "
835 "subclass, even a trivial one."
836 )
837
838 roles, methods = _locate_roles_and_methods(cls)
839
840 _setup_canned_roles(cls, roles, methods)
841
842 _assert_required_roles(cls, roles, methods)
843
844 _set_collection_attributes(cls, roles, methods)
845
846
847def _locate_roles_and_methods(cls):

Callers 3

test_name_setupMethod · 0.90
_prepare_instrumentationFunction · 0.85
__goFunction · 0.85

Calls 4

_setup_canned_rolesFunction · 0.85
_assert_required_rolesFunction · 0.85

Tested by 1

test_name_setupMethod · 0.72