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

Method get

starlette/config.py:94–109  ·  view source on GitHub ↗
(
        self,
        key: str,
        cast: Callable[[Any], Any] | None = None,
        default: Any = undefined,
    )

Source from the content-addressed store, hash-verified

92 return self.get(key, cast, default)
93
94 def get(
95 self,
96 key: str,
97 cast: Callable[[Any], Any] | None = None,
98 default: Any = undefined,
99 ) -> Any:
100 key = self.env_prefix + key
101 if key in self.environ:
102 value = self.environ[key]
103 return self._perform_cast(key, value, cast)
104 if key in self.file_values:
105 value = self.file_values[key]
106 return self._perform_cast(key, value, cast)
107 if default is not undefined:
108 return self._perform_cast(key, default, cast)
109 raise KeyError(f"Config '{key}' is missing, and has no default.")
110
111 def _read_file(self, file_name: str | Path, encoding: str) -> dict[str, str]:
112 file_values: dict[str, str] = {}

Callers 15

__call__Method · 0.95
test_configFunction · 0.95
is_not_modifiedMethod · 0.45
wrapped_appFunction · 0.45
parseMethod · 0.45
sendMethod · 0.45
_raise_on_disconnectMethod · 0.45
send_denial_responseMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45

Calls 1

_perform_castMethod · 0.95

Tested by 3

test_configFunction · 0.76