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

Function check_native_override

mypyc/irbuild/function.py:779–805  ·  view source on GitHub ↗

Report an error if an override changes signature in unsupported ways. Glue methods can work around many signature changes but not all of them.

(
    builder: IRBuilder, base_sig: FuncSignature, sub_sig: FuncSignature, line: int
)

Source from the content-addressed store, hash-verified

777
778
779def check_native_override(
780 builder: IRBuilder, base_sig: FuncSignature, sub_sig: FuncSignature, line: int
781) -> None:
782 """Report an error if an override changes signature in unsupported ways.
783
784 Glue methods can work around many signature changes but not all of them.
785 """
786 for base_arg, sub_arg in zip(base_sig.real_args(), sub_sig.real_args()):
787 if base_arg.type.error_overlap:
788 if not base_arg.optional and sub_arg.optional and base_sig.num_bitmap_args:
789 # This would change the meanings of bits in the argument defaults
790 # bitmap, which we don't support. We'd need to do tricky bit
791 # manipulations to support this generally.
792 builder.error(
793 "An argument with type "
794 + f'"{base_arg.type}" cannot be given a default value in a method override',
795 line,
796 )
797 if base_arg.type.error_overlap or sub_arg.type.error_overlap:
798 if not is_same_type(base_arg.type, sub_arg.type):
799 # This would change from signaling a default via an error value to
800 # signaling a default via bitmap, which we don't support.
801 builder.error(
802 "Incompatible argument type "
803 + f'"{sub_arg.type}" (base class has type "{base_arg.type}")',
804 line,
805 )
806
807
808def gen_glue_property(

Callers 1

gen_glue_methodFunction · 0.85

Calls 4

is_same_typeFunction · 0.90
zipFunction · 0.85
real_argsMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…