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

Method create_use_attr

scripts/openapi.py:1185–1209  ·  view source on GitHub ↗
(cls, prop: Property)

Source from the content-addressed store, hash-verified

1183
1184 @classmethod
1185 def create_use_attr(cls, prop: Property) -> cst.BaseStatement:
1186 # we need to make the 'headers' attribute truly private,
1187 # otherwise it conflicts with GithubObject._headers
1188 attr_name = f"__{prop.name}" if prop.name == "headers" else f"_{prop.name}"
1189 return cst.If(
1190 test=cst.Comparison(
1191 left=cst.SimpleString(f'"{prop.name}"'),
1192 comparisons=[cst.ComparisonTarget(operator=cst.In(), comparator=cst.Name("attributes"))],
1193 ),
1194 body=cst.IndentedBlock(
1195 header=cst.TrailingWhitespace(
1196 whitespace=cst.SimpleWhitespace(" "), comment=cst.Comment("# pragma no branch")
1197 ),
1198 body=[
1199 cst.SimpleStatementLine(
1200 [
1201 cst.Assign(
1202 targets=[cst.AssignTarget(cls.create_attribute(["self", attr_name]))],
1203 value=cls.make_attribute(prop),
1204 )
1205 ]
1206 )
1207 ],
1208 ),
1209 )
1210
1211 def update_init_attrs(self, func: cst.FunctionDef) -> cst.FunctionDef:
1212 # adds only missing attributes, does not update existing ones

Callers 1

update_use_attrsMethod · 0.95

Calls 2

create_attributeMethod · 0.80
make_attributeMethod · 0.80

Tested by

no test coverage detected