MCPcopy Index your code
hub / github.com/python/mypy / fail

Function fail

mypy/plugins/singledispatch.py:72–85  ·  view source on GitHub ↗

Emit an error message. This tries to emit an error message at the location specified by `context`, falling back to the location specified by `ctx.context`. This is helpful when the only context information about where you want to put the error message may be None (like it is for `Callab

(ctx: PluginContext, msg: str, context: Context | None)

Source from the content-addressed store, hash-verified

70
71
72def fail(ctx: PluginContext, msg: str, context: Context | None) -> None:
73 """Emit an error message.
74
75 This tries to emit an error message at the location specified by `context`, falling back to the
76 location specified by `ctx.context`. This is helpful when the only context information about
77 where you want to put the error message may be None (like it is for `CallableType.definition`)
78 and falling back to the location of the calling function is fine."""
79 # TODO: figure out if there is some more reliable way of getting context information, so this
80 # function isn't necessary
81 if context is not None:
82 err_context = context
83 else:
84 err_context = ctx.context
85 ctx.api.fail(msg, err_context)
86
87
88def create_singledispatch_function_callback(ctx: FunctionContext) -> Type:

Callers 2

register_functionFunction · 0.70

Calls 1

failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…