Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 14 additions & 12 deletions codegen/parser/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def _get_field_args(self) -> dict[str, str]:

@dataclass(kw_only=True)
class DateTimeSchema(SchemaData):
_type_string: ClassVar[str] = "datetime"
# avoid conflict with field name which will cause pydantic analyze error
_type_string: ClassVar[str] = "_dt.datetime"

@override
def get_response_type_string(self) -> str:
Expand All @@ -303,37 +304,38 @@ def get_response_type_string(self) -> str:
@override
def get_model_imports(self) -> set[str]:
imports = super().get_model_imports()
imports.add("from datetime import datetime")
imports.add("import datetime as _dt")
return imports

@override
def get_type_imports(self) -> set[str]:
imports = super().get_type_imports()
imports.add("from datetime import datetime")
imports.add("import datetime as _dt")
return imports

@override
def get_param_imports(self) -> set[str]:
imports = super().get_param_imports()
imports.add("from datetime import datetime")
imports.add("import datetime as _dt")
return imports

@override
def get_using_imports(self) -> set[str]:
imports = super().get_using_imports()
imports.add("from datetime import datetime")
imports.add("import datetime as _dt")
return imports

@override
def get_response_imports(self) -> set[str]:
imports = super().get_response_imports()
imports.add("from datetime import datetime")
imports.add("import datetime as _dt")
return imports


@dataclass(kw_only=True)
class DateSchema(SchemaData):
_type_string: ClassVar[str] = "date"
# avoid conflict with field name which will cause pydantic analyze error
_type_string: ClassVar[str] = "_dt.date"

@override
def get_response_type_string(self) -> str:
Expand All @@ -344,31 +346,31 @@ def get_response_type_string(self) -> str:
@override
def get_model_imports(self) -> set[str]:
imports = super().get_model_imports()
imports.add("from datetime import date")
imports.add("import datetime as _dt")
return imports

@override
def get_type_imports(self) -> set[str]:
imports = super().get_type_imports()
imports.add("from datetime import date")
imports.add("import datetime as _dt")
return imports

@override
def get_param_imports(self) -> set[str]:
imports = super().get_param_imports()
imports.add("from datetime import date")
imports.add("import datetime as _dt")
return imports

@override
def get_using_imports(self) -> set[str]:
imports = super().get_using_imports()
imports.add("from datetime import date")
imports.add("import datetime as _dt")
return imports

@override
def get_response_imports(self) -> set[str]:
imports = super().get_response_imports()
imports.add("from datetime import date")
imports.add("import datetime as _dt")
return imports


Expand Down
12 changes: 6 additions & 6 deletions githubkit/versions/ghec_v2022_11_28/models/group_0004.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Annotated, Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -55,19 +55,19 @@ class GlobalAdvisory(GitHubModel):
)
identifiers: Union[list[GlobalAdvisoryPropIdentifiersItems], None] = Field()
references: Union[list[str], None] = Field()
published_at: datetime = Field(
published_at: _dt.datetime = Field(
description="The date and time of when the advisory was published, in ISO 8601 format."
)
updated_at: datetime = Field(
updated_at: _dt.datetime = Field(
description="The date and time of when the advisory was last updated, in ISO 8601 format."
)
github_reviewed_at: Union[datetime, None] = Field(
github_reviewed_at: Union[_dt.datetime, None] = Field(
description="The date and time of when the advisory was reviewed by GitHub, in ISO 8601 format."
)
nvd_published_at: Union[datetime, None] = Field(
nvd_published_at: Union[_dt.datetime, None] = Field(
description="The date and time when the advisory was published in the National Vulnerability Database, in ISO 8601 format.\nThis field is only populated when the advisory is imported from the National Vulnerability Database."
)
withdrawn_at: Union[datetime, None] = Field(
withdrawn_at: Union[_dt.datetime, None] = Field(
description="The date and time of when the advisory was withdrawn, in ISO 8601 format."
)
vulnerabilities: Union[list[Vulnerability], None] = Field(
Expand Down
6 changes: 3 additions & 3 deletions githubkit/versions/ghec_v2022_11_28/models/group_0008.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand All @@ -36,8 +36,8 @@ class Enterprise(GitHubModel):
node_id: str = Field()
name: str = Field(description="The name of the enterprise.")
slug: str = Field(description="The slug url identifier for the enterprise.")
created_at: Union[datetime, None] = Field()
updated_at: Union[datetime, None] = Field()
created_at: Union[_dt.datetime, None] = Field()
updated_at: Union[_dt.datetime, None] = Field()
avatar_url: str = Field()


Expand Down
6 changes: 3 additions & 3 deletions githubkit/versions/ghec_v2022_11_28/models/group_0010.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand Down Expand Up @@ -43,8 +43,8 @@ class actors within GitHub.
description: Union[str, None] = Field()
external_url: str = Field()
html_url: str = Field()
created_at: datetime = Field()
updated_at: datetime = Field()
created_at: _dt.datetime = Field()
updated_at: _dt.datetime = Field()
permissions: IntegrationPropPermissions = Field(
description="The set of permissions for the GitHub app"
)
Expand Down
6 changes: 3 additions & 3 deletions githubkit/versions/ghec_v2022_11_28/models/group_0012.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand All @@ -29,7 +29,7 @@ class HookDeliveryItem(GitHubModel):
guid: str = Field(
description="Unique identifier for the event (shared with all deliveries for all webhooks that subscribe to this event)."
)
delivered_at: datetime = Field(
delivered_at: _dt.datetime = Field(
description="Time when the webhook delivery occurred."
)
redelivery: bool = Field(
Expand All @@ -50,7 +50,7 @@ class HookDeliveryItem(GitHubModel):
repository_id: Union[int, None] = Field(
description="The id of the repository associated with this event."
)
throttled_at: Missing[Union[datetime, None]] = Field(
throttled_at: Missing[Union[_dt.datetime, None]] = Field(
default=UNSET, description="Time when the webhook delivery was throttled."
)

Expand Down
8 changes: 5 additions & 3 deletions githubkit/versions/ghec_v2022_11_28/models/group_0015.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand All @@ -29,7 +29,9 @@ class HookDelivery(GitHubModel):
guid: str = Field(
description="Unique identifier for the event (shared with all deliveries for all webhooks that subscribe to this event)."
)
delivered_at: datetime = Field(description="Time when the delivery was delivered.")
delivered_at: _dt.datetime = Field(
description="Time when the delivery was delivered."
)
redelivery: bool = Field(description="Whether the delivery is a redelivery.")
duration: float = Field(description="Time spent delivering.")
status: str = Field(
Expand All @@ -46,7 +48,7 @@ class HookDelivery(GitHubModel):
repository_id: Union[int, None] = Field(
description="The id of the repository associated with this event."
)
throttled_at: Missing[Union[datetime, None]] = Field(
throttled_at: Missing[Union[_dt.datetime, None]] = Field(
default=UNSET, description="Time when the webhook delivery was throttled."
)
url: Missing[str] = Field(
Expand Down
4 changes: 2 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/models/group_0016.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand All @@ -32,7 +32,7 @@ class IntegrationInstallationRequest(GitHubModel):
node_id: Missing[str] = Field(default=UNSET)
account: Union[SimpleUser, Enterprise] = Field()
requester: SimpleUser = Field(title="Simple User", description="A GitHub user.")
created_at: datetime = Field()
created_at: _dt.datetime = Field()


model_rebuild(IntegrationInstallationRequest)
Expand Down
8 changes: 4 additions & 4 deletions githubkit/versions/ghec_v2022_11_28/models/group_0018.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -48,14 +48,14 @@ class Installation(GitHubModel):
description="The permissions granted to the user access token.",
)
events: list[str] = Field()
created_at: datetime = Field()
updated_at: datetime = Field()
created_at: _dt.datetime = Field()
updated_at: _dt.datetime = Field()
single_file_name: Union[str, None] = Field()
has_multiple_single_files: Missing[bool] = Field(default=UNSET)
single_file_paths: Missing[list[str]] = Field(default=UNSET)
app_slug: str = Field()
suspended_by: Union[None, SimpleUser] = Field()
suspended_at: Union[datetime, None] = Field()
suspended_at: Union[_dt.datetime, None] = Field()
contact_email: Missing[Union[str, None]] = Field(default=UNSET)


Expand Down
8 changes: 4 additions & 4 deletions githubkit/versions/ghec_v2022_11_28/models/group_0020.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -121,9 +121,9 @@ class Repository(GitHubModel):
default=UNSET,
description="The repository visibility: public, private, or internal.",
)
pushed_at: Union[datetime, None] = Field()
created_at: Union[datetime, None] = Field()
updated_at: Union[datetime, None] = Field()
pushed_at: Union[_dt.datetime, None] = Field()
created_at: Union[_dt.datetime, None] = Field()
updated_at: Union[_dt.datetime, None] = Field()
allow_rebase_merge: Missing[bool] = Field(
default=UNSET, description="Whether to allow rebase merges for pull requests."
)
Expand Down
8 changes: 4 additions & 4 deletions githubkit/versions/ghec_v2022_11_28/models/group_0023.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Union

from pydantic import Field
Expand Down Expand Up @@ -39,12 +39,12 @@ class Authorization(GitHubModel):
app: AuthorizationPropApp = Field()
note: Union[str, None] = Field()
note_url: Union[str, None] = Field()
updated_at: datetime = Field()
created_at: datetime = Field()
updated_at: _dt.datetime = Field()
created_at: _dt.datetime = Field()
fingerprint: Union[str, None] = Field()
user: Missing[Union[None, SimpleUser]] = Field(default=UNSET)
installation: Missing[Union[None, ScopedInstallation]] = Field(default=UNSET)
expires_at: Union[datetime, None] = Field()
expires_at: Union[_dt.datetime, None] = Field()


class AuthorizationPropApp(GitHubModel):
Expand Down
4 changes: 2 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/models/group_0025.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -65,7 +65,7 @@ class ClassroomAssignment(GitHubModel):
language: str = Field(
description="The programming language used in the assignment."
)
deadline: Union[datetime, None] = Field(
deadline: Union[_dt.datetime, None] = Field(
description="The time at which the assignment is due."
)
starter_code_repository: SimpleClassroomRepository = Field(
Expand Down
4 changes: 2 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/models/group_0026.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -105,7 +105,7 @@ class SimpleClassroomAssignment(GitHubModel):
language: Union[str, None] = Field(
description="The programming language used in the assignment."
)
deadline: Union[datetime, None] = Field(
deadline: Union[_dt.datetime, None] = Field(
description="The time at which the assignment is due."
)
classroom: SimpleClassroom = Field(
Expand Down
4 changes: 2 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/models/group_0032.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand Down Expand Up @@ -53,7 +53,7 @@ class ActionsHostedRunner(GitHubModel):
default=UNSET,
description="The public IP ranges when public IP is enabled for the hosted runners.",
)
last_active_on: Missing[Union[datetime, None]] = Field(
last_active_on: Missing[Union[_dt.datetime, None]] = Field(
default=UNSET,
description="The time at which the runner was last used, in ISO 8601 format.",
)
Expand Down
4 changes: 2 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/models/group_0051.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations

from datetime import datetime
import datetime as _dt
from typing import Literal, Union

from pydantic import Field
Expand All @@ -28,7 +28,7 @@ class AuthenticationToken(GitHubModel):
"""

token: str = Field(description="The token used for authentication")
expires_at: datetime = Field(description="The time this token expires")
expires_at: _dt.datetime = Field(description="The time this token expires")
permissions: Missing[AuthenticationTokenPropPermissions] = Field(default=UNSET)
repositories: Missing[list[Repository]] = Field(
default=UNSET, description="The repositories this token has access to"
Expand Down
Loading
Loading