MCPcopy Index your code
hub / github.com/python/cpython / state_modulename_name

Method state_modulename_name

Tools/clinic/libclinic/dsl_parser.py:674–730  ·  view source on GitHub ↗
(self, line: str)

Source from the content-addressed store, hash-verified

672 self.next(self.state_function_docstring)
673
674 def state_modulename_name(self, line: str) -> None:
675 # looking for declaration, which establishes the leftmost column
676 # line should be
677 # modulename.fnname [as c_basename] [-> return annotation]
678 # square brackets denote optional syntax.
679 #
680 # alternatively:
681 # modulename.fnname [as c_basename] = modulename.existing_fn_name
682 # clones the parameters and return converter from that
683 # function. you can't modify them. you must enter a
684 # new docstring.
685 #
686 # (but we might find a directive first!)
687 #
688 # this line is permitted to start with whitespace.
689 # we'll call this number of spaces F (for "function").
690
691 assert self.valid_line(line)
692 self.indent.infer(line)
693
694 # are we cloning?
695 before, equals, existing = line.rpartition('=')
696 if equals:
697 existing = existing.strip()
698 if libclinic.is_legal_py_identifier(existing):
699 if self.forced_text_signature:
700 fail("Cannot use @text_signature when cloning a function")
701 # we're cloning!
702 names = self.parse_function_names(before)
703 return self.parse_cloned_function(names, existing)
704
705 line, _, returns = line.partition('->')
706 returns = returns.strip()
707 full_name, c_basename = self.parse_function_names(line)
708 return_converter = self.resolve_return_converter(full_name, returns)
709
710 fields = [x.strip() for x in full_name.split('.')]
711 function_name = fields.pop()
712 module, cls = self.clinic._module_and_class(fields)
713
714 func = Function(
715 name=function_name,
716 full_name=full_name,
717 module=module,
718 cls=cls,
719 c_basename=c_basename,
720 return_converter=return_converter,
721 kind=self.kind,
722 coexist=self.coexist,
723 critical_section=self.critical_section,
724 disable_fastcall=self.disable_fastcall,
725 target_critical_section=self.target_critical_section,
726 forced_text_signature=self.forced_text_signature
727 )
728 self.add_function(func)
729
730 self.next(self.state_parameters_start)
731

Callers

nothing calls this directly

Calls 15

valid_lineMethod · 0.95
parse_function_namesMethod · 0.95
parse_cloned_functionMethod · 0.95
add_functionMethod · 0.95
nextMethod · 0.95
failFunction · 0.90
FunctionClass · 0.90
inferMethod · 0.80
_module_and_classMethod · 0.80
rpartitionMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected