MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / create_property_function

Method create_property_function

scripts/openapi.py:1051–1076  ·  view source on GitHub ↗
(
        self, name: str, data_type: PythonType | GithubClass | None, deprecated: bool
    )

Source from the content-addressed store, hash-verified

1049 return cst.FlattenSentinel(nodes=nodes)
1050
1051 def create_property_function(
1052 self, name: str, data_type: PythonType | GithubClass | None, deprecated: bool
1053 ) -> cst.FunctionDef:
1054 # we need to make the 'headers' attribute truly private,
1055 # otherwise it conflicts with GithubObject._headers
1056 attr_name = f"__{name}" if name == "headers" else f"_{name}"
1057 complete_if_completable_stmt = cst.SimpleStatementLine(
1058 body=[
1059 cst.Expr(
1060 cst.Call(
1061 func=self.create_attribute(["self", "_completeIfNotSet"]),
1062 args=[cst.Arg(self.create_attribute(["self", attr_name]))],
1063 )
1064 )
1065 ]
1066 )
1067 return_stmt = cst.SimpleStatementLine(body=[cst.Return(self.create_attribute(["self", attr_name, "value"]))])
1068 stmts = ([complete_if_completable_stmt] if self.completable else []) + [return_stmt]
1069
1070 return cst.FunctionDef(
1071 decorators=[cst.Decorator(decorator=cst.Name(value="property"))],
1072 name=cst.Name(value=name),
1073 params=cst.Parameters(params=[cst.Param(cst.Name("self"))]),
1074 returns=cst.Annotation(annotation=self.create_type(data_type, short_class_name=True)),
1075 body=cst.IndentedBlock(body=stmts),
1076 )
1077
1078 @classmethod
1079 def create_init_attr(cls, prop: Property) -> cst.SimpleStatementLine:

Callers 1

leave_FunctionDefMethod · 0.95

Calls 2

create_attributeMethod · 0.80
create_typeMethod · 0.80

Tested by

no test coverage detected