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

Method simple_declaration

Tools/clinic/libclinic/converter.py:386–410  ·  view source on GitHub ↗

Computes the basic declaration of the variable. Used in computing the prototype declaration and the variable declaration.

(
            self,
            by_reference: bool = False,
            *,
            in_parser: bool = False
    )

Source from the content-addressed store, hash-verified

384 #
385
386 def simple_declaration(
387 self,
388 by_reference: bool = False,
389 *,
390 in_parser: bool = False
391 ) -> str:
392 """
393 Computes the basic declaration of the variable.
394 Used in computing the prototype declaration and the
395 variable declaration.
396 """
397 assert isinstance(self.type, str)
398 prototype = [self.type]
399 if by_reference or not self.type.endswith('*'):
400 prototype.append(" ")
401 if by_reference:
402 prototype.append('*')
403 if in_parser:
404 name = self.parser_name
405 else:
406 name = self.name
407 if self.unused:
408 name = f"Py_UNUSED({name})"
409 prototype.append(name)
410 return "".join(prototype)
411
412 def declaration(self, *, in_parser: bool = False) -> str:
413 """

Callers 3

_render_selfMethod · 0.95
declarationMethod · 0.95
test_unused_paramMethod · 0.80

Calls 3

endswithMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by 1

test_unused_paramMethod · 0.64