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

Function generate_bin_op_forward_only_wrapper

mypyc/codegen/emitwrapper.py:362–386  ·  view source on GitHub ↗
(
    fn: FuncIR, emitter: Emitter, gen: WrapperGenerator
)

Source from the content-addressed store, hash-verified

360
361
362def generate_bin_op_forward_only_wrapper(
363 fn: FuncIR, emitter: Emitter, gen: WrapperGenerator
364) -> None:
365 gen.emit_arg_processing(error=GotoHandler("typefail"), raise_exception=False)
366 handle_third_pow_argument(fn, emitter, gen, if_unsupported=["goto typefail;"])
367 gen.emit_call(not_implemented_handler="goto typefail;")
368 gen.emit_error_handling()
369 emitter.emit_label("typefail")
370 # If some argument has an incompatible type, treat this the same as
371 # returning NotImplemented, and try to call the reverse operator method.
372 #
373 # Note that in normal Python you'd instead of an explicit
374 # return of NotImplemented, but it doesn't generally work here
375 # the body won't be executed at all if there is an argument
376 # type check failure.
377 #
378 # The recommended way is to still use a type check in the
379 # body. This will only be used in interpreted mode:
380 #
381 # def __add__(self, other: int) -> Foo:
382 # if not isinstance(other, int):
383 # return NotImplemented
384 # ...
385 generate_bin_op_reverse_dunder_call(fn, emitter, reverse_op_methods[fn.name])
386 gen.finish()
387
388
389def generate_bin_op_reverse_only_wrapper(

Callers 1

generate_bin_op_wrapperFunction · 0.85

Calls 8

GotoHandlerClass · 0.90
emit_arg_processingMethod · 0.80
emit_callMethod · 0.80
emit_error_handlingMethod · 0.80
emit_labelMethod · 0.80
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…