MCPcopy Create free account
hub / github.com/microsoft/debugpy / __init__

Method __init__

src/debugpy/adapter/components.py:146–173  ·  view source on GitHub ↗

Parses an "initialize" request or response and extracts the feature flags. For every "X" in self.PROPERTIES, sets self["X"] to the corresponding value from message.payload if it's present there, or to the default value otherwise.

(self, component, message)

Source from the content-addressed store, hash-verified

144 """
145
146 def __init__(self, component, message):
147 """Parses an "initialize" request or response and extracts the feature flags.
148
149 For every "X" in self.PROPERTIES, sets self["X"] to the corresponding value
150 from message.payload if it's present there, or to the default value otherwise.
151 """
152
153 assert message.is_request("initialize") or message.is_response("initialize")
154
155 self.component = component
156
157 payload = message.payload
158 for name, validate in self.PROPERTIES.items():
159 value = payload.get(name, ())
160 if not callable(validate):
161 validate = json.default(validate)
162
163 try:
164 value = validate(value)
165 except Exception as exc:
166 raise message.isnt_valid("{0} {1}", json.repr(name), exc)
167
168 assert (
169 value != ()
170 ), f"{validate} must provide a default value for missing properties."
171 self[name] = value
172
173 log.debug("{0}", self)
174
175 def __repr__(self):
176 return f"{type(self).__name__}: {json.repr(dict(self))}"

Callers

nothing calls this directly

Calls 7

validateFunction · 0.85
is_requestMethod · 0.80
is_responseMethod · 0.80
itemsMethod · 0.80
isnt_validMethod · 0.80
getMethod · 0.45
defaultMethod · 0.45

Tested by

no test coverage detected