(
self, name: str, data_type: PythonType | GithubClass | None, deprecated: bool
)
| 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: |
no test coverage detected