MCPcopy
hub / github.com/encode/starlette / state

Method state

starlette/requests.py:189–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

187
188 @property
189 def state(self) -> StateT:
190 if not hasattr(self, "_state"):
191 # Ensure 'state' has an empty dict if it's not already populated.
192 self.scope.setdefault("state", {})
193 # Create a state instance with a reference to the dict in which it should
194 # store info
195 self._state = State(self.scope["state"])
196 return cast(StateT, self._state)
197
198 def url_for(self, name: str, /, **path_params: Any) -> URL:
199 url_path_provider: Router | Starlette | None = self.scope.get("router") or self.scope.get("app")

Callers

nothing calls this directly

Calls 2

StateClass · 0.90
setdefaultMethod · 0.45

Tested by

no test coverage detected