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

Method get_kind

mypy/stubtest.py:1065–1082  ·  view source on GitHub ↗
(arg_name: str)

Source from the content-addressed store, hash-verified

1063 return mypy.typeops.make_simplified_union([t for t in all_types if t])
1064
1065 def get_kind(arg_name: str) -> nodes.ArgKind:
1066 kinds = {arg.kind for arg, _ in all_args[arg_name]}
1067 if nodes.ARG_STAR in kinds:
1068 return nodes.ARG_STAR
1069 if nodes.ARG_STAR2 in kinds:
1070 return nodes.ARG_STAR2
1071 # The logic here is based on two tenets:
1072 # 1) If an arg is ever optional (or unspecified), it is optional
1073 # 2) If an arg is ever positional, it is positional
1074 is_opt = (
1075 len(all_args[arg_name]) < len(stub.items)
1076 or nodes.ARG_OPT in kinds
1077 or nodes.ARG_NAMED_OPT in kinds
1078 )
1079 is_pos = nodes.ARG_OPT in kinds or nodes.ARG_POS in kinds
1080 if is_opt:
1081 return nodes.ARG_OPT if is_pos else nodes.ARG_NAMED_OPT
1082 return nodes.ARG_POS if is_pos else nodes.ARG_NAMED
1083
1084 sig: Signature[nodes.Argument] = Signature()
1085 for arg_name in sorted(all_args, key=get_position):

Callers

nothing calls this directly

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected