MCPcopy
hub / github.com/pallets/click / make_context

Method make_context

src/click/core.py:1266–1301  ·  view source on GitHub ↗

This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. To quickly customize the context class used without overriding this method, set the :attr:`context

(
        self,
        info_name: str | None,
        args: list[str],
        parent: Context | None = None,
        **extra: t.Any,
    )

Source from the content-addressed store, hash-verified

1264 formatter.write_text(epilog)
1265
1266 def make_context(
1267 self,
1268 info_name: str | None,
1269 args: list[str],
1270 parent: Context | None = None,
1271 **extra: t.Any,
1272 ) -> Context:
1273 """This function when given an info name and arguments will kick
1274 off the parsing and create a new :class:`Context`. It does not
1275 invoke the actual command callback though.
1276
1277 To quickly customize the context class used without overriding
1278 this method, set the :attr:`context_class` attribute.
1279
1280 :param info_name: the info name for this invocation. Generally this
1281 is the most descriptive name for the script or
1282 command. For the toplevel script it's usually
1283 the name of the script, for commands below it's
1284 the name of the command.
1285 :param args: the arguments to parse as list of strings.
1286 :param parent: the parent context if available.
1287 :param extra: extra keyword arguments forwarded to the context
1288 constructor.
1289
1290 .. versionchanged:: 8.0
1291 Added the :attr:`context_class` attribute.
1292 """
1293 for key, value in self.context_settings.items():
1294 if key not in extra:
1295 extra[key] = value
1296
1297 ctx = self.context_class(self, info_name=info_name, parent=parent, **extra)
1298
1299 with ctx.scope(cleanup=False):
1300 self.parse_args(ctx, args)
1301 return ctx
1302
1303 def parse_args(self, ctx: Context, args: list[str]) -> list[str]:
1304 if not args and self.no_args_is_help and not ctx.resilient_parsing:

Callers 5

mainMethod · 0.95
invokeMethod · 0.80
_resolve_contextFunction · 0.80
test_return_valuesFunction · 0.80

Calls 2

parse_argsMethod · 0.95
scopeMethod · 0.80

Tested by 2

test_return_valuesFunction · 0.64