Skip to content

Commit c0b78ce

Browse files
committed
🐛 Prevent invalid annotations caused by list shadowing by method signature.
1 parent c7154c6 commit c0b78ce

File tree

4,824 files changed

+258000
-244823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,824 files changed

+258000
-244823
lines changed

codegen/parser/schemas/schema.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,38 +357,46 @@ class ListSchema(SchemaData):
357357

358358
@override
359359
def get_type_string(self, include_constraints: bool = True) -> str:
360-
type_string = f"list[{self.item_schema.get_type_string()}]"
360+
type_string = f"builtins.list[{self.item_schema.get_type_string()}]"
361361
if include_constraints and (args := self._get_field_args()):
362362
return f"Annotated[{type_string}, {self._get_field_string(args)}]"
363363
return type_string
364364

365365
@override
366366
def get_param_type_string(self) -> str:
367-
return f"list[{self.item_schema.get_param_type_string()}]"
367+
# We **must** refer to `builtins.list` here explicitly to avoid shadowing:
368+
# class A:
369+
# def list(self): ...
370+
# def meth(self) -> list[int]: ... # Oops, it's the `list` method, bad hint
371+
return f"builtins.list[{self.item_schema.get_param_type_string()}]"
368372

369373
@override
370374
def get_model_imports(self) -> set[str]:
371375
imports = super().get_model_imports()
372376
imports.add("from githubkit.compat import PYDANTIC_V2")
377+
imports.add("import builtins")
373378
imports.update(self.item_schema.get_model_imports())
374379
return imports
375380

376381
@override
377382
def get_type_imports(self) -> set[str]:
378383
imports = super().get_type_imports()
384+
imports.add("import builtins")
379385
imports.update(self.item_schema.get_type_imports())
380386
return imports
381387

382388
@override
383389
def get_param_imports(self) -> set[str]:
384390
imports = super().get_param_imports()
391+
imports.add("import builtins")
385392
imports.update(self.item_schema.get_param_imports())
386393
return imports
387394

388395
@override
389396
def get_using_imports(self) -> set[str]:
390397
imports = super().get_using_imports()
391398
imports.add("from githubkit.compat import PYDANTIC_V2")
399+
imports.add("import builtins")
392400
imports.update(self.item_schema.get_using_imports())
393401
return imports
394402

githubkit/rest/__init__.py

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@
3131
from githubkit.versions.v2022_11_28.models import (
3232
ActionsGetDefaultWorkflowPermissions as ActionsGetDefaultWorkflowPermissions,
3333
)
34+
from githubkit.versions.v2022_11_28.models import (
35+
ActionsHostedRunner as ActionsHostedRunner,
36+
)
37+
from githubkit.versions.v2022_11_28.models import (
38+
ActionsHostedRunnerImage as ActionsHostedRunnerImage,
39+
)
40+
from githubkit.versions.v2022_11_28.models import (
41+
ActionsHostedRunnerLimits as ActionsHostedRunnerLimits,
42+
)
43+
from githubkit.versions.v2022_11_28.models import (
44+
ActionsHostedRunnerLimitsPropPublicIps as ActionsHostedRunnerLimitsPropPublicIps,
45+
)
46+
from githubkit.versions.v2022_11_28.models import (
47+
ActionsHostedRunnerMachineSpec as ActionsHostedRunnerMachineSpec,
48+
)
49+
from githubkit.versions.v2022_11_28.models import (
50+
ActionsHostedRunnerPoolImage as ActionsHostedRunnerPoolImage,
51+
)
3452
from githubkit.versions.v2022_11_28.models import (
3553
ActionsOrganizationPermissions as ActionsOrganizationPermissions,
3654
)
@@ -1039,6 +1057,10 @@
10391057
from githubkit.versions.v2022_11_28.models import (
10401058
MovedColumnInProjectIssueEventPropProjectCard as MovedColumnInProjectIssueEventPropProjectCard,
10411059
)
1060+
from githubkit.versions.v2022_11_28.models import (
1061+
NetworkConfiguration as NetworkConfiguration,
1062+
)
1063+
from githubkit.versions.v2022_11_28.models import NetworkSettings as NetworkSettings
10421064
from githubkit.versions.v2022_11_28.models import (
10431065
NotificationsPutBody as NotificationsPutBody,
10441066
)
@@ -1141,6 +1163,30 @@
11411163
from githubkit.versions.v2022_11_28.models import (
11421164
OrgsOrgActionsCacheUsageByRepositoryGetResponse200 as OrgsOrgActionsCacheUsageByRepositoryGetResponse200,
11431165
)
1166+
from githubkit.versions.v2022_11_28.models import (
1167+
OrgsOrgActionsHostedRunnersGetResponse200 as OrgsOrgActionsHostedRunnersGetResponse200,
1168+
)
1169+
from githubkit.versions.v2022_11_28.models import (
1170+
OrgsOrgActionsHostedRunnersHostedRunnerIdPatchBody as OrgsOrgActionsHostedRunnersHostedRunnerIdPatchBody,
1171+
)
1172+
from githubkit.versions.v2022_11_28.models import (
1173+
OrgsOrgActionsHostedRunnersImagesGithubOwnedGetResponse200 as OrgsOrgActionsHostedRunnersImagesGithubOwnedGetResponse200,
1174+
)
1175+
from githubkit.versions.v2022_11_28.models import (
1176+
OrgsOrgActionsHostedRunnersImagesPartnerGetResponse200 as OrgsOrgActionsHostedRunnersImagesPartnerGetResponse200,
1177+
)
1178+
from githubkit.versions.v2022_11_28.models import (
1179+
OrgsOrgActionsHostedRunnersMachineSizesGetResponse200 as OrgsOrgActionsHostedRunnersMachineSizesGetResponse200,
1180+
)
1181+
from githubkit.versions.v2022_11_28.models import (
1182+
OrgsOrgActionsHostedRunnersPlatformsGetResponse200 as OrgsOrgActionsHostedRunnersPlatformsGetResponse200,
1183+
)
1184+
from githubkit.versions.v2022_11_28.models import (
1185+
OrgsOrgActionsHostedRunnersPostBody as OrgsOrgActionsHostedRunnersPostBody,
1186+
)
1187+
from githubkit.versions.v2022_11_28.models import (
1188+
OrgsOrgActionsHostedRunnersPostBodyPropImage as OrgsOrgActionsHostedRunnersPostBodyPropImage,
1189+
)
11441190
from githubkit.versions.v2022_11_28.models import (
11451191
OrgsOrgActionsPermissionsPutBody as OrgsOrgActionsPermissionsPutBody,
11461192
)
@@ -1156,6 +1202,9 @@
11561202
from githubkit.versions.v2022_11_28.models import (
11571203
OrgsOrgActionsRunnerGroupsPostBody as OrgsOrgActionsRunnerGroupsPostBody,
11581204
)
1205+
from githubkit.versions.v2022_11_28.models import (
1206+
OrgsOrgActionsRunnerGroupsRunnerGroupIdHostedRunnersGetResponse200 as OrgsOrgActionsRunnerGroupsRunnerGroupIdHostedRunnersGetResponse200,
1207+
)
11591208
from githubkit.versions.v2022_11_28.models import (
11601209
OrgsOrgActionsRunnerGroupsRunnerGroupIdPatchBody as OrgsOrgActionsRunnerGroupsRunnerGroupIdPatchBody,
11611210
)
@@ -1429,6 +1478,15 @@
14291478
from githubkit.versions.v2022_11_28.models import (
14301479
OrgsOrgSecurityProductEnablementPostBody as OrgsOrgSecurityProductEnablementPostBody,
14311480
)
1481+
from githubkit.versions.v2022_11_28.models import (
1482+
OrgsOrgSettingsNetworkConfigurationsGetResponse200 as OrgsOrgSettingsNetworkConfigurationsGetResponse200,
1483+
)
1484+
from githubkit.versions.v2022_11_28.models import (
1485+
OrgsOrgSettingsNetworkConfigurationsNetworkConfigurationIdPatchBody as OrgsOrgSettingsNetworkConfigurationsNetworkConfigurationIdPatchBody,
1486+
)
1487+
from githubkit.versions.v2022_11_28.models import (
1488+
OrgsOrgSettingsNetworkConfigurationsPostBody as OrgsOrgSettingsNetworkConfigurationsPostBody,
1489+
)
14321490
from githubkit.versions.v2022_11_28.models import (
14331491
OrgsOrgTeamsPostBody as OrgsOrgTeamsPostBody,
14341492
)
@@ -1703,6 +1761,7 @@
17031761
from githubkit.versions.v2022_11_28.models import (
17041762
ProtectedBranchRequiredStatusCheckPropChecksItems as ProtectedBranchRequiredStatusCheckPropChecksItems,
17051763
)
1764+
from githubkit.versions.v2022_11_28.models import PublicIp as PublicIp
17061765
from githubkit.versions.v2022_11_28.models import PublicUser as PublicUser
17071766
from githubkit.versions.v2022_11_28.models import (
17081767
PublicUserPropPlan as PublicUserPropPlan,
@@ -9641,6 +9700,7 @@
96419700
"GlobalAdvisoryPropCreditsItems",
96429701
"BasicError",
96439702
"ValidationErrorSimple",
9703+
"Enterprise",
96449704
"IntegrationPropPermissions",
96459705
"Integration",
96469706
"WebhookConfig",
@@ -9654,7 +9714,6 @@
96549714
"HookDeliveryPropRequestPropPayload",
96559715
"HookDeliveryPropResponse",
96569716
"HookDeliveryPropResponsePropHeaders",
9657-
"Enterprise",
96589717
"IntegrationInstallationRequest",
96599718
"AppPermissions",
96609719
"Installation",
@@ -9754,6 +9813,13 @@
97549813
"OrganizationFull",
97559814
"OrganizationFullPropPlan",
97569815
"ActionsCacheUsageOrgEnterprise",
9816+
"ActionsHostedRunnerMachineSpec",
9817+
"ActionsHostedRunner",
9818+
"ActionsHostedRunnerPoolImage",
9819+
"PublicIp",
9820+
"ActionsHostedRunnerImage",
9821+
"ActionsHostedRunnerLimits",
9822+
"ActionsHostedRunnerLimitsPropPublicIps",
97579823
"OidcCustomSub",
97589824
"ActionsOrganizationPermissions",
97599825
"SelectedActions",
@@ -9920,6 +9986,7 @@
99209986
"ActionsBillingUsagePropMinutesUsedBreakdown",
99219987
"PackagesBillingUsage",
99229988
"CombinedBillingUsage",
9989+
"NetworkSettings",
99239990
"TeamFull",
99249991
"TeamOrganization",
99259992
"TeamOrganizationPropPlan",
@@ -12536,13 +12603,22 @@
1253612603
"OrgsOrgPatchBody",
1253712604
"OrgsOrgActionsCacheUsageByRepositoryGetResponse200",
1253812605
"ActionsCacheUsageByRepository",
12606+
"OrgsOrgActionsHostedRunnersGetResponse200",
12607+
"OrgsOrgActionsHostedRunnersPostBody",
12608+
"OrgsOrgActionsHostedRunnersPostBodyPropImage",
12609+
"OrgsOrgActionsHostedRunnersImagesGithubOwnedGetResponse200",
12610+
"OrgsOrgActionsHostedRunnersImagesPartnerGetResponse200",
12611+
"OrgsOrgActionsHostedRunnersMachineSizesGetResponse200",
12612+
"OrgsOrgActionsHostedRunnersPlatformsGetResponse200",
12613+
"OrgsOrgActionsHostedRunnersHostedRunnerIdPatchBody",
1253912614
"OrgsOrgActionsPermissionsPutBody",
1254012615
"OrgsOrgActionsPermissionsRepositoriesGetResponse200",
1254112616
"OrgsOrgActionsPermissionsRepositoriesPutBody",
1254212617
"OrgsOrgActionsRunnerGroupsGetResponse200",
1254312618
"RunnerGroupsOrg",
1254412619
"OrgsOrgActionsRunnerGroupsPostBody",
1254512620
"OrgsOrgActionsRunnerGroupsRunnerGroupIdPatchBody",
12621+
"OrgsOrgActionsRunnerGroupsRunnerGroupIdHostedRunnersGetResponse200",
1254612622
"OrgsOrgActionsRunnerGroupsRunnerGroupIdRepositoriesGetResponse200",
1254712623
"OrgsOrgActionsRunnerGroupsRunnerGroupIdRepositoriesPutBody",
1254812624
"OrgsOrgActionsRunnerGroupsRunnerGroupIdRunnersGetResponse200",
@@ -12634,6 +12710,10 @@
1263412710
"OrgsOrgReposPostBodyPropCustomProperties",
1263512711
"OrgsOrgRulesetsPostBody",
1263612712
"OrgsOrgRulesetsRulesetIdPutBody",
12713+
"OrgsOrgSettingsNetworkConfigurationsGetResponse200",
12714+
"NetworkConfiguration",
12715+
"OrgsOrgSettingsNetworkConfigurationsPostBody",
12716+
"OrgsOrgSettingsNetworkConfigurationsNetworkConfigurationIdPatchBody",
1263712717
"OrgsOrgTeamsPostBody",
1263812718
"OrgsOrgTeamsTeamSlugPatchBody",
1263912719
"OrgsOrgTeamsTeamSlugDiscussionsPostBody",

0 commit comments

Comments
 (0)