diff --git a/github/Migration.py b/github/Migration.py index e293e829..2d4f1b69 100644 --- a/github/Migration.py +++ b/github/Migration.py @@ -29,109 +29,89 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations -from typing import Any, Dict +from datetime import datetime +from typing import Any import github.GithubObject import github.NamedUser import github.PaginatedList - -from . import Consts +import github.Repository +from github import Consts +from github.GithubObject import Attribute, CompletableGithubObject, NotSet -class Migration(github.GithubObject.CompletableGithubObject): +class Migration(CompletableGithubObject): """ This class represents Migrations. The reference can be found here https://docs.github.com/en/rest/reference/migrations """ + def _initAttributes(self) -> None: + self._id: Attribute[int] = NotSet + self._owner: Attribute[github.NamedUser.NamedUser] = NotSet + self._guid: Attribute[str] = NotSet + self._state: Attribute[str] = NotSet + self._lock_repositories: Attribute[bool] = NotSet + self._exclude_attachments: Attribute[bool] = NotSet + self._repositories: Attribute[list[github.Repository.Repository]] = NotSet + self._url: Attribute[str] = NotSet + def __repr__(self) -> str: return self.get__repr__({"state": self._state.value, "url": self._url.value}) @property - def id(self): - """ - :type: int - """ + def id(self) -> int: return self._id.value @property - def owner(self): - """ - :type: :class:`github.NamedUser.NamedUser` - """ + def owner(self) -> github.NamedUser.NamedUser: self._completeIfNotSet(self._owner) return self._owner.value @property - def guid(self): - """ - :type: str - """ + def guid(self) -> str: self._completeIfNotSet(self._guid) return self._guid.value @property - def state(self): - """ - :type: str - """ + def state(self) -> str: self._completeIfNotSet(self._guid) return self._state.value @property - def lock_repositories(self): - """ - :type: bool - """ + def lock_repositories(self) -> bool: self._completeIfNotSet(self._repositories) return self._lock_repositories.value @property - def exclude_attachments(self): - """ - :type: bool - """ + def exclude_attachments(self) -> bool: self._completeIfNotSet(self._exclude_attachments) return self._exclude_attachments.value @property - def repositories(self): - """ - :type: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` - """ + def repositories(self) -> list[github.Repository.Repository]: self._completeIfNotSet(self._repositories) return self._repositories.value @property - def url(self): - """ - :type: str - """ + def url(self) -> str: self._completeIfNotSet(self._url) return self._url.value @property - def created_at(self): - """ - :type: datetime.datetime - :rtype: None - """ + def created_at(self) -> datetime: self._completeIfNotSet(self._created_at) return self._created_at.value @property - def updated_at(self): - """ - :type: datetime.datetime - :rtype: None - """ + def updated_at(self) -> datetime: self._completeIfNotSet(self._updated_at) return self._updated_at.value - def get_status(self): + def get_status(self) -> str: """ :calls: `GET /user/migrations/{migration_id} `_ - :rtype: str """ headers, data = self._requester.requestJsonAndCheck( "GET", self.url, headers={"Accept": Consts.mediaTypeMigrationPreview} @@ -139,10 +119,9 @@ class Migration(github.GithubObject.CompletableGithubObject): self._useAttributes(data) return self.state - def get_archive_url(self): + def get_archive_url(self) -> str: """ :calls: `GET /user/migrations/{migration_id}/archive `_ - :rtype: str """ headers, data = self._requester.requestJsonAndCheck( "GET", @@ -151,7 +130,7 @@ class Migration(github.GithubObject.CompletableGithubObject): ) return data["data"] - def delete(self): + def delete(self) -> None: """ :calls: `DELETE /user/migrations/{migration_id}/archive `_ """ @@ -161,11 +140,9 @@ class Migration(github.GithubObject.CompletableGithubObject): headers={"Accept": Consts.mediaTypeMigrationPreview}, ) - def unlock_repo(self, repo_name): + def unlock_repo(self, repo_name: str) -> None: """ :calls: `DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock `_ - :param repo_name: str - :rtype: None """ assert isinstance(repo_name, str), repo_name headers, data = self._requester.requestJsonAndCheck( @@ -174,19 +151,7 @@ class Migration(github.GithubObject.CompletableGithubObject): headers={"Accept": Consts.mediaTypeMigrationPreview}, ) - def _initAttributes(self) -> None: - self._id = github.GithubObject.NotSet - self._owner = github.GithubObject.NotSet - self._guid = github.GithubObject.NotSet - self._state = github.GithubObject.NotSet - self._lock_repositories = github.GithubObject.NotSet - self._exclude_attachments = github.GithubObject.NotSet - self._repositories = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - self._created_at = github.GithubObject.NotSet - self._updated_at = github.GithubObject.NotSet - - def _useAttributes(self, attributes: Dict[str, Any]) -> None: + def _useAttributes(self, attributes: dict[str, Any]) -> None: if "id" in attributes: self._id = self._makeIntAttribute(attributes["id"]) if "owner" in attributes: diff --git a/github/Migration.pyi b/github/Migration.pyi deleted file mode 100644 index f6432716..00000000 --- a/github/Migration.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from datetime import datetime -from typing import Any, Dict, List - -from github.GithubObject import CompletableGithubObject -from github.NamedUser import NamedUser -from github.Repository import Repository - -class Migration(CompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def created_at(self) -> datetime: ... - def delete(self) -> None: ... - @property - def exclude_attachments(self) -> bool: ... - def get_archive_url(self) -> str: ... - def get_status(self) -> str: ... - @property - def guid(self) -> str: ... - @property - def id(self) -> int: ... - @property - def lock_repositories(self) -> bool: ... - @property - def owner(self) -> NamedUser: ... - @property - def repositories(self) -> List[Repository]: ... - @property - def state(self) -> str: ... - def unlock_repo(self, repo_name: str) -> None: ... - @property - def updated_at(self) -> datetime: ... - @property - def url(self) -> str: ...