diff --git a/github/InstallationAuthorization.py b/github/InstallationAuthorization.py index 036a3eef..8309b58c 100644 --- a/github/InstallationAuthorization.py +++ b/github/InstallationAuthorization.py @@ -22,63 +22,55 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING -import github.GithubObject import github.NamedUser import github.PaginatedList +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser -class InstallationAuthorization(github.GithubObject.NonCompletableGithubObject): +class InstallationAuthorization(NonCompletableGithubObject): """ This class represents InstallationAuthorizations """ + def _initAttributes(self) -> None: + self._token: Attribute[str] = NotSet + self._expires_at: Attribute[datetime] = NotSet + self._on_behalf_of: Attribute[NamedUser] = NotSet + self._permissions: Attribute[dict] = NotSet + self._repository_selection: Attribute[str] = NotSet + def __repr__(self): return self.get__repr__({"expires_at": self._expires_at.value}) @property - def token(self): - """ - :type: string - """ + def token(self) -> str: return self._token.value @property - def expires_at(self): - """ - :type: datetime - """ + def expires_at(self) -> datetime: return self._expires_at.value @property - def on_behalf_of(self): - """ - :type: :class:`github.NamedUser.NamedUser` - """ + def on_behalf_of(self) -> NamedUser: return self._on_behalf_of.value @property - def permissions(self): - """ - :type: dict - """ + def permissions(self) -> dict: return self._permissions.value @property - def repository_selection(self): - """ - :type: string - """ + def repository_selection(self) -> str: return self._repository_selection.value - def _initAttributes(self): - self._token = github.GithubObject.NotSet - self._expires_at = github.GithubObject.NotSet - self._on_behalf_of = github.GithubObject.NotSet - self._permissions = github.GithubObject.NotSet - self._repository_selection = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "token" in attributes: # pragma no branch self._token = self._makeStringAttribute(attributes["token"]) if "expires_at" in attributes: # pragma no branch diff --git a/github/InstallationAuthorization.pyi b/github/InstallationAuthorization.pyi deleted file mode 100644 index 8ef8e38f..00000000 --- a/github/InstallationAuthorization.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject -from github.NamedUser import NamedUser - -class InstallationAuthorization(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def expires_at(self) -> datetime: ... - @property - def on_behalf_of(self) -> NamedUser: ... - @property - def token(self) -> str: ... - @property - def permissions(self) -> dict: ... - @property - def repository_selection(self) -> str: ... diff --git a/github/IssuePullRequest.py b/github/IssuePullRequest.py index b7d73da6..f9c8eb4a 100644 --- a/github/IssuePullRequest.py +++ b/github/IssuePullRequest.py @@ -27,41 +27,33 @@ # # ################################################################################ -import github.GithubObject + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class IssuePullRequest(github.GithubObject.NonCompletableGithubObject): +class IssuePullRequest(NonCompletableGithubObject): """ This class represents IssuePullRequests """ + def _initAttributes(self) -> None: + self._diff_url: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._patch_url: Attribute[str] = NotSet + @property - def diff_url(self): - """ - :type: string - """ + def diff_url(self) -> str: return self._diff_url.value @property - def html_url(self): - """ - :type: string - """ + def html_url(self) -> str: return self._html_url.value @property - def patch_url(self): - """ - :type: string - """ + def patch_url(self) -> str: return self._patch_url.value - def _initAttributes(self): - self._diff_url = github.GithubObject.NotSet - self._html_url = github.GithubObject.NotSet - self._patch_url = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "diff_url" in attributes: # pragma no branch self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "html_url" in attributes: # pragma no branch diff --git a/github/IssuePullRequest.pyi b/github/IssuePullRequest.pyi deleted file mode 100644 index c1a2eae7..00000000 --- a/github/IssuePullRequest.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject - -class IssuePullRequest(NonCompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def diff_url(self) -> str: ... - @property - def html_url(self) -> str: ... - @property - def patch_url(self) -> str: ... diff --git a/github/NotificationSubject.py b/github/NotificationSubject.py index 9b2266de..59343303 100644 --- a/github/NotificationSubject.py +++ b/github/NotificationSubject.py @@ -26,52 +26,41 @@ # # ################################################################################ -import github.GithubObject + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class NotificationSubject(github.GithubObject.NonCompletableGithubObject): +class NotificationSubject(NonCompletableGithubObject): """ This class represents Subjects of Notifications. The reference can be found here https://docs.github.com/en/rest/reference/activity#list-notifications-for-the-authenticated-user """ + def _initAttributes(self) -> None: + self._title: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + self._latest_comment_url: Attribute[str] = NotSet + self._type: Attribute[str] = NotSet + def __repr__(self): return self.get__repr__({"title": self._title.value}) @property - def title(self): - """ - :type: string - """ + def title(self) -> str: return self._title.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: return self._url.value @property - def latest_comment_url(self): - """ - :type: string - """ + def latest_comment_url(self) -> str: return self._latest_comment_url.value @property - def type(self): - """ - :type: string - """ + def type(self) -> str: return self._type.value - def _initAttributes(self): - self._title = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - self._latest_comment_url = github.GithubObject.NotSet - self._type = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch diff --git a/github/NotificationSubject.pyi b/github/NotificationSubject.pyi deleted file mode 100644 index f05ff13b..00000000 --- a/github/NotificationSubject.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Any, Dict, Optional - -from github.GithubObject import NonCompletableGithubObject - -class NotificationSubject(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def latest_comment_url(self) -> Optional[str]: ... - @property - def title(self) -> str: ... - @property - def type(self) -> str: ... - @property - def url(self) -> Optional[str]: ... diff --git a/github/PublicKey.py b/github/PublicKey.py index 28118edf..3a2d7889 100644 --- a/github/PublicKey.py +++ b/github/PublicKey.py @@ -29,52 +29,48 @@ ################################################################################ # https://docs.github.com/en/rest/reference/actions#example-encrypting-a-secret-using-python +from __future__ import annotations + from base64 import b64encode from nacl import encoding, public -import github.GithubObject +from github.GithubObject import Attribute, CompletableGithubObject, NotSet def encrypt(public_key: str, secret_value: str) -> str: """Encrypt a Unicode string using the public key.""" - public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder()) - sealed_box = public.SealedBox(public_key) + pk = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder) + sealed_box = public.SealedBox(pk) encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) return b64encode(encrypted).decode("utf-8") -class PublicKey(github.GithubObject.CompletableGithubObject): +class PublicKey(CompletableGithubObject): """ This class represents either an organization public key or a repository public key. The reference can be found here https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key or here https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key """ + def _initAttributes(self) -> None: + self._key_id: Attribute[str | int] = NotSet + self._key: Attribute[str] = NotSet + def __repr__(self): return self.get__repr__({"key_id": self._key_id.value, "key": self._key.value}) @property - def key(self): - """ - :type: string - """ + def key(self) -> str: self._completeIfNotSet(self._key) return self._key.value @property - def key_id(self): - """ - :type: string or int - """ + def key_id(self) -> str | int: self._completeIfNotSet(self._key_id) return self._key_id.value - def _initAttributes(self): - self._key = github.GithubObject.NotSet - self._key_id = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "key" in attributes: # pragma no branch self._key = self._makeStringAttribute(attributes["key"]) if "key_id" in attributes: # pragma no branch @@ -83,5 +79,5 @@ class PublicKey(github.GithubObject.CompletableGithubObject): else: self._key_id = self._makeIntAttribute(attributes["key_id"]) - def encrypt(self, unencrypted_value): + def encrypt(self, unencrypted_value: str) -> str: return encrypt(self._key.value, unencrypted_value) diff --git a/github/PublicKey.pyi b/github/PublicKey.pyi deleted file mode 100644 index 4f7b47bd..00000000 --- a/github/PublicKey.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Any, Dict, Union - -from github.GithubObject import CompletableGithubObject - -class PublicKey(CompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def key_id(self) -> Union[str, int]: ... - @property - def key(self) -> str: ... - def encrypt(self, unencrypted_value: str) -> str: ... diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index 94ab3f37..054dbf49 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -27,63 +27,55 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations + +from typing import TYPE_CHECKING -import github.GithubObject import github.NamedUser import github.Repository +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + from github.Repository import Repository -class PullRequestPart(github.GithubObject.NonCompletableGithubObject): +class PullRequestPart(NonCompletableGithubObject): """ This class represents PullRequestParts """ + def _initAttributes(self) -> None: + self._label: Attribute[str] = NotSet + self._ref: Attribute[str] = NotSet + self._repo: Attribute[Repository] = NotSet + self._sha: Attribute[str] = NotSet + self._user: Attribute[NamedUser] = NotSet + def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property - def label(self): - """ - :type: string - """ + def label(self) -> str: return self._label.value @property - def ref(self): - """ - :type: string - """ + def ref(self) -> str: return self._ref.value @property - def repo(self): - """ - :type: :class:`github.Repository.Repository` - """ + def repo(self) -> Repository: return self._repo.value @property - def sha(self): - """ - :type: string - """ + def sha(self) -> str: return self._sha.value @property - def user(self): - """ - :type: :class:`github.NamedUser.NamedUser` - """ + def user(self) -> NamedUser: return self._user.value - def _initAttributes(self): - self._label = github.GithubObject.NotSet - self._ref = github.GithubObject.NotSet - self._repo = github.GithubObject.NotSet - self._sha = github.GithubObject.NotSet - self._user = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "label" in attributes: # pragma no branch self._label = self._makeStringAttribute(attributes["label"]) if "ref" in attributes: # pragma no branch diff --git a/github/PullRequestPart.pyi b/github/PullRequestPart.pyi deleted file mode 100644 index 082e6bc2..00000000 --- a/github/PullRequestPart.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Any, Dict, Optional - -from github.GithubObject import NonCompletableGithubObject -from github.NamedUser import NamedUser -from github.Repository import Repository - -class PullRequestPart(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def label(self) -> str: ... - @property - def ref(self) -> str: ... - @property - def repo(self) -> Repository: ... - @property - def sha(self) -> str: ... - @property - def user(self) -> Optional[NamedUser]: ... diff --git a/github/Rate.py b/github/Rate.py index 9cb9f881..048dbe55 100644 --- a/github/Rate.py +++ b/github/Rate.py @@ -26,14 +26,22 @@ # # ################################################################################ -import github.GithubObject +from datetime import datetime + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class Rate(github.GithubObject.NonCompletableGithubObject): +class Rate(NonCompletableGithubObject): """ This class represents Rates. The reference can be found here https://docs.github.com/en/rest/reference/rate-limit """ + def _initAttributes(self): + self._limit: Attribute[int] = NotSet + self._remaining: Attribute[int] = NotSet + self._reset: Attribute[datetime] = NotSet + self._used: Attribute[int] = NotSet + def __repr__(self): return self.get__repr__( { @@ -44,39 +52,21 @@ class Rate(github.GithubObject.NonCompletableGithubObject): ) @property - def limit(self): - """ - :type: integer - """ + def limit(self) -> int: return self._limit.value @property - def remaining(self): - """ - :type: integer - """ + def remaining(self) -> int: return self._remaining.value @property - def reset(self): - """ - :type: datetime.datetime - """ + def reset(self) -> datetime: return self._reset.value @property - def used(self): - """ - :type: integer - """ + def used(self) -> int: return self._used.value - def _initAttributes(self): - self._limit = github.GithubObject.NotSet - self._remaining = github.GithubObject.NotSet - self._reset = github.GithubObject.NotSet - self._used = github.GithubObject.NotSet - def _useAttributes(self, attributes): if "limit" in attributes: # pragma no branch self._limit = self._makeIntAttribute(attributes["limit"]) diff --git a/github/Rate.pyi b/github/Rate.pyi deleted file mode 100644 index 1f888974..00000000 --- a/github/Rate.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject - -class Rate(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def limit(self) -> int: ... - @property - def remaining(self) -> int: ... - @property - def reset(self) -> datetime: ... - @property - def used(self) -> int: ... diff --git a/github/RateLimit.py b/github/RateLimit.py index be1404ef..203d7d68 100644 --- a/github/RateLimit.py +++ b/github/RateLimit.py @@ -25,20 +25,32 @@ # # ################################################################################ -import github.GithubObject +from __future__ import annotations + +from typing import TYPE_CHECKING + import github.Rate +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Rate import Rate -class RateLimit(github.GithubObject.NonCompletableGithubObject): +class RateLimit(NonCompletableGithubObject): """ This class represents RateLimits. The reference can be found here https://docs.github.com/en/rest/reference/rate-limit """ + def _initAttributes(self) -> None: + self._core: Attribute[Rate] = NotSet + self._search: Attribute[Rate] = NotSet + self._graphql: Attribute[Rate] = NotSet + def __repr__(self): return self.get__repr__({"core": self._core.value}) @property - def core(self): + def core(self) -> Rate: """ Rate limit for the non-search-related API @@ -47,7 +59,7 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject): return self._core.value @property - def search(self): + def search(self) -> Rate: """ Rate limit for the Search API. @@ -56,7 +68,7 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject): return self._search.value @property - def graphql(self): + def graphql(self) -> Rate: """ (Experimental) Rate limit for GraphQL API, use with caution. @@ -64,12 +76,7 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject): """ return self._graphql.value - def _initAttributes(self): - self._core = github.GithubObject.NotSet - self._search = github.GithubObject.NotSet - self._graphql = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "core" in attributes: # pragma no branch self._core = self._makeClassAttribute(github.Rate.Rate, attributes["core"]) if "search" in attributes: # pragma no branch diff --git a/github/RateLimit.pyi b/github/RateLimit.pyi deleted file mode 100644 index d9192c82..00000000 --- a/github/RateLimit.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject -from github.Rate import Rate - -class RateLimit(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def core(self) -> Rate: ... - @property - def graphql(self) -> Rate: ... - @property - def rate(self) -> Rate: ... - @property - def search(self) -> Rate: ... diff --git a/github/Reaction.py b/github/Reaction.py index c7728086..f88b3767 100644 --- a/github/Reaction.py +++ b/github/Reaction.py @@ -21,54 +21,55 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING -import github.GithubObject import github.NamedUser +from github.GithubObject import Attribute, CompletableGithubObject, NotSet from . import Consts +if TYPE_CHECKING: + from github.NamedUser import NamedUser -class Reaction(github.GithubObject.CompletableGithubObject): + +class Reaction(CompletableGithubObject): """ This class represents Reactions. The reference can be found here https://docs.github.com/en/rest/reference/reactions """ + def _initAttributes(self) -> None: + self._content: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._id: Attribute[int] = NotSet + self._user: Attribute[NamedUser] = NotSet + def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property - def content(self): - """ - :type: string - """ + def content(self) -> str: self._completeIfNotSet(self._content) return self._content.value @property - def created_at(self): - """ - :type: datetime.datetime - """ + def created_at(self) -> datetime: self._completeIfNotSet(self._created_at) return self._created_at.value @property - def id(self): - """ - :type: integer - """ + def id(self) -> int: self._completeIfNotSet(self._id) return self._id.value @property - def user(self): - """ - :type: :class:`github.NamedUser.NamedUser` - """ + def user(self) -> NamedUser: self._completeIfNotSet(self._user) return self._user.value - def delete(self): + def delete(self) -> None: """ :calls: `DELETE /reactions/{id} `_ :rtype: None @@ -79,13 +80,7 @@ class Reaction(github.GithubObject.CompletableGithubObject): headers={"Accept": Consts.mediaTypeReactionsPreview}, ) - def _initAttributes(self): - self._content = github.GithubObject.NotSet - self._created_at = github.GithubObject.NotSet - self._id = github.GithubObject.NotSet - self._user = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "content" in attributes: # pragma no branch self._content = self._makeStringAttribute(attributes["content"]) if "created_at" in attributes: # pragma no branch diff --git a/github/Reaction.pyi b/github/Reaction.pyi deleted file mode 100644 index 216918ad..00000000 --- a/github/Reaction.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from github.GithubObject import CompletableGithubObject -from github.NamedUser import NamedUser - -class Reaction(CompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def content(self) -> str: ... - @property - def created_at(self) -> datetime: ... - def delete(self) -> None: ... - @property - def id(self) -> int: ... - @property - def user(self) -> NamedUser: ... diff --git a/github/RepositoryPreferences.py b/github/RepositoryPreferences.py index 467264e0..ae01de82 100644 --- a/github/RepositoryPreferences.py +++ b/github/RepositoryPreferences.py @@ -20,35 +20,36 @@ # # ################################################################################ -import github.GithubObject +from __future__ import annotations + +from typing import TYPE_CHECKING + import github.Repository +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Repository import Repository -class RepositoryPreferences(github.GithubObject.NonCompletableGithubObject): +class RepositoryPreferences(NonCompletableGithubObject): """ This class represents repository preferences. The reference can be found here https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-repository-preferences-for-check-suites """ + def _initAttributes(self) -> None: + self._preferences: Attribute[dict[str, list[dict[str, bool | int]]]] = NotSet + self._repository: Attribute[Repository] = NotSet + @property - def preferences(self): - """ - :type: dict - """ + def preferences(self) -> dict[str, list[dict[str, bool | int]]]: return self._preferences.value @property - def repository(self): - """ - :type: :class:`github.Repository.Repository` - """ + def repository(self) -> Repository: return self._repository.value - def _initAttributes(self): - self._preferences = github.GithubObject.NotSet - self._repository = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "preferences" in attributes: # pragma no branch self._preferences = self._makeDictAttribute(attributes["preferences"]) if "repository" in attributes: # pragma no branch diff --git a/github/RepositoryPreferences.pyi b/github/RepositoryPreferences.pyi deleted file mode 100644 index f405734c..00000000 --- a/github/RepositoryPreferences.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from typing import Any, Dict, List, Union - -from github.GithubObject import NonCompletableGithubObject -from github.Repository import Repository - -class RepositoryPreferences(NonCompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def preferences(self) -> Dict[str, List[Dict[str, Union[bool, int]]]]: ... - @property - def repository(self) -> Repository: ... diff --git a/github/RequiredPullRequestReviews.py b/github/RequiredPullRequestReviews.py index 1e899017..885acccb 100644 --- a/github/RequiredPullRequestReviews.py +++ b/github/RequiredPullRequestReviews.py @@ -20,9 +20,18 @@ # # ################################################################################ +from __future__ import annotations + +from typing import TYPE_CHECKING + import github.GithubObject import github.NamedUser import github.Team +from github.GithubObject import Attribute, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + from github.Team import Team class RequiredPullRequestReviews(github.GithubObject.CompletableGithubObject): @@ -30,6 +39,13 @@ class RequiredPullRequestReviews(github.GithubObject.CompletableGithubObject): This class represents Required Pull Request Reviews. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-pull-request-review-protection """ + def _initAttributes(self) -> None: + self._dismiss_stale_reviews: Attribute[bool] = NotSet + self._require_code_owner_reviews: Attribute[bool] = NotSet + self._required_approving_review_count: Attribute[int] = NotSet + self._users: Attribute[NamedUser] = NotSet + self._teams: Attribute[Team] = NotSet + def __repr__(self): return self.get__repr__( { @@ -40,61 +56,36 @@ class RequiredPullRequestReviews(github.GithubObject.CompletableGithubObject): ) @property - def dismiss_stale_reviews(self): - """ - :type: bool - """ + def dismiss_stale_reviews(self) -> bool: self._completeIfNotSet(self._dismiss_stale_reviews) return self._dismiss_stale_reviews.value @property - def require_code_owner_reviews(self): - """ - :type: bool - """ + def require_code_owner_reviews(self) -> bool: self._completeIfNotSet(self._require_code_owner_reviews) return self._require_code_owner_reviews.value @property - def required_approving_review_count(self): - """ - :type: int - """ + def required_approving_review_count(self) -> int: self._completeIfNotSet(self._required_approving_review_count) return self._required_approving_review_count.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: self._completeIfNotSet(self._url) return self._url.value @property - def dismissal_users(self): - """ - :type: list of :class:`github.NamedUser.NamedUser` - """ + def dismissal_users(self) -> NamedUser: self._completeIfNotSet(self._users) return self._users.value @property - def dismissal_teams(self): - """ - :type: list of :class:`github.Team.Team` - """ + def dismissal_teams(self) -> Team: self._completeIfNotSet(self._teams) return self._teams.value - def _initAttributes(self): - self._dismiss_stale_reviews = github.GithubObject.NotSet - self._require_code_owner_reviews = github.GithubObject.NotSet - self._required_approving_review_count = github.GithubObject.NotSet - self._users = github.GithubObject.NotSet - self._teams = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "dismissal_restrictions" in attributes: # pragma no branch if "users" in attributes["dismissal_restrictions"]: self._users = self._makeListOfClassesAttribute( diff --git a/github/RequiredPullRequestReviews.pyi b/github/RequiredPullRequestReviews.pyi deleted file mode 100644 index 4d1c5884..00000000 --- a/github/RequiredPullRequestReviews.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Any, Dict, List, Optional - -from github.GithubObject import CompletableGithubObject -from github.NamedUser import NamedUser -from github.Team import Team - -class RequiredPullRequestReviews(CompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def dismiss_stale_reviews(self) -> bool: ... - @property - def dismissal_teams(self) -> Optional[List[Team]]: ... - @property - def dismissal_users(self) -> Optional[List[NamedUser]]: ... - @property - def require_code_owner_reviews(self) -> bool: ... - @property - def required_approving_review_count(self) -> int: ... - @property - def url(self) -> int: ... diff --git a/github/SelfHostedActionsRunner.py b/github/SelfHostedActionsRunner.py index 129e3f4c..f7fe2423 100644 --- a/github/SelfHostedActionsRunner.py +++ b/github/SelfHostedActionsRunner.py @@ -20,68 +20,52 @@ # # ################################################################################ -import github.GithubObject +from __future__ import annotations + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class SelfHostedActionsRunner(github.GithubObject.NonCompletableGithubObject): +class SelfHostedActionsRunner(NonCompletableGithubObject): """ This class represents Self-hosted GitHub Actions Runners. The reference can be found at https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners """ + def _initAttributes(self) -> None: + self._id: Attribute[int] = NotSet + self._name: Attribute[str] = NotSet + self._os: Attribute[str] = NotSet + self._status: Attribute[str] = NotSet + self._busy: Attribute[bool] = NotSet + self._labels: Attribute[list[dict[str, int | str]]] = NotSet + def __repr__(self): return self.get__repr__({"name": self._name.value}) @property - def id(self): - """ - :type: int - """ + def id(self) -> int: return self._id.value @property - def name(self): - """ - :type: string - """ + def name(self) -> str: return self._name.value @property - def os(self): - """ - :type: string - """ + def os(self) -> str: return self._os.value @property - def status(self): - """ - :type: str - """ + def status(self) -> str: return self._status.value @property - def busy(self): - """ - :type: bool - """ + def busy(self) -> bool: return self._busy.value - def labels(self): - """ - :type: list of dicts - """ + def labels(self) -> list[dict[str, int | str]]: return self._labels.value - def _initAttributes(self): - self._id = github.GithubObject.NotSet - self._name = github.GithubObject.NotSet - self._os = github.GithubObject.NotSet - self._status = github.GithubObject.NotSet - self._busy = github.GithubObject.NotSet - self._labels = [] - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch diff --git a/github/SelfHostedActionsRunner.pyi b/github/SelfHostedActionsRunner.pyi deleted file mode 100644 index 0ab60ba0..00000000 --- a/github/SelfHostedActionsRunner.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, Dict, List, Union - -from github.GithubObject import NonCompletableGithubObject - -class SelfHostedActionsRunner(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def id(self) -> int: ... - @property - def name(self) -> str: ... - @property - def os(self) -> str: ... - @property - def status(self) -> str: ... - @property - def busy(self) -> bool: ... - def labels(self) -> List[Dict[str, Union[str, int]]]: ... diff --git a/github/Stargazer.py b/github/Stargazer.py index 7e3334e6..94bf1917 100644 --- a/github/Stargazer.py +++ b/github/Stargazer.py @@ -23,38 +23,40 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING import github +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser -class Stargazer(github.GithubObject.NonCompletableGithubObject): +class Stargazer(NonCompletableGithubObject): """ This class represents Stargazers. The reference can be found here https://docs.github.com/en/rest/reference/activity#starring """ + def _initAttributes(self) -> None: + self._starred_at: Attribute[datetime] = NotSet + self._user: Attribute[NamedUser] = NotSet + self._url: Attribute[str] = NotSet + def __repr__(self): return self.get__repr__({"user": self._user.value._login.value}) @property - def starred_at(self): - """ - :type: datetime.datetime - """ + def starred_at(self) -> datetime: return self._starred_at.value @property - def user(self): - """ - :type: :class:`github.NamedUser` - """ + def user(self) -> NamedUser: return self._user.value - def _initAttributes(self): - self._starred_at = github.GithubObject.NotSet - self._user = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "starred_at" in attributes: self._starred_at = self._makeDatetimeAttribute(attributes["starred_at"]) if "user" in attributes: diff --git a/github/Stargazer.pyi b/github/Stargazer.pyi deleted file mode 100644 index 7f7284ef..00000000 --- a/github/Stargazer.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject -from github.NamedUser import NamedUser - -class Stargazer(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def starred_at(self) -> datetime: ... - @property - def user(self) -> NamedUser: ... diff --git a/github/StatsCommitActivity.py b/github/StatsCommitActivity.py index d8be09b4..21c7765f 100755 --- a/github/StatsCommitActivity.py +++ b/github/StatsCommitActivity.py @@ -23,8 +23,10 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from datetime import datetime import github.GithubObject +from github.GithubObject import Attribute class StatsCommitActivity(github.GithubObject.NonCompletableGithubObject): @@ -32,33 +34,24 @@ class StatsCommitActivity(github.GithubObject.NonCompletableGithubObject): This class represents StatsCommitActivities. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-the-last-year-of-commit-activity """ + def _initAttributes(self) -> None: + self._week: Attribute[datetime] = github.GithubObject.NotSet + self._total: Attribute[int] = github.GithubObject.NotSet + self._days: Attribute[int] = github.GithubObject.NotSet + @property - def week(self): - """ - :type: datetime.datetime - """ + def week(self) -> datetime: return self._week.value @property - def total(self): - """ - :type: int - """ + def total(self) -> int: return self._total.value @property - def days(self): - """ - :type: list of int - """ + def days(self) -> int: return self._days.value - def _initAttributes(self): - self._week = github.GithubObject.NotSet - self._total = github.GithubObject.NotSet - self._days = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "week" in attributes: # pragma no branch self._week = self._makeTimestampAttribute(attributes["week"]) if "total" in attributes: # pragma no branch diff --git a/github/StatsCommitActivity.pyi b/github/StatsCommitActivity.pyi deleted file mode 100644 index 12243e5d..00000000 --- a/github/StatsCommitActivity.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from datetime import datetime -from typing import Any, Dict, List - -from github.GithubObject import NonCompletableGithubObject - -class StatsCommitActivity(NonCompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def days(self) -> List[int]: ... - @property - def total(self) -> int: ... - @property - def week(self) -> datetime: ... diff --git a/github/StatsParticipation.py b/github/StatsParticipation.py index 92ff31f1..261ead1a 100755 --- a/github/StatsParticipation.py +++ b/github/StatsParticipation.py @@ -23,34 +23,29 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations -import github.GithubObject +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class StatsParticipation(github.GithubObject.NonCompletableGithubObject): +class StatsParticipation(NonCompletableGithubObject): """ This class represents StatsParticipations. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-the-weekly-commit-count """ + def _initAttributes(self) -> None: + self._all: Attribute[list[int]] = NotSet + self._owner: Attribute[list[int]] = NotSet + @property - def all(self): - """ - :type: list of int - """ + def all(self) -> list[int]: return self._all.value @property - def owner(self): - """ - :type: list of int - """ + def owner(self) -> list[int]: return self._owner.value - def _initAttributes(self): - self._all = github.GithubObject.NotSet - self._owner = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "all" in attributes: # pragma no branch self._all = self._makeListOfIntsAttribute(attributes["all"]) if "owner" in attributes: # pragma no branch diff --git a/github/StatsParticipation.pyi b/github/StatsParticipation.pyi deleted file mode 100644 index 45dc6605..00000000 --- a/github/StatsParticipation.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Dict, List - -from github.GithubObject import NonCompletableGithubObject - -class StatsParticipation(NonCompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, List[int]]) -> None: ... - @property - def all(self) -> List[int]: ... - @property - def owner(self) -> List[int]: ... diff --git a/github/StatsPunchCard.py b/github/StatsPunchCard.py index b84dab20..71895ae8 100755 --- a/github/StatsPunchCard.py +++ b/github/StatsPunchCard.py @@ -23,6 +23,7 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from typing import Dict, Tuple import github.GithubObject import github.NamedUser # TODO remove unused @@ -33,19 +34,15 @@ class StatsPunchCard(github.GithubObject.NonCompletableGithubObject): This class represents StatsPunchCards. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-the-hourly-commit-count-for-each-day """ - def get(self, day, hour): - """ - Get a specific element + _dict: Dict[Tuple[int, int], int] - :param day: int - :param hour: int - :rtype: int - """ + def get(self, day: int, hour: int) -> int: + """Get a specific element""" return self._dict[(day, hour)] - def _initAttributes(self): + def _initAttributes(self) -> None: self._dict = {} - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: for day, hour, commits in attributes: self._dict[(day, hour)] = commits diff --git a/github/StatsPunchCard.pyi b/github/StatsPunchCard.pyi deleted file mode 100644 index 03353169..00000000 --- a/github/StatsPunchCard.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import List - -from github.GithubObject import NonCompletableGithubObject - -class StatsPunchCard(NonCompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: List[List[int]]) -> None: ... - def get(self, day: int, hour: int) -> int: ... diff --git a/github/Tag.py b/github/Tag.py index 8203dcbb..9fac78bf 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -28,12 +28,18 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations + +from typing import TYPE_CHECKING import github.Commit -import github.GithubObject +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Commit import Commit -class Tag(github.GithubObject.NonCompletableGithubObject): +class Tag(NonCompletableGithubObject): """ This class represents Tags. The reference can be found here https://docs.github.com/en/rest/reference/repos#list-repository-tags """ @@ -43,41 +49,29 @@ class Tag(github.GithubObject.NonCompletableGithubObject): {"name": self._name.value, "commit": self._commit.value} ) + def _initAttributes(self) -> None: + self._commit: Attribute[Commit] = NotSet + self._name: Attribute[str] = NotSet + self._tarball_url: Attribute[str] = NotSet + self._zipball_url: Attribute[str] = NotSet + @property - def commit(self): - """ - :type: :class:`github.Commit.Commit` - """ + def commit(self) -> Commit: return self._commit.value @property - def name(self): - """ - :type: string - """ + def name(self) -> str: return self._name.value @property - def tarball_url(self): - """ - :type: string - """ + def tarball_url(self) -> str: return self._tarball_url.value @property - def zipball_url(self): - """ - :type: string - """ + def zipball_url(self) -> str: return self._zipball_url.value - def _initAttributes(self): - self._commit = github.GithubObject.NotSet - self._name = github.GithubObject.NotSet - self._tarball_url = github.GithubObject.NotSet - self._zipball_url = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "commit" in attributes: # pragma no branch self._commit = self._makeClassAttribute( github.Commit.Commit, attributes["commit"] diff --git a/github/Tag.pyi b/github/Tag.pyi deleted file mode 100644 index 019c1bde..00000000 --- a/github/Tag.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Any, Dict - -from github.Commit import Commit -from github.GithubObject import NonCompletableGithubObject - -class Tag(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def commit(self) -> Commit: ... - @property - def name(self) -> str: ... - @property - def tarball_url(self) -> str: ... - @property - def zipball_url(self) -> str: ... diff --git a/github/TimelineEventSource.py b/github/TimelineEventSource.py index c64fd88f..e7574e6c 100644 --- a/github/TimelineEventSource.py +++ b/github/TimelineEventSource.py @@ -20,37 +20,38 @@ # # ################################################################################ -import github.GithubObject +from __future__ import annotations + +from typing import TYPE_CHECKING + import github.Issue +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Issue import Issue -class TimelineEventSource(github.GithubObject.NonCompletableGithubObject): +class TimelineEventSource(NonCompletableGithubObject): """ This class represents IssueTimelineEventSource. The reference can be found here https://docs.github.com/en/rest/reference/issues#timeline """ + def _initAttributes(self) -> None: + self._type: Attribute[str] = NotSet + self._issue: Attribute[Issue] = NotSet + def __repr__(self): return self.get__repr__({"type": self._type.value}) @property - def type(self): - """ - :type: string - """ + def type(self) -> str: return self._type.value @property - def issue(self): - """ - :type: :class:`github.Issue.Issue` - """ + def issue(self) -> Issue: return self._issue.value - def _initAttributes(self): - self._type = github.GithubObject.NotSet - self._issue = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "issue" in attributes: # pragma no branch diff --git a/github/TimelineEventSource.pyi b/github/TimelineEventSource.pyi deleted file mode 100644 index 8a7d31d1..00000000 --- a/github/TimelineEventSource.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject -from github.Issue import Issue - -class TimelineEventSource(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def type(self) -> str: ... - @property - def issue(self) -> Issue: ... diff --git a/github/UserKey.py b/github/UserKey.py index 5acfb5e7..e101a00a 100644 --- a/github/UserKey.py +++ b/github/UserKey.py @@ -30,6 +30,7 @@ ################################################################################ import github.GithubObject +from github.GithubObject import Attribute class UserKey(github.GithubObject.CompletableGithubObject): @@ -37,64 +38,49 @@ class UserKey(github.GithubObject.CompletableGithubObject): This class represents UserKeys. The reference can be found here https://docs.github.com/en/rest/reference/users#keys """ + def _initAttributes(self) -> None: + self._id: Attribute[int] = github.GithubObject.NotSet + self._key: Attribute[str] = github.GithubObject.NotSet + self._title: Attribute[str] = github.GithubObject.NotSet + self._url: Attribute[str] = github.GithubObject.NotSet + self._verified: Attribute[bool] = github.GithubObject.NotSet + def __repr__(self): return self.get__repr__({"id": self._id.value, "title": self._title.value}) @property - def id(self): - """ - :type: integer - """ + def id(self) -> int: self._completeIfNotSet(self._id) return self._id.value @property - def key(self): - """ - :type: string - """ + def key(self) -> str: self._completeIfNotSet(self._key) return self._key.value @property - def title(self): - """ - :type: string - """ + def title(self) -> str: self._completeIfNotSet(self._title) return self._title.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: self._completeIfNotSet(self._url) return self._url.value @property - def verified(self): - """ - :type: bool - """ + def verified(self) -> bool: self._completeIfNotSet(self._verified) return self._verified.value - def delete(self): + def delete(self) -> None: """ :calls: `DELETE /user/keys/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) - def _initAttributes(self): - self._id = github.GithubObject.NotSet - self._key = github.GithubObject.NotSet - self._title = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - self._verified = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch diff --git a/github/UserKey.pyi b/github/UserKey.pyi deleted file mode 100644 index 4aa4aadb..00000000 --- a/github/UserKey.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, Dict - -from github.GithubObject import CompletableGithubObject - -class UserKey(CompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - def delete(self) -> None: ... - @property - def id(self) -> int: ... - @property - def key(self) -> str: ... - @property - def title(self) -> str: ... - @property - def url(self) -> str: ... - @property - def verified(self) -> bool: ... diff --git a/github/View.py b/github/View.py index e3f3e495..dae12829 100644 --- a/github/View.py +++ b/github/View.py @@ -24,15 +24,22 @@ # # ################################################################################ -import github.GithubObject +from datetime import datetime + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class View(github.GithubObject.NonCompletableGithubObject): +class View(NonCompletableGithubObject): """ This class represents a popular Path for a GitHub repository. The reference can be found here https://docs.github.com/en/rest/reference/repos#traffic """ + def _initAttributes(self) -> None: + self._timestamp: Attribute[datetime] = NotSet + self._count: Attribute[int] = NotSet + self._uniques: Attribute[int] = NotSet + def __repr__(self): return self.get__repr__( { @@ -43,32 +50,18 @@ class View(github.GithubObject.NonCompletableGithubObject): ) @property - def timestamp(self): - """ - :type: datetime.datetime - """ + def timestamp(self) -> datetime: return self._timestamp.value @property - def count(self): - """ - :type: integer - """ + def count(self) -> int: return self._count.value @property - def uniques(self): - """ - :type: integer - """ + def uniques(self) -> int: return self._uniques.value - def _initAttributes(self): - self._timestamp = github.GithubObject.NotSet - self._count = github.GithubObject.NotSet - self._uniques = github.GithubObject.NotSet - - def _useAttributes(self, attributes): + def _useAttributes(self, attributes) -> None: if "timestamp" in attributes: # pragma no branch self._timestamp = self._makeDatetimeAttribute(attributes["timestamp"]) if "count" in attributes: # pragma no branch diff --git a/github/View.pyi b/github/View.pyi deleted file mode 100644 index dd45c7d6..00000000 --- a/github/View.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from github.GithubObject import NonCompletableGithubObject - -class View(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def timestamp(self) -> datetime: ... - @property - def count(self) -> int: ... - @property - def uniques(self) -> int: ...