MCPcopy
hub / github.com/pallets/werkzeug / __get__

Method __get__

src/werkzeug/local.py:310–335  ·  view source on GitHub ↗
(self, instance: LocalProxy[t.Any], owner: type | None = None)

Source from the content-addressed store, hash-verified

308 self.name = name
309
310 def __get__(self, instance: LocalProxy[t.Any], owner: type | None = None) -> t.Any:
311 if instance is None:
312 if self.class_value is not None:
313 return self.class_value
314
315 return self
316
317 try:
318 obj = instance._get_current_object()
319 except RuntimeError:
320 if self.fallback is None:
321 raise
322
323 fallback = self.fallback.__get__(instance, owner)
324
325 if self.is_attr:
326 # __class__ and __doc__ are attributes, not methods.
327 # Call the fallback to get the value.
328 return fallback()
329
330 return fallback
331
332 if self.bind_f is not None:
333 return self.bind_f(instance, obj)
334
335 return getattr(obj, self.name)
336
337 def __repr__(self) -> str:
338 return f"proxy {self.name}"

Callers 3

__call__Method · 0.95
bind_fMethod · 0.45
bind_fMethod · 0.45

Calls 2

bind_fMethod · 0.95
_get_current_objectMethod · 0.80

Tested by

no test coverage detected