MCPcopy Create free account
hub / github.com/python/mypy / maybe_note_concatenate_pos_args

Method maybe_note_concatenate_pos_args

mypy/messages.py:855–885  ·  view source on GitHub ↗
(
        self,
        original_caller_type: ProperType,
        callee_type: ProperType,
        context: Context,
        code: ErrorCode | None = None,
    )

Source from the content-addressed store, hash-verified

853 )
854
855 def maybe_note_concatenate_pos_args(
856 self,
857 original_caller_type: ProperType,
858 callee_type: ProperType,
859 context: Context,
860 code: ErrorCode | None = None,
861 ) -> None:
862 # pos-only vs positional can be confusing, with Concatenate
863 if (
864 isinstance(callee_type, CallableType)
865 and isinstance(original_caller_type, CallableType)
866 and (original_caller_type.from_concatenate or callee_type.from_concatenate)
867 ):
868 names: list[str] = []
869 for c, o in zip(
870 callee_type.formal_arguments(), original_caller_type.formal_arguments()
871 ):
872 if None in (c.pos, o.pos):
873 # non-positional
874 continue
875 if c.name != o.name and c.name is None and o.name is not None:
876 names.append(o.name)
877
878 if names:
879 missing_arguments = '"' + '", "'.join(names) + '"'
880 self.note(
881 f'This is likely because "{original_caller_type.name}" has named arguments: '
882 f"{missing_arguments}. Consider marking them positional-only",
883 context,
884 code=code,
885 )
886
887 def invalid_index_type(
888 self,

Callers 2

check_subtypeMethod · 0.80

Calls 6

noteMethod · 0.95
isinstanceFunction · 0.85
zipFunction · 0.85
appendMethod · 0.80
formal_argumentsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected