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

Method create_init_attr

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

Source from the content-addressed store, hash-verified

1077
1078 @classmethod
1079 def create_init_attr(cls, prop: Property) -> cst.SimpleStatementLine:
1080 # we need to make the 'headers' attribute truly private,
1081 # otherwise it conflicts with GithubObject._headers
1082 attr_name = f"__{prop.name}" if prop.name == "headers" else f"_{prop.name}"
1083 return cst.SimpleStatementLine(
1084 [
1085 cst.AnnAssign(
1086 target=cls.create_attribute(["self", attr_name]),
1087 annotation=cst.Annotation(
1088 annotation=cst.Subscript(
1089 value=cst.Name("Attribute"),
1090 slice=[
1091 cst.SubscriptElement(
1092 slice=cst.Index(cls.create_type(prop.data_type, short_class_name=True))
1093 )
1094 ],
1095 )
1096 ),
1097 value=cst.Name("NotSet"),
1098 )
1099 ]
1100 )
1101
1102 @classmethod
1103 def make_attribute(cls, prop: Property) -> cst.Call:

Callers 1

update_init_attrsMethod · 0.95

Calls 2

create_attributeMethod · 0.80
create_typeMethod · 0.80

Tested by

no test coverage detected