From 13e178a3abcdc1acfb3dd63aecc2f5e22b7772ae Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:37:20 +0200 Subject: [PATCH] Set line length to 120 characters (#2599) --- .isort.cfg | 2 +- doc/conf.py | 4 +- github/AccessToken.py | 8 +- github/Artifact.py | 26 +- github/Auth.py | 48 +- github/AuthenticatedUser.py | 312 ++---- github/AuthenticatedUser.pyi | 4 +- github/Authorization.py | 8 +- github/Branch.py | 88 +- github/BranchProtection.py | 12 +- github/CheckRun.py | 56 +- github/CheckRun.pyi | 4 +- github/CheckRunAnnotation.py | 4 +- github/CheckRunOutput.py | 8 +- github/CheckSuite.py | 28 +- github/CheckSuite.pyi | 4 +- github/CodeScanAlert.py | 16 +- github/CodeScanAlertInstance.py | 4 +- github/CodeScanRule.py | 4 +- github/Commit.py | 68 +- github/CommitCombinedStatus.py | 8 +- github/CommitComment.py | 8 +- github/CommitStatus.py | 4 +- github/Comparison.py | 16 +- github/Consts.py | 4 +- github/ContentFile.py | 20 +- github/Deployment.py | 48 +- github/DeploymentStatus.py | 16 +- github/EnvironmentDeploymentBranchPolicy.py | 12 +- github/EnvironmentProtectionRule.py | 4 +- github/EnvironmentProtectionRuleReviewer.py | 8 +- github/Event.py | 12 +- github/File.py | 8 +- github/Gist.py | 52 +- github/GistComment.py | 8 +- github/GistHistoryState.py | 24 +- github/GitCommit.py | 16 +- github/GitRef.py | 16 +- github/GitRelease.py | 34 +- github/GitReleaseAsset.py | 12 +- github/GitTag.py | 8 +- github/GitTree.py | 4 +- github/GithubApp.py | 4 +- github/GithubIntegration.py | 30 +- github/GithubObject.py | 69 +- github/GithubRetry.py | 58 +- github/Hook.py | 8 +- github/HookDelivery.py | 12 +- github/HookDescription.py | 4 +- github/InstallationAuthorization.py | 8 +- github/Invitation.py | 12 +- github/Issue.py | 160 +-- github/IssueComment.py | 8 +- github/IssueEvent.py | 28 +- github/Label.py | 4 +- github/Label.pyi | 4 +- github/License.py | 16 +- github/MainClass.py | 124 +-- github/MainClass.pyi | 54 +- github/Membership.py | 12 +- github/Migration.py | 12 +- github/Milestone.py | 20 +- github/NamedUser.py | 86 +- github/NamedUser.pyi | 4 +- github/Notification.py | 12 +- github/NotificationSubject.py | 4 +- github/Organization.py | 281 ++--- github/Organization.pyi | 12 +- github/PaginatedList.py | 5 +- github/Project.py | 12 +- github/ProjectCard.py | 24 +- github/ProjectCard.pyi | 8 +- github/ProjectColumn.py | 8 +- github/ProjectColumn.pyi | 4 +- github/PullRequest.py | 244 ++--- github/PullRequest.pyi | 12 +- github/PullRequestComment.py | 20 +- github/PullRequestPart.py | 8 +- github/PullRequestReview.py | 12 +- github/RateLimit.py | 8 +- github/Reaction.py | 4 +- github/Repository.py | 974 +++++------------- github/Repository.pyi | 92 +- github/RepositoryAdvisory.py | 109 +- github/RepositoryAdvisoryCredit.py | 8 +- github/RepositoryAdvisoryCreditDetailed.py | 4 +- github/RepositoryAdvisoryVulnerability.py | 32 +- .../RepositoryAdvisoryVulnerabilityPackage.py | 4 +- github/RepositoryPreferences.py | 4 +- github/Requester.py | 149 +-- github/RequiredPullRequestReviews.py | 8 +- github/SourceImport.py | 16 +- github/Stargazer.py | 4 +- github/StatsContributor.py | 8 +- github/Tag.py | 8 +- github/Team.py | 80 +- github/Team.pyi | 12 +- github/TeamDiscussion.py | 12 +- github/TimelineEvent.py | 18 +- github/TimelineEventSource.py | 4 +- github/Topic.py | 4 +- github/Workflow.py | 26 +- github/WorkflowJob.py | 4 +- github/WorkflowRun.py | 34 +- github/WorkflowStep.py | 4 +- pyproject.toml | 4 + scripts/add_attribute.py | 36 +- scripts/fix_headers.py | 6 +- tests/ApplicationOAuth.py | 47 +- tests/AuthenticatedUser.py | 46 +- tests/Authentication.py | 32 +- tests/Authorization.py | 16 +- tests/Autolink.py | 14 +- tests/BadAttributes.py | 8 +- tests/Branch.py | 64 +- tests/BranchProtection.py | 11 +- tests/CheckRun.py | 20 +- tests/CheckSuite.py | 16 +- tests/Commit.py | 40 +- tests/CommitCombinedStatus.py | 8 +- tests/CommitComment.py | 4 +- tests/CommitStatus.py | 9 +- tests/ConditionalRequestUpdate.py | 4 +- tests/Connection.py | 8 +- tests/Deployment.py | 12 +- tests/DeploymentStatus.py | 4 +- tests/Enterprise.py | 4 +- tests/Environment.py | 22 +- tests/Exceptions.py | 16 +- tests/ExposeAllAttributes.py | 4 +- tests/Framework.py | 58 +- tests/Gist.py | 16 +- tests/GistComment.py | 4 +- tests/GitBlob.py | 6 +- tests/GitCommit.py | 18 +- tests/GitRef.py | 14 +- tests/GitRelease.py | 24 +- tests/GitTag.py | 10 +- tests/GitTree.py | 14 +- tests/GithubApp.py | 20 +- tests/GithubIntegration.py | 68 +- tests/GithubObject.py | 4 +- tests/GithubRetry.py | 38 +- tests/Github_.py | 16 +- tests/Hook.py | 4 +- tests/Installation.py | 24 +- tests/Issue.py | 60 +- tests/Issue134.py | 4 +- tests/Issue140.py | 4 +- tests/Issue494.py | 3 +- tests/Issue80.py | 16 +- tests/Issue87.py | 12 +- tests/Issue945.py | 28 +- tests/IssueComment.py | 4 +- tests/IssueEvent.py | 116 +-- tests/Label.py | 8 +- tests/License.py | 4 +- tests/Logging_.py | 12 +- tests/Migration.py | 12 +- tests/Milestone.py | 4 +- tests/NamedUser.py | 8 +- tests/Organization.py | 98 +- tests/Organization2072.py | 8 +- tests/PaginatedList.py | 8 +- tests/Project.py | 48 +- tests/ProjectColumn.py | 4 +- tests/PublicKey.py | 8 +- tests/PullRequest.py | 84 +- tests/PullRequest1168.py | 4 +- tests/PullRequest1375.py | 4 +- tests/PullRequest2408.py | 4 +- tests/PullRequestComment.py | 12 +- tests/PullRequestReview.py | 4 +- tests/RateLimiting.py | 4 +- tests/RawData.py | 4 +- tests/Reaction.py | 7 +- tests/Repository.py | 210 +--- tests/RepositoryAdvisory.py | 4 +- tests/RepositoryKey.py | 8 +- tests/Requester.py | 58 +- tests/RequiredPullRequestReviews.py | 9 +- tests/RequiredStatusChecks.py | 5 +- tests/Retry.py | 4 +- tests/Search.py | 24 +- tests/SourceImport.py | 4 +- tests/Tag.py | 12 +- tests/Team.py | 36 +- tests/Topic.py | 8 +- tests/Workflow.py | 20 +- tests/WorkflowRun.py | 8 +- tests/conftest.py | 4 +- tox.ini | 2 +- 192 files changed, 1455 insertions(+), 4433 deletions(-) create mode 100644 pyproject.toml diff --git a/.isort.cfg b/.isort.cfg index 58fc9801..16f37d47 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -3,6 +3,6 @@ multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 use_parentheses=True -line_length=88 +line_length=120 known_third_party=dateutil,deprecated,httpretty,jwt,nacl,pytest,requests,setuptools,typing_extensions,urllib3 known_first_party=github diff --git a/doc/conf.py b/doc/conf.py index 0dd2e847..2b5d697d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -362,7 +362,5 @@ with open("apis.rst", "w") as apis: apis.write("\n") for verb in ["GET", "PATCH", "POST", "PUT", "DELETE"]: if verb in verbs: - apis.write( - " * " + verb + ": " + " or ".join(sorted(verbs[verb])) + "\n" - ) + apis.write(" * " + verb + ": " + " or ".join(sorted(verbs[verb])) + "\n") apis.write("\n") diff --git a/github/AccessToken.py b/github/AccessToken.py index e5c23fc9..2a3000b5 100644 --- a/github/AccessToken.py +++ b/github/AccessToken.py @@ -48,9 +48,7 @@ class AccessToken(NonCompletableGithubObject): "scope": self.scope, "type": self.type, "expires_in": self.expires_in, - "refresh_token": ( - f"{self.refresh_token[:5]}..." if self.refresh_token else None - ), + "refresh_token": (f"{self.refresh_token[:5]}..." if self.refresh_token else None), "refresh_token_expires_in": self.refresh_expires_in, } ) @@ -137,6 +135,4 @@ class AccessToken(NonCompletableGithubObject): if "refresh_token" in attributes: # pragma no branch self._refresh_token = self._makeStringAttribute(attributes["refresh_token"]) if "refresh_token_expires_in" in attributes: # pragma no branch - self._refresh_expires_in = self._makeIntAttribute( - attributes["refresh_token_expires_in"] - ) + self._refresh_expires_in = self._makeIntAttribute(attributes["refresh_token_expires_in"]) diff --git a/github/Artifact.py b/github/Artifact.py index 286978b9..db94d6e6 100644 --- a/github/Artifact.py +++ b/github/Artifact.py @@ -110,20 +110,18 @@ class Artifact(NonCompletableGithubObject): def _useAttributes(self, attributes): if "archive_download_url" in attributes: # pragma no branch - self._archive_download_url = self._makeStringAttribute( - attributes["archive_download_url"] - ) + self._archive_download_url = self._makeStringAttribute(attributes["archive_download_url"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance( - attributes["created_at"], (str,) - ), attributes["created_at"] + assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str,)), attributes[ + "created_at" + ] self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "expired" in attributes: # pragma no branch self._expired = self._makeBoolAttribute(attributes["expired"]) if "expires_at" in attributes: # pragma no branch - assert attributes["expires_at"] is None or isinstance( - attributes["expires_at"], (str,) - ), attributes["expires_at"] + assert attributes["expires_at"] is None or isinstance(attributes["expires_at"], (str,)), attributes[ + "expires_at" + ] self._expires_at = self._makeDatetimeAttribute(attributes["expires_at"]) if "head_sha" in attributes: # pragma no branch self._head_sha = self._makeStringAttribute(attributes["head_sha"]) @@ -136,13 +134,11 @@ class Artifact(NonCompletableGithubObject): if "size_in_bytes" in attributes: # pragma no branch self._size_in_bytes = self._makeIntAttribute(attributes["size_in_bytes"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance( - attributes["updated_at"], (str,) - ), attributes["updated_at"] + assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str,)), attributes[ + "updated_at" + ] self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "workflow_run" in attributes: # pragma no branch - self._workflow_run = self._makeClassAttribute( - github.WorkflowRun.WorkflowRun, attributes["workflow_run"] - ) + self._workflow_run = self._makeClassAttribute(github.WorkflowRun.WorkflowRun, attributes["workflow_run"]) diff --git a/github/Auth.py b/github/Auth.py index dc73667e..3d67e4e5 100644 --- a/github/Auth.py +++ b/github/Auth.py @@ -34,9 +34,7 @@ from github.Requester import Requester, WithRequester # For App authentication, time remaining before token expiration to request a new one ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS = 20 -TOKEN_REFRESH_THRESHOLD_TIMEDELTA = timedelta( - seconds=ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS -) +TOKEN_REFRESH_THRESHOLD_TIMEDELTA = timedelta(seconds=ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS) class Auth(abc.ABC): @@ -91,11 +89,7 @@ class Login(Auth): @property def token(self) -> str: - return ( - base64.b64encode(f"{self.login}:{self.password}".encode()) - .decode("utf-8") - .replace("\n", "") - ) + return base64.b64encode(f"{self.login}:{self.password}".encode()).decode("utf-8").replace("\n", "") class Token(Auth): @@ -192,9 +186,7 @@ class AppAuth(JWT): """ if expiration is not None: assert isinstance(expiration, int), expiration - assert ( - Consts.MIN_JWT_EXPIRY <= expiration <= Consts.MAX_JWT_EXPIRY - ), expiration + assert Consts.MIN_JWT_EXPIRY <= expiration <= Consts.MAX_JWT_EXPIRY, expiration now = int(time.time()) payload = { @@ -202,9 +194,7 @@ class AppAuth(JWT): "exp": now + (expiration if expiration is not None else self._jwt_expiry), "iss": self._app_id, } - encrypted = jwt.encode( - payload, key=self.private_key, algorithm=self._jwt_algorithm - ) + encrypted = jwt.encode(payload, key=self.private_key, algorithm=self._jwt_algorithm) if isinstance(encrypted, bytes): return encrypted.decode("utf-8") @@ -251,9 +241,7 @@ class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]): assert isinstance(app_auth, AppAuth), app_auth assert isinstance(installation_id, int), installation_id - assert token_permissions is None or isinstance( - token_permissions, dict - ), token_permissions + assert token_permissions is None or isinstance(token_permissions, dict), token_permissions self._app_auth = app_auth self._installation_id = installation_id @@ -303,16 +291,11 @@ class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]): @property def _is_expired(self) -> bool: assert self.__installation_authorization is not None - token_expires_at = ( - self.__installation_authorization.expires_at - - TOKEN_REFRESH_THRESHOLD_TIMEDELTA - ) + token_expires_at = self.__installation_authorization.expires_at - TOKEN_REFRESH_THRESHOLD_TIMEDELTA return token_expires_at < datetime.now(timezone.utc) def _get_installation_authorization(self) -> InstallationAuthorization: - assert ( - self.__integration is not None - ), "Method withRequester(Requester) must be called first" + assert self.__integration is not None, "Method withRequester(Requester) must be called first" return self.__integration.get_access_token( self._installation_id, permissions=self._token_permissions, @@ -413,22 +396,13 @@ class AppUserAuth(Auth, WithRequester["AppUserAuth"]): @property def _is_expired(self) -> bool: - return self._expires_at is not None and self._expires_at < datetime.now( - timezone.utc - ) + return self._expires_at is not None and self._expires_at < datetime.now(timezone.utc) def _refresh(self): if self._refresh_token is None: - raise RuntimeError( - "Cannot refresh expired token because no refresh token has been provided" - ) - if ( - self._refresh_expires_at is not None - and self._refresh_expires_at < datetime.now(timezone.utc) - ): - raise RuntimeError( - "Cannot refresh expired token because refresh token also expired" - ) + raise RuntimeError("Cannot refresh expired token because no refresh token has been provided") + if self._refresh_expires_at is not None and self._refresh_expires_at < datetime.now(timezone.utc): + raise RuntimeError("Cannot refresh expired token because refresh token also expired") # refresh token token = self.__app.refresh_access_token(self._refresh_token) diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index 4625c2f6..3140c0f4 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -383,9 +383,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert all(isinstance(element, str) for element in emails), emails post_parameters = {"emails": emails} - headers, data = self._requester.requestJsonAndCheck( - "POST", "/user/emails", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", "/user/emails", input=post_parameters) def add_to_following(self, following): """ @@ -394,9 +392,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(following, github.NamedUser.NamedUser), following - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"/user/following/{following._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/following/{following._identity}") def add_to_starred(self, starred): """ @@ -405,9 +401,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(starred, github.Repository.Repository), starred - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"/user/starred/{starred._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/starred/{starred._identity}") def add_to_subscriptions(self, subscription): """ @@ -416,9 +410,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(subscription, github.Repository.Repository), subscription - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"/user/subscriptions/{subscription._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/subscriptions/{subscription._identity}") def add_to_watched(self, watched): """ @@ -452,22 +444,12 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param onetime_password: string :rtype: :class:`github.Authorization.Authorization` """ - assert scopes is github.GithubObject.NotSet or all( - isinstance(element, str) for element in scopes - ), scopes + assert scopes is github.GithubObject.NotSet or all(isinstance(element, str) for element in scopes), scopes assert note is github.GithubObject.NotSet or isinstance(note, str), note - assert note_url is github.GithubObject.NotSet or isinstance( - note_url, str - ), note_url - assert client_id is github.GithubObject.NotSet or isinstance( - client_id, str - ), client_id - assert client_secret is github.GithubObject.NotSet or isinstance( - client_secret, str - ), client_secret - assert onetime_password is None or isinstance( - onetime_password, str - ), onetime_password + assert note_url is github.GithubObject.NotSet or isinstance(note_url, str), note_url + assert client_id is github.GithubObject.NotSet or isinstance(client_id, str), client_id + assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, str), client_secret + assert onetime_password is None or isinstance(onetime_password, str), onetime_password post_parameters = dict() if scopes is not github.GithubObject.NotSet: post_parameters["scopes"] = scopes @@ -480,9 +462,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): if client_secret is not github.GithubObject.NotSet: post_parameters["client_secret"] = client_secret if onetime_password is not None: - request_header = { - Consts.headerOTP: onetime_password - } # pragma no cover (Should be covered) + request_header = {Consts.headerOTP: onetime_password} # pragma no cover (Should be covered) else: request_header = None headers, data = self._requester.requestJsonAndCheck( @@ -491,9 +471,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): input=post_parameters, headers=request_header, ) - return github.Authorization.Authorization( - self._requester, headers, data, completed=True - ) + return github.Authorization.Authorization(self._requester, headers, data, completed=True) @staticmethod def create_fork( @@ -532,12 +510,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(repo, github.Repository.Repository), repo - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert private is github.GithubObject.NotSet or isinstance(private, bool), private post_parameters = { "name": name, "owner": self.login, @@ -552,9 +526,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": "application/vnd.github.v3+json"}, ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_gist(self, public, files, description=github.GithubObject.NotSet): """ @@ -565,21 +537,15 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Gist.Gist` """ assert isinstance(public, bool), public - assert all( - isinstance(element, github.InputFileContent) for element in files.values() - ), files - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert all(isinstance(element, github.InputFileContent) for element in files.values()), files + assert description is github.GithubObject.NotSet or isinstance(description, str), description post_parameters = { "public": public, "files": {key: value._identity for key, value in files.items()}, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description - headers, data = self._requester.requestJsonAndCheck( - "POST", "/gists", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", "/gists", input=post_parameters) return github.Gist.Gist(self._requester, headers, data, completed=True) def create_key(self, title, key): @@ -595,9 +561,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): "title": title, "key": key, } - headers, data = self._requester.requestJsonAndCheck( - "POST", "/user/keys", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", "/user/keys", input=post_parameters) return github.UserKey.UserKey(self._requester, headers, data, completed=True) def create_project(self, name, body=github.GithubObject.NotSet): @@ -659,33 +623,15 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert homepage is github.GithubObject.NotSet or isinstance( - homepage, str - ), homepage - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private - assert has_issues is github.GithubObject.NotSet or isinstance( - has_issues, bool - ), has_issues - assert has_wiki is github.GithubObject.NotSet or isinstance( - has_wiki, bool - ), has_wiki - assert has_downloads is github.GithubObject.NotSet or isinstance( - has_downloads, bool - ), has_downloads - assert has_projects is github.GithubObject.NotSet or isinstance( - has_projects, bool - ), has_projects - assert auto_init is github.GithubObject.NotSet or isinstance( - auto_init, bool - ), auto_init - assert license_template is github.GithubObject.NotSet or isinstance( - license_template, str - ), license_template + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, str), homepage + assert private is github.GithubObject.NotSet or isinstance(private, bool), private + assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues + assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki + assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads + assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects + assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init + assert license_template is github.GithubObject.NotSet or isinstance(license_template, str), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance( gitignore_template, str ), gitignore_template @@ -732,12 +678,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): post_parameters["allow_rebase_merge"] = allow_rebase_merge if delete_branch_on_merge is not github.GithubObject.NotSet: post_parameters["delete_branch_on_merge"] = delete_branch_on_merge - headers, data = self._requester.requestJsonAndCheck( - "POST", "/user/repos", input=post_parameters - ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", "/user/repos", input=post_parameters) + return github.Repository.Repository(self._requester, headers, data, completed=True) def edit( self, @@ -763,15 +705,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): assert name is github.GithubObject.NotSet or isinstance(name, str), name assert email is github.GithubObject.NotSet or isinstance(email, str), email assert blog is github.GithubObject.NotSet or isinstance(blog, str), blog - assert company is github.GithubObject.NotSet or isinstance( - company, str - ), company - assert location is github.GithubObject.NotSet or isinstance( - location, str - ), location - assert hireable is github.GithubObject.NotSet or isinstance( - hireable, bool - ), hireable + assert company is github.GithubObject.NotSet or isinstance(company, str), company + assert location is github.GithubObject.NotSet or isinstance(location, str), location + assert hireable is github.GithubObject.NotSet or isinstance(hireable, bool), hireable assert bio is github.GithubObject.NotSet or isinstance(bio, str), bio post_parameters = dict() if name is not github.GithubObject.NotSet: @@ -788,9 +724,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): post_parameters["hireable"] = hireable if bio is not github.GithubObject.NotSet: post_parameters["bio"] = bio - headers, data = self._requester.requestJsonAndCheck( - "PATCH", "/user", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", "/user", input=post_parameters) self._useAttributes(data) def get_authorization(self, id): @@ -800,12 +734,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Authorization.Authorization` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/authorizations/{id}" - ) - return github.Authorization.Authorization( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/authorizations/{id}") + return github.Authorization.Authorization(self._requester, headers, data, completed=True) def get_authorizations(self): """ @@ -830,27 +760,21 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ - return github.PaginatedList.PaginatedList( - github.Event.Event, self._requester, "/events", None - ) + return github.PaginatedList.PaginatedList(github.Event.Event, self._requester, "/events", None) def get_followers(self): """ :calls: `GET /user/followers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - return github.PaginatedList.PaginatedList( - github.NamedUser.NamedUser, self._requester, "/user/followers", None - ) + return github.PaginatedList.PaginatedList(github.NamedUser.NamedUser, self._requester, "/user/followers", None) def get_following(self): """ :calls: `GET /user/following `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - return github.PaginatedList.PaginatedList( - github.NamedUser.NamedUser, self._requester, "/user/following", None - ) + return github.PaginatedList.PaginatedList(github.NamedUser.NamedUser, self._requester, "/user/following", None) def get_gists(self, since=github.GithubObject.NotSet): """ @@ -862,9 +786,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") - return github.PaginatedList.PaginatedList( - github.Gist.Gist, self._requester, "/gists", url_parameters - ) + return github.PaginatedList.PaginatedList(github.Gist.Gist, self._requester, "/gists", url_parameters) def get_issues( self, @@ -892,9 +814,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -909,9 +829,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") - return github.PaginatedList.PaginatedList( - github.Issue.Issue, self._requester, "/issues", url_parameters - ) + return github.PaginatedList.PaginatedList(github.Issue.Issue, self._requester, "/issues", url_parameters) def get_user_issues( self, @@ -939,9 +857,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -956,9 +872,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") - return github.PaginatedList.PaginatedList( - github.Issue.Issue, self._requester, "/user/issues", url_parameters - ) + return github.PaginatedList.PaginatedList(github.Issue.Issue, self._requester, "/user/issues", url_parameters) def get_key(self, id): """ @@ -975,9 +889,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /user/keys `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.UserKey.UserKey` """ - return github.PaginatedList.PaginatedList( - github.UserKey.UserKey, self._requester, "/user/keys", None - ) + return github.PaginatedList.PaginatedList(github.UserKey.UserKey, self._requester, "/user/keys", None) def get_notification(self, id): """ @@ -986,12 +898,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert isinstance(id, str), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/notifications/threads/{id}" - ) - return github.Notification.Notification( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/notifications/threads/{id}") + return github.Notification.Notification(self._requester, headers, data, completed=True) def get_notifications( self, @@ -1010,13 +918,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert all is github.GithubObject.NotSet or isinstance(all, bool), all - assert participating is github.GithubObject.NotSet or isinstance( - participating, bool - ), participating + assert participating is github.GithubObject.NotSet or isinstance(participating, bool), participating assert since is github.GithubObject.NotSet or isinstance(since, datetime), since - assert before is github.GithubObject.NotSet or isinstance( - before, datetime - ), before + assert before is github.GithubObject.NotSet or isinstance(before, datetime), before params = dict() if all is not github.GithubObject.NotSet: @@ -1053,9 +957,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /user/orgs `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` """ - return github.PaginatedList.PaginatedList( - github.Organization.Organization, self._requester, "/user/orgs", None - ) + return github.PaginatedList.PaginatedList(github.Organization.Organization, self._requester, "/user/orgs", None) def get_repo(self, name): """ @@ -1064,12 +966,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/repos/{self.login}/{name}" - ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/repos/{self.login}/{name}") + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos( self, @@ -1088,17 +986,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert visibility is github.GithubObject.NotSet or isinstance( - visibility, str - ), visibility - assert affiliation is github.GithubObject.NotSet or isinstance( - affiliation, str - ), affiliation + assert visibility is github.GithubObject.NotSet or isinstance(visibility, str), visibility + assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, str), affiliation assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction url_parameters = dict() if visibility is not github.GithubObject.NotSet: url_parameters["visibility"] = visibility @@ -1119,18 +1011,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /user/starred `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - return github.PaginatedList.PaginatedList( - github.Repository.Repository, self._requester, "/user/starred", None - ) + return github.PaginatedList.PaginatedList(github.Repository.Repository, self._requester, "/user/starred", None) def get_starred_gists(self): """ :calls: `GET /gists/starred `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` """ - return github.PaginatedList.PaginatedList( - github.Gist.Gist, self._requester, "/gists/starred", None - ) + return github.PaginatedList.PaginatedList(github.Gist.Gist, self._requester, "/gists/starred", None) def get_subscriptions(self): """ @@ -1146,9 +1034,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /user/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ - return github.PaginatedList.PaginatedList( - github.Team.Team, self._requester, "/user/teams", None - ) + return github.PaginatedList.PaginatedList(github.Team.Team, self._requester, "/user/teams", None) def get_watched(self): """ @@ -1180,9 +1066,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(following, github.NamedUser.NamedUser), following - status, headers, data = self._requester.requestJson( - "GET", f"/user/following/{following._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"/user/following/{following._identity}") return status == 204 def has_in_starred(self, starred): @@ -1192,9 +1076,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(starred, github.Repository.Repository), starred - status, headers, data = self._requester.requestJson( - "GET", f"/user/starred/{starred._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"/user/starred/{starred._identity}") return status == 204 def has_in_subscriptions(self, subscription): @@ -1204,9 +1086,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(subscription, github.Repository.Repository), subscription - status, headers, data = self._requester.requestJson( - "GET", f"/user/subscriptions/{subscription._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"/user/subscriptions/{subscription._identity}") return status == 204 def has_in_watched(self, watched): @@ -1216,9 +1096,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(watched, github.Repository.Repository), watched - status, headers, data = self._requester.requestJson( - "GET", f"/repos/{watched._identity}/subscription" - ) + status, headers, data = self._requester.requestJson("GET", f"/repos/{watched._identity}/subscription") return status == 200 def mark_notifications_as_read(self, last_read_at=datetime.now(timezone.utc)): @@ -1229,9 +1107,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): assert isinstance(last_read_at, datetime) put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} - headers, data = self._requester.requestJsonAndCheck( - "PUT", "/notifications", input=put_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PUT", "/notifications", input=put_parameters) def remove_from_emails(self, *emails): """ @@ -1241,9 +1117,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert all(isinstance(element, str) for element in emails), emails post_parameters = {"emails": emails} - headers, data = self._requester.requestJsonAndCheck( - "DELETE", "/user/emails", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", "/user/emails", input=post_parameters) def remove_from_following(self, following): """ @@ -1252,9 +1126,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(following, github.NamedUser.NamedUser), following - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"/user/following/{following._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/following/{following._identity}") def remove_from_starred(self, starred): """ @@ -1263,9 +1135,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(starred, github.Repository.Repository), starred - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"/user/starred/{starred._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/starred/{starred._identity}") def remove_from_subscriptions(self, subscription): """ @@ -1274,9 +1144,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(subscription, github.Repository.Repository), subscription - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"/user/subscriptions/{subscription._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/subscriptions/{subscription._identity}") def remove_from_watched(self, watched): """ @@ -1285,9 +1153,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(watched, github.Repository.Repository), watched - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"/repos/{watched._identity}/subscription" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/repos/{watched._identity}/subscription") def accept_invitation(self, invitation): """ @@ -1295,9 +1161,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param invitation: :class:`github.Invitation.Invitation` or int :rtype: None """ - assert isinstance(invitation, github.Invitation.Invitation) or isinstance( - invitation, int - ) + assert isinstance(invitation, github.Invitation.Invitation) or isinstance(invitation, int) if isinstance(invitation, github.Invitation.Invitation): invitation = invitation.id @@ -1333,9 +1197,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ assert isinstance(repos, (list, tuple)), repos assert all(isinstance(repo, str) for repo in repos), repos - assert lock_repositories is github.GithubObject.NotSet or isinstance( - lock_repositories, bool - ), lock_repositories + assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance( exclude_attachments, bool ), exclude_attachments @@ -1350,9 +1212,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) - return github.Migration.Migration( - self._requester, headers, data, completed=True - ) + return github.Migration.Migration(self._requester, headers, data, completed=True) def get_migrations(self): """ @@ -1373,12 +1233,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Membership.Membership` """ assert isinstance(org, str) - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/user/memberships/orgs/{org}" - ) - return github.Membership.Membership( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/user/memberships/orgs/{org}") + return github.Membership.Membership(self._requester, headers, data, completed=True) def _initAttributes(self): self._avatar_url = github.GithubObject.NotSet @@ -1466,13 +1322,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "organizations_url" in attributes: # pragma no branch - self._organizations_url = self._makeStringAttribute( - attributes["organizations_url"] - ) + self._organizations_url = self._makeStringAttribute(attributes["organizations_url"]) if "owned_private_repos" in attributes: # pragma no branch - self._owned_private_repos = self._makeIntAttribute( - attributes["owned_private_repos"] - ) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch @@ -1482,9 +1334,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch - self._received_events_url = self._makeStringAttribute( - attributes["received_events_url"] - ) + self._received_events_url = self._makeStringAttribute(attributes["received_events_url"]) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "site_admin" in attributes: # pragma no branch @@ -1492,13 +1342,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): if "starred_url" in attributes: # pragma no branch self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch - self._subscriptions_url = self._makeStringAttribute( - attributes["subscriptions_url"] - ) + self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"]) if "total_private_repos" in attributes: # pragma no branch - self._total_private_repos = self._makeIntAttribute( - attributes["total_private_repos"] - ) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch @@ -1506,6 +1352,4 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "two_factor_authentication" in attributes: - self._two_factor_authentication = self._makeBoolAttribute( - attributes["two_factor_authentication"] - ) + self._two_factor_authentication = self._makeBoolAttribute(attributes["two_factor_authentication"]) diff --git a/github/AuthenticatedUser.pyi b/github/AuthenticatedUser.pyi index b753a465..c4355a94 100644 --- a/github/AuthenticatedUser.pyi +++ b/github/AuthenticatedUser.pyi @@ -123,9 +123,7 @@ class AuthenticatedUser(CompletableGithubObject): def get_events(self) -> PaginatedList[Event]: ... def get_followers(self) -> PaginatedList[NamedUser]: ... def get_following(self) -> PaginatedList[NamedUser]: ... - def get_gists( - self, since: Union[datetime, _NotSetType] = ... - ) -> PaginatedList[Gist]: ... + def get_gists(self, since: Union[datetime, _NotSetType] = ...) -> PaginatedList[Gist]: ... def get_invitations(self) -> PaginatedList[Invitation]: ... def get_issues( self, diff --git a/github/Authorization.py b/github/Authorization.py index 5fe99f86..f16590d4 100644 --- a/github/Authorization.py +++ b/github/Authorization.py @@ -127,9 +127,7 @@ class Authorization(github.GithubObject.CompletableGithubObject): :param note_url: string :rtype: None """ - assert isinstance(scopes, _NotSetType) or all( - isinstance(element, str) for element in scopes - ), scopes + assert isinstance(scopes, _NotSetType) or all(isinstance(element, str) for element in scopes), scopes assert isinstance(add_scopes, _NotSetType) or all( isinstance(element, str) for element in add_scopes ), add_scopes @@ -149,9 +147,7 @@ class Authorization(github.GithubObject.CompletableGithubObject): } ) - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def _initAttributes(self): diff --git a/github/Branch.py b/github/Branch.py index a3836199..51d5a147 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -92,15 +92,11 @@ class Branch(NonCompletableGithubObject): def _useAttributes(self, attributes) -> None: if "commit" in attributes: # pragma no branch - self._commit = self._makeClassAttribute( - github.Commit.Commit, attributes["commit"] - ) + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "protection_url" in attributes: # pragma no branch - self._protection_url = self._makeStringAttribute( - attributes["protection_url"] - ) + self._protection_url = self._makeStringAttribute(attributes["protection_url"]) if "protected" in attributes: # pragma no branch self._protected = self._makeBoolAttribute(attributes["protected"]) @@ -113,9 +109,7 @@ class Branch(NonCompletableGithubObject): self.protection_url, headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, ) - return github.BranchProtection.BranchProtection( - self._requester, headers, data, completed=True - ) + return github.BranchProtection.BranchProtection(self._requester, headers, data, completed=True) def edit_protection( self, @@ -156,25 +150,15 @@ class Branch(NonCompletableGithubObject): assert is_optional_list(dismissal_apps, str), dismissal_apps assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews - assert is_optional( - required_approving_review_count, int - ), required_approving_review_count + assert is_optional(required_approving_review_count, int), required_approving_review_count assert is_optional(required_linear_history, bool), required_linear_history assert is_optional(allow_force_pushes, bool), allow_force_pushes - assert is_optional( - required_linear_history, bool - ), required_conversation_resolution + assert is_optional(required_linear_history, bool), required_conversation_resolution assert is_optional(lock_branch, bool), lock_branch assert is_optional(allow_fork_syncing, bool), allow_fork_syncing - assert is_optional_list( - users_bypass_pull_request_allowances, str - ), users_bypass_pull_request_allowances - assert is_optional_list( - teams_bypass_pull_request_allowances, str - ), teams_bypass_pull_request_allowances - assert is_optional_list( - apps_bypass_pull_request_allowances, str - ), apps_bypass_pull_request_allowances + assert is_optional_list(users_bypass_pull_request_allowances, str), users_bypass_pull_request_allowances + assert is_optional_list(teams_bypass_pull_request_allowances, str), teams_bypass_pull_request_allowances + assert is_optional_list(apps_bypass_pull_request_allowances, str), apps_bypass_pull_request_allowances post_parameters: dict[str, Any] = {} if is_defined(strict) or is_defined(contexts): @@ -207,9 +191,7 @@ class Branch(NonCompletableGithubObject): ): post_parameters["required_pull_request_reviews"] = {} if is_defined(dismiss_stale_reviews): - post_parameters["required_pull_request_reviews"][ - "dismiss_stale_reviews" - ] = dismiss_stale_reviews + post_parameters["required_pull_request_reviews"]["dismiss_stale_reviews"] = dismiss_stale_reviews if is_defined(require_code_owner_reviews): post_parameters["required_pull_request_reviews"][ "require_code_owner_reviews" @@ -228,23 +210,15 @@ class Branch(NonCompletableGithubObject): dismissal_restrictions["apps"] = dismissal_apps if dismissal_restrictions: - post_parameters["required_pull_request_reviews"][ - "dismissal_restrictions" - ] = dismissal_restrictions + post_parameters["required_pull_request_reviews"]["dismissal_restrictions"] = dismissal_restrictions bypass_pull_request_allowances = {} if is_defined(users_bypass_pull_request_allowances): - bypass_pull_request_allowances[ - "users" - ] = users_bypass_pull_request_allowances + bypass_pull_request_allowances["users"] = users_bypass_pull_request_allowances if is_defined(teams_bypass_pull_request_allowances): - bypass_pull_request_allowances[ - "teams" - ] = teams_bypass_pull_request_allowances + bypass_pull_request_allowances["teams"] = teams_bypass_pull_request_allowances if is_defined(apps_bypass_pull_request_allowances): - bypass_pull_request_allowances[ - "apps" - ] = apps_bypass_pull_request_allowances + bypass_pull_request_allowances["apps"] = apps_bypass_pull_request_allowances if bypass_pull_request_allowances: post_parameters["required_pull_request_reviews"][ @@ -279,9 +253,7 @@ class Branch(NonCompletableGithubObject): else: post_parameters["allow_force_pushes"] = None if is_defined(required_conversation_resolution): - post_parameters[ - "required_conversation_resolution" - ] = required_conversation_resolution + post_parameters["required_conversation_resolution"] = required_conversation_resolution else: post_parameters["required_conversation_resolution"] = None if is_defined(lock_branch): @@ -318,12 +290,8 @@ class Branch(NonCompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ :rtype: :class:`github.RequiredStatusChecks.RequiredStatusChecks` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.protection_url}/required_status_checks" - ) - return github.RequiredStatusChecks.RequiredStatusChecks( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/required_status_checks") + return github.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True) def edit_required_status_checks( self, @@ -336,9 +304,7 @@ class Branch(NonCompletableGithubObject): assert is_optional(strict, bool), strict assert is_optional_list(contexts, str), contexts - post_parameters: dict[str, Any] = NotSet.remove_unset_items( - {"strict": strict, "contexts": contexts} - ) + post_parameters: dict[str, Any] = NotSet.remove_unset_items({"strict": strict, "contexts": contexts}) headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.protection_url}/required_status_checks", @@ -383,9 +349,7 @@ class Branch(NonCompletableGithubObject): assert is_optional_list(dismissal_teams, str), dismissal_teams assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews - assert is_optional( - required_approving_review_count, int - ), required_approving_review_count + assert is_optional(required_approving_review_count, int), required_approving_review_count post_parameters: dict[str, Any] = NotSet.remove_unset_items( { @@ -422,26 +386,20 @@ class Branch(NonCompletableGithubObject): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.protection_url}/enforce_admins" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/enforce_admins") return data["enabled"] def set_admin_enforcement(self) -> None: """ :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ """ - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.protection_url}/enforce_admins" - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.protection_url}/enforce_admins") def remove_admin_enforcement(self) -> None: """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.protection_url}/enforce_admins" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/enforce_admins") def get_user_push_restrictions(self) -> PaginatedList[NamedUser]: """ @@ -535,9 +493,7 @@ class Branch(NonCompletableGithubObject): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions `_ """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.protection_url}/restrictions" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/restrictions") def get_required_signatures(self) -> bool: """ diff --git a/github/BranchProtection.py b/github/BranchProtection.py index 6aeabdc2..c871ac02 100644 --- a/github/BranchProtection.py +++ b/github/BranchProtection.py @@ -51,9 +51,7 @@ class BranchProtection(github.GithubObject.CompletableGithubObject): self._url: Attribute[str] = NotSet self._required_status_checks: Attribute[RequiredStatusChecks] = NotSet self._enforce_admins: Attribute[bool] = NotSet - self._required_pull_request_reviews: Attribute[ - RequiredPullRequestReviews - ] = NotSet + self._required_pull_request_reviews: Attribute[RequiredPullRequestReviews] = NotSet self._user_push_restrictions: Opt[str] = NotSet self._team_push_restrictions: Opt[str] = NotSet @@ -90,9 +88,7 @@ class BranchProtection(github.GithubObject.CompletableGithubObject): def get_team_push_restrictions(self) -> PaginatedList[Team] | None: if not is_defined(self._team_push_restrictions): return None - return github.PaginatedList.PaginatedList( - github.Team.Team, self._requester, self._team_push_restrictions, None - ) + return github.PaginatedList.PaginatedList(github.Team.Team, self._requester, self._team_push_restrictions, None) def _useAttributes(self, attributes: dict[str, Any]) -> None: if "url" in attributes: # pragma no branch @@ -103,9 +99,7 @@ class BranchProtection(github.GithubObject.CompletableGithubObject): attributes["required_status_checks"], ) if "enforce_admins" in attributes: # pragma no branch - self._enforce_admins = self._makeBoolAttribute( - attributes["enforce_admins"]["enabled"] - ) + self._enforce_admins = self._makeBoolAttribute(attributes["enforce_admins"]["enabled"]) if "required_pull_request_reviews" in attributes: # pragma no branch self._required_pull_request_reviews = self._makeClassAttribute( github.RequiredPullRequestReviews.RequiredPullRequestReviews, diff --git a/github/CheckRun.py b/github/CheckRun.py index 0091f293..87c49449 100644 --- a/github/CheckRun.py +++ b/github/CheckRun.py @@ -37,9 +37,7 @@ class CheckRun(github.GithubObject.CompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"id": self._id.value, "conclusion": self._conclusion.value} - ) + return self.get__repr__({"id": self._id.value, "conclusion": self._conclusion.value}) @property def app(self): @@ -210,29 +208,15 @@ class CheckRun(github.GithubObject.CompletableGithubObject): :rtype: None """ assert name is github.GithubObject.NotSet or isinstance(name, str), name - assert head_sha is github.GithubObject.NotSet or isinstance( - head_sha, str - ), head_sha - assert details_url is github.GithubObject.NotSet or isinstance( - details_url, str - ), details_url - assert external_id is github.GithubObject.NotSet or isinstance( - external_id, str - ), external_id + assert head_sha is github.GithubObject.NotSet or isinstance(head_sha, str), head_sha + assert details_url is github.GithubObject.NotSet or isinstance(details_url, str), details_url + assert external_id is github.GithubObject.NotSet or isinstance(external_id, str), external_id assert status is github.GithubObject.NotSet or isinstance(status, str), status - assert started_at is github.GithubObject.NotSet or isinstance( - started_at, datetime - ), started_at - assert conclusion is github.GithubObject.NotSet or isinstance( - conclusion, str - ), conclusion - assert completed_at is github.GithubObject.NotSet or isinstance( - completed_at, datetime - ), completed_at + assert started_at is github.GithubObject.NotSet or isinstance(started_at, datetime), started_at + assert conclusion is github.GithubObject.NotSet or isinstance(conclusion, str), conclusion + assert completed_at is github.GithubObject.NotSet or isinstance(completed_at, datetime), completed_at assert output is github.GithubObject.NotSet or isinstance(output, dict), output - assert actions is github.GithubObject.NotSet or all( - isinstance(element, dict) for element in actions - ), actions + assert actions is github.GithubObject.NotSet or all(isinstance(element, dict) for element in actions), actions post_parameters = dict() if name is not github.GithubObject.NotSet: @@ -248,9 +232,7 @@ class CheckRun(github.GithubObject.CompletableGithubObject): if started_at is not github.GithubObject.NotSet: post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") if completed_at is not github.GithubObject.NotSet: - post_parameters["completed_at"] = completed_at.strftime( - "%Y-%m-%dT%H:%M:%SZ" - ) + post_parameters["completed_at"] = completed_at.strftime("%Y-%m-%dT%H:%M:%SZ") if conclusion is not github.GithubObject.NotSet: post_parameters["conclusion"] = conclusion if output is not github.GithubObject.NotSet: @@ -258,9 +240,7 @@ class CheckRun(github.GithubObject.CompletableGithubObject): if actions is not github.GithubObject.NotSet: post_parameters["actions"] = actions - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def _initAttributes(self): @@ -283,16 +263,10 @@ class CheckRun(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "app" in attributes: # pragma no branch - self._app = self._makeClassAttribute( - github.GithubApp.GithubApp, attributes["app"] - ) + self._app = self._makeClassAttribute(github.GithubApp.GithubApp, attributes["app"]) # This only gives us a dictionary with `id` attribute of `check_suite` - if ( - "check_suite" in attributes and "id" in attributes["check_suite"] - ): # pragma no branch - self._check_suite_id = self._makeIntAttribute( - attributes["check_suite"]["id"] - ) + if "check_suite" in attributes and "id" in attributes["check_suite"]: # pragma no branch + self._check_suite_id = self._makeIntAttribute(attributes["check_suite"]["id"]) if "completed_at" in attributes: # pragma no branch self._completed_at = self._makeDatetimeAttribute(attributes["completed_at"]) if "conclusion" in attributes: # pragma no branch @@ -312,9 +286,7 @@ class CheckRun(github.GithubObject.CompletableGithubObject): if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "output" in attributes: # pragma no branch - self._output = self._makeClassAttribute( - github.CheckRunOutput.CheckRunOutput, attributes["output"] - ) + self._output = self._makeClassAttribute(github.CheckRunOutput.CheckRunOutput, attributes["output"]) if "pull_requests" in attributes: # pragma no branch self._pull_requests = self._makeListOfClassesAttribute( github.PullRequest.PullRequest, attributes["pull_requests"] diff --git a/github/CheckRun.pyi b/github/CheckRun.pyi index 10cfda8d..8e1f2ef6 100644 --- a/github/CheckRun.pyi +++ b/github/CheckRun.pyi @@ -23,9 +23,7 @@ class CheckRun(CompletableGithubObject): started_at: Union[_NotSetType, datetime] = ..., conclusion: Union[_NotSetType, str] = ..., completed_at: Union[_NotSetType, datetime] = ..., - output: Union[ - _NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]] - ] = ..., + output: Union[_NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]]] = ..., actions: Union[_NotSetType, List[Dict[str, str]]] = ..., ) -> None: ... @property diff --git a/github/CheckRunAnnotation.py b/github/CheckRunAnnotation.py index 07391f98..4088201e 100644 --- a/github/CheckRunAnnotation.py +++ b/github/CheckRunAnnotation.py @@ -81,9 +81,7 @@ class CheckRunAnnotation(NonCompletableGithubObject): def _useAttributes(self, attributes) -> None: if "annotation_level" in attributes: # pragma no branch - self._annotation_level = self._makeStringAttribute( - attributes["annotation_level"] - ) + self._annotation_level = self._makeStringAttribute(attributes["annotation_level"]) if "end_column" in attributes: # pragma no branch self._end_column = self._makeIntAttribute(attributes["end_column"]) if "end_line" in attributes: # pragma no branch diff --git a/github/CheckRunOutput.py b/github/CheckRunOutput.py index 33a96587..0fe88401 100644 --- a/github/CheckRunOutput.py +++ b/github/CheckRunOutput.py @@ -58,13 +58,9 @@ class CheckRunOutput(NonCompletableGithubObject): def _useAttributes(self, attributes) -> None: if "annotations_count" in attributes: # pragma no branch - self._annotations_count = self._makeIntAttribute( - attributes["annotations_count"] - ) + self._annotations_count = self._makeIntAttribute(attributes["annotations_count"]) if "annotations_url" in attributes: # pragma no branch - self._annotations_url = self._makeStringAttribute( - attributes["annotations_url"] - ) + self._annotations_url = self._makeStringAttribute(attributes["annotations_url"]) if "summary" in attributes: # pragma no branch self._summary = self._makeStringAttribute(attributes["summary"]) if "text" in attributes: # pragma no branch diff --git a/github/CheckSuite.py b/github/CheckSuite.py index a244d1f8..a6c89eba 100644 --- a/github/CheckSuite.py +++ b/github/CheckSuite.py @@ -165,9 +165,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject): :rtype: bool """ request_headers = {"Accept": "application/vnd.github.v3+json"} - status, _, _ = self._requester.requestJson( - "POST", f"{self.url}/rerequest", headers=request_headers - ) + status, _, _ = self._requester.requestJson("POST", f"{self.url}/rerequest", headers=request_headers) return status == 201 def get_check_runs( @@ -183,9 +181,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject): :param filter: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRun.CheckRun` """ - assert check_name is github.GithubObject.NotSet or isinstance( - check_name, str - ), check_name + assert check_name is github.GithubObject.NotSet or isinstance(check_name, str), check_name assert status is github.GithubObject.NotSet or isinstance(status, str), status assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter url_parameters = dict() @@ -226,15 +222,11 @@ class CheckSuite(github.GithubObject.CompletableGithubObject): if "after" in attributes: # pragma no branch self._after = self._makeStringAttribute(attributes["after"]) if "app" in attributes: # pragma no branch - self._app = self._makeClassAttribute( - github.GithubApp.GithubApp, attributes["app"] - ) + self._app = self._makeClassAttribute(github.GithubApp.GithubApp, attributes["app"]) if "before" in attributes: # pragma no branch self._before = self._makeStringAttribute(attributes["before"]) if "check_runs_url" in attributes: # pragma no branch - self._check_runs_url = self._makeStringAttribute( - attributes["check_runs_url"] - ) + self._check_runs_url = self._makeStringAttribute(attributes["check_runs_url"]) if "conclusion" in attributes: # pragma no branch self._conclusion = self._makeStringAttribute(attributes["conclusion"]) if "created_at" in attributes: # pragma no branch @@ -246,25 +238,19 @@ class CheckSuite(github.GithubObject.CompletableGithubObject): # The GitCommit object only looks for 'sha' if "id" in attributes["head_commit"]: attributes["head_commit"]["sha"] = attributes["head_commit"]["id"] - self._head_commit = self._makeClassAttribute( - github.GitCommit.GitCommit, attributes["head_commit"] - ) + self._head_commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["head_commit"]) if "head_sha" in attributes: # pragma no branch self._head_sha = self._makeStringAttribute(attributes["head_sha"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "latest_check_runs_count" in attributes: # pragma no branch - self._latest_check_runs_count = self._makeIntAttribute( - attributes["latest_check_runs_count"] - ) + self._latest_check_runs_count = self._makeIntAttribute(attributes["latest_check_runs_count"]) if "pull_requests" in attributes: # pragma no branch self._pull_requests = self._makeListOfClassesAttribute( github.PullRequest.PullRequest, attributes["pull_requests"] ) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "updated_at" in attributes: # pragma no branch diff --git a/github/CheckSuite.pyi b/github/CheckSuite.pyi index dd84c396..a55445cd 100644 --- a/github/CheckSuite.pyi +++ b/github/CheckSuite.pyi @@ -46,6 +46,4 @@ class CheckSuite(CompletableGithubObject): @property def url(self) -> str: ... def rerequest(self) -> bool: ... - def get_check_runs( - self, check_name: str, status: str, filter: str - ) -> PaginatedList[CheckRun]: ... + def get_check_runs(self, check_name: str, status: str, filter: str) -> PaginatedList[CheckRun]: ... diff --git a/github/CodeScanAlert.py b/github/CodeScanAlert.py index da386336..214f897c 100644 --- a/github/CodeScanAlert.py +++ b/github/CodeScanAlert.py @@ -154,26 +154,18 @@ class CodeScanAlert(github.GithubObject.NonCompletableGithubObject): if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "rule" in attributes: # pragma no branch - self._rule = self._makeClassAttribute( - github.CodeScanRule.CodeScanRule, attributes["rule"] - ) + self._rule = self._makeClassAttribute(github.CodeScanRule.CodeScanRule, attributes["rule"]) if "tool" in attributes: # pragma no branch - self._tool = self._makeClassAttribute( - github.CodeScanTool.CodeScanTool, attributes["tool"] - ) + self._tool = self._makeClassAttribute(github.CodeScanTool.CodeScanTool, attributes["tool"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "dismissed_at" in attributes: # pragma no branch self._dismissed_at = self._makeDatetimeAttribute(attributes["dismissed_at"]) if "dismissed_by" in attributes: # pragma no branch - self._dismissed_by = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["dismissed_by"] - ) + self._dismissed_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["dismissed_by"]) if "dismissed_reason" in attributes: # pragma no branch - self._dismissed_reason = self._makeStringAttribute( - attributes["dismissed_reason"] - ) + self._dismissed_reason = self._makeStringAttribute(attributes["dismissed_reason"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/CodeScanAlertInstance.py b/github/CodeScanAlertInstance.py index 62ce5224..b48d7f53 100644 --- a/github/CodeScanAlertInstance.py +++ b/github/CodeScanAlertInstance.py @@ -120,6 +120,4 @@ class CodeScanAlertInstance(github.GithubObject.NonCompletableGithubObject): attributes["location"], ) if "classifications" in attributes: # pragma no branch - self._classifications = self._makeListOfStringsAttribute( - attributes["classifications"] - ) + self._classifications = self._makeListOfStringsAttribute(attributes["classifications"]) diff --git a/github/CodeScanRule.py b/github/CodeScanRule.py index 9f7e3412..60e2c746 100644 --- a/github/CodeScanRule.py +++ b/github/CodeScanRule.py @@ -82,8 +82,6 @@ class CodeScanRule(github.GithubObject.NonCompletableGithubObject): if "severity" in attributes: # pragma no branch self._severity = self._makeStringAttribute(attributes["severity"]) if "security_severity_level" in attributes: # pragma no branch - self._security_severity_level = self._makeStringAttribute( - attributes["security_severity_level"] - ) + self._security_severity_level = self._makeStringAttribute(attributes["security_severity_level"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) diff --git a/github/Commit.py b/github/Commit.py index 2b625f6b..22384fd8 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -149,9 +149,7 @@ class Commit(github.GithubObject.CompletableGithubObject): assert isinstance(body, str), body assert line is github.GithubObject.NotSet or isinstance(line, int), line assert path is github.GithubObject.NotSet or isinstance(path, str), path - assert position is github.GithubObject.NotSet or isinstance( - position, int - ), position + assert position is github.GithubObject.NotSet or isinstance(position, int), position post_parameters = { "body": body, } @@ -161,12 +159,8 @@ class Commit(github.GithubObject.CompletableGithubObject): post_parameters["path"] = path if position is not github.GithubObject.NotSet: post_parameters["position"] = position - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/comments", input=post_parameters - ) - return github.CommitComment.CommitComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/comments", input=post_parameters) + return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) def create_status( self, @@ -184,15 +178,9 @@ class Commit(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.CommitStatus.CommitStatus` """ assert isinstance(state, str), state - assert target_url is github.GithubObject.NotSet or isinstance( - target_url, str - ), target_url - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert context is github.GithubObject.NotSet or isinstance( - context, str - ), context + assert target_url is github.GithubObject.NotSet or isinstance(target_url, str), target_url + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert context is github.GithubObject.NotSet or isinstance(context, str), context post_parameters = { "state": state, } @@ -207,9 +195,7 @@ class Commit(github.GithubObject.CompletableGithubObject): f"{self._parentUrl(self._parentUrl(self.url))}/statuses/{self.sha}", input=post_parameters, ) - return github.CommitStatus.CommitStatus( - self._requester, headers, data, completed=True - ) + return github.CommitStatus.CommitStatus(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -241,9 +227,7 @@ class Commit(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.CommitCombinedStatus.CommitCombinedStatus` """ headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/status") - return github.CommitCombinedStatus.CommitCombinedStatus( - self._requester, headers, data, completed=True - ) + return github.CommitCombinedStatus.CommitCombinedStatus(self._requester, headers, data, completed=True) def get_pulls(self): """ @@ -271,9 +255,7 @@ class Commit(github.GithubObject.CompletableGithubObject): :param filter: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRun.CheckRun` """ - assert check_name is github.GithubObject.NotSet or isinstance( - check_name, str - ), check_name + assert check_name is github.GithubObject.NotSet or isinstance(check_name, str), check_name assert status is github.GithubObject.NotSet or isinstance(status, str), status assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter url_parameters = dict() @@ -292,9 +274,7 @@ class Commit(github.GithubObject.CompletableGithubObject): list_item="check_runs", ) - def get_check_suites( - self, app_id=github.GithubObject.NotSet, check_name=github.GithubObject.NotSet - ): + def get_check_suites(self, app_id=github.GithubObject.NotSet, check_name=github.GithubObject.NotSet): """ :class: `GET /repos/{owner}/{repo}/commits/{ref}/check-suites `_ :param app_id: int @@ -302,9 +282,7 @@ class Commit(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckSuite.CheckSuite` """ assert app_id is github.GithubObject.NotSet or isinstance(app_id, int), app_id - assert check_name is github.GithubObject.NotSet or isinstance( - check_name, str - ), check_name + assert check_name is github.GithubObject.NotSet or isinstance(check_name, str), check_name parameters = dict() if app_id is not github.GithubObject.NotSet: parameters["app_id"] = app_id @@ -338,34 +316,22 @@ class Commit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - self._author = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["author"] - ) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commit" in attributes: # pragma no branch - self._commit = self._makeClassAttribute( - github.GitCommit.GitCommit, attributes["commit"] - ) + self._commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["commit"]) if "committer" in attributes: # pragma no branch - self._committer = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["committer"] - ) + self._committer = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["committer"]) if "files" in attributes: # pragma no branch - self._files = self._makeListOfClassesAttribute( - github.File.File, attributes["files"] - ) + self._files = self._makeListOfClassesAttribute(github.File.File, attributes["files"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "parents" in attributes: # pragma no branch - self._parents = self._makeListOfClassesAttribute( - Commit, attributes["parents"] - ) + self._parents = self._makeListOfClassesAttribute(Commit, attributes["parents"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "stats" in attributes: # pragma no branch - self._stats = self._makeClassAttribute( - github.CommitStats.CommitStats, attributes["stats"] - ) + self._stats = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["stats"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/CommitCombinedStatus.py b/github/CommitCombinedStatus.py index 63259615..3cfee8b4 100644 --- a/github/CommitCombinedStatus.py +++ b/github/CommitCombinedStatus.py @@ -107,10 +107,6 @@ class CommitCombinedStatus(github.GithubObject.NonCompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "statuses" in attributes: # pragma no branch - self._statuses = self._makeListOfClassesAttribute( - github.CommitStatus.CommitStatus, attributes["statuses"] - ) + self._statuses = self._makeListOfClassesAttribute(github.CommitStatus.CommitStatus, attributes["statuses"]) diff --git a/github/CommitComment.py b/github/CommitComment.py index f762ecf0..a9bf0388 100644 --- a/github/CommitComment.py +++ b/github/CommitComment.py @@ -150,9 +150,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_reactions(self): @@ -238,6 +236,4 @@ class CommitComment(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/CommitStatus.py b/github/CommitStatus.py index 40338d34..b56b46d5 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -126,9 +126,7 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "id" in attributes: # pragma no branch diff --git a/github/Comparison.py b/github/Comparison.py index f058b7e3..0a58a289 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -160,27 +160,19 @@ class Comparison(github.GithubObject.CompletableGithubObject): if "ahead_by" in attributes: # pragma no branch self._ahead_by = self._makeIntAttribute(attributes["ahead_by"]) if "base_commit" in attributes: # pragma no branch - self._base_commit = self._makeClassAttribute( - github.Commit.Commit, attributes["base_commit"] - ) + self._base_commit = self._makeClassAttribute(github.Commit.Commit, attributes["base_commit"]) if "behind_by" in attributes: # pragma no branch self._behind_by = self._makeIntAttribute(attributes["behind_by"]) if "commits" in attributes: # pragma no branch - self._commits = self._makeListOfClassesAttribute( - github.Commit.Commit, attributes["commits"] - ) + self._commits = self._makeListOfClassesAttribute(github.Commit.Commit, attributes["commits"]) if "diff_url" in attributes: # pragma no branch self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "files" in attributes: # pragma no branch - self._files = self._makeListOfClassesAttribute( - github.File.File, attributes["files"] - ) + self._files = self._makeListOfClassesAttribute(github.File.File, attributes["files"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "merge_base_commit" in attributes: # pragma no branch - self._merge_base_commit = self._makeClassAttribute( - github.Commit.Commit, attributes["merge_base_commit"] - ) + self._merge_base_commit = self._makeClassAttribute(github.Commit.Commit, attributes["merge_base_commit"]) if "patch_url" in attributes: # pragma no branch self._patch_url = self._makeStringAttribute(attributes["patch_url"]) if "permalink_url" in attributes: # pragma no branch diff --git a/github/Consts.py b/github/Consts.py index 7433da53..ca888b2a 100644 --- a/github/Consts.py +++ b/github/Consts.py @@ -92,9 +92,7 @@ mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview mediaTypeTeamDiscussionsPreview = "application/vnd.github.echo-preview+json" # https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/ -mediaTypeRequireMultipleApprovingReviews = ( - "application/vnd.github.luke-cage-preview+json" -) +mediaTypeRequireMultipleApprovingReviews = "application/vnd.github.luke-cage-preview+json" # https://developer.github.com/changes/2018-05-24-user-migration-api/ mediaTypeMigrationPreview = "application/vnd.github.wyandotte-preview+json" diff --git a/github/ContentFile.py b/github/ContentFile.py index 007f17fb..acd25d47 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -122,13 +122,9 @@ class ContentFile(github.GithubObject.CompletableGithubObject): """ if self._repository is github.GithubObject.NotSet: # The repository was not set automatically, so it must be looked up by url. - repo_url = "/".join( - self.url.split("/")[:6] - ) # pragma no cover (Should be covered) + repo_url = "/".join(self.url.split("/")[:6]) # pragma no cover (Should be covered) self._repository = github.GithubObject._ValuedAttribute( - github.Repository.Repository( - self._requester, self._headers, {"url": repo_url}, completed=False - ) + github.Repository.Repository(self._requester, self._headers, {"url": repo_url}, completed=False) ) # pragma no cover (Should be covered) return self._repository.value @@ -199,17 +195,13 @@ class ContentFile(github.GithubObject.CompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "license" in attributes: # pragma no branch - self._license = self._makeClassAttribute( - github.License.License, attributes["license"] - ) + self._license = self._makeClassAttribute(github.License.License, attributes["license"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch @@ -219,6 +211,4 @@ class ContentFile(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "text_matches" in attributes: # pragma no branch - self._text_matches = self._makeListOfDictsAttribute( - attributes["text_matches"] - ) + self._text_matches = self._makeListOfDictsAttribute(attributes["text_matches"]) diff --git a/github/Deployment.py b/github/Deployment.py index 2c658e76..6bc430b9 100644 --- a/github/Deployment.py +++ b/github/Deployment.py @@ -188,9 +188,7 @@ class Deployment(github.GithubObject.CompletableGithubObject): f"{self.url}/statuses/{id_}", headers={"Accept": self._get_accept_header()}, ) - return github.DeploymentStatus.DeploymentStatus( - self._requester, headers, data, completed=True - ) + return github.DeploymentStatus.DeploymentStatus(self._requester, headers, data, completed=True) def create_status( self, @@ -212,21 +210,11 @@ class Deployment(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.DeploymentStatus.DeploymentStatus` """ assert isinstance(state, str), state - assert target_url is github.GithubObject.NotSet or isinstance( - target_url, str - ), target_url - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert environment is github.GithubObject.NotSet or isinstance( - environment, str - ), environment - assert environment_url is github.GithubObject.NotSet or isinstance( - environment_url, str - ), environment_url - assert auto_inactive is github.GithubObject.NotSet or isinstance( - auto_inactive, bool - ), auto_inactive + assert target_url is github.GithubObject.NotSet or isinstance(target_url, str), target_url + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert environment is github.GithubObject.NotSet or isinstance(environment, str), environment + assert environment_url is github.GithubObject.NotSet or isinstance(environment_url, str), environment_url + assert auto_inactive is github.GithubObject.NotSet or isinstance(auto_inactive, bool), auto_inactive post_parameters = {"state": state} if target_url is not github.GithubObject.NotSet: @@ -246,9 +234,7 @@ class Deployment(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": self._get_accept_header()}, ) - return github.DeploymentStatus.DeploymentStatus( - self._requester, headers, data, completed=True - ) + return github.DeploymentStatus.DeploymentStatus(self._requester, headers, data, completed=True) @staticmethod def _get_accept_header(): @@ -281,15 +267,11 @@ class Deployment(github.GithubObject.CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "production_environment" in attributes: # pragma no branch - self._production_environment = self._makeBoolAttribute( - attributes["production_environment"] - ) + self._production_environment = self._makeBoolAttribute(attributes["production_environment"]) if "ref" in attributes: # pragma no branch self._ref = self._makeStringAttribute(attributes["ref"]) if "transient_environment" in attributes: # pragma no branch - self._transient_environment = self._makeBoolAttribute( - attributes["transient_environment"] - ) + self._transient_environment = self._makeBoolAttribute(attributes["transient_environment"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "sha" in attributes: # pragma no branch @@ -299,17 +281,13 @@ class Deployment(github.GithubObject.CompletableGithubObject): if "payload" in attributes: # pragma no branch self._payload = self._makeDictAttribute(attributes["payload"]) if "original_environment" in attributes: # pragma no branch - self._original_environment = self._makeStringAttribute( - attributes["original_environment"] - ) + self._original_environment = self._makeStringAttribute(attributes["original_environment"]) if "environment" in attributes: # pragma no branch self._environment = self._makeStringAttribute(attributes["environment"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch @@ -317,6 +295,4 @@ class Deployment(github.GithubObject.CompletableGithubObject): if "statuses_url" in attributes: # pragma no branch self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) if "repository_url" in attributes: # pragma no branch - self._repository_url = self._makeStringAttribute( - attributes["repository_url"] - ) + self._repository_url = self._makeStringAttribute(attributes["repository_url"]) diff --git a/github/DeploymentStatus.py b/github/DeploymentStatus.py index 3e49fc29..5ecb8e3f 100644 --- a/github/DeploymentStatus.py +++ b/github/DeploymentStatus.py @@ -153,9 +153,7 @@ class DeploymentStatus(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "environment_url" in attributes: # pragma no branch - self._environment_url = self._makeStringAttribute( - attributes["environment_url"] - ) + self._environment_url = self._makeStringAttribute(attributes["environment_url"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "id" in attributes: # pragma no branch @@ -165,21 +163,15 @@ class DeploymentStatus(github.GithubObject.CompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "deployment_url" in attributes: # pragma no branch - self._deployment_url = self._makeStringAttribute( - attributes["deployment_url"] - ) + self._deployment_url = self._makeStringAttribute(attributes["deployment_url"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "environment" in attributes: # pragma no branch self._environment = self._makeStringAttribute(attributes["environment"]) if "repository_url" in attributes: # pragma no branch - self._repository_url = self._makeStringAttribute( - attributes["repository_url"] - ) + self._repository_url = self._makeStringAttribute(attributes["repository_url"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "target_url" in attributes: # pragma no branch diff --git a/github/EnvironmentDeploymentBranchPolicy.py b/github/EnvironmentDeploymentBranchPolicy.py index 51c1c0e8..cd55ff79 100644 --- a/github/EnvironmentDeploymentBranchPolicy.py +++ b/github/EnvironmentDeploymentBranchPolicy.py @@ -46,13 +46,9 @@ class EnvironmentDeploymentBranchPolicy(github.GithubObject.NonCompletableGithub def _useAttributes(self, attributes): if "protected_branches" in attributes: # pragma no branch - self._protected_branches = self._makeBoolAttribute( - attributes["protected_branches"] - ) + self._protected_branches = self._makeBoolAttribute(attributes["protected_branches"]) if "custom_branch_policies" in attributes: # pragma no branch - self._custom_branch_policies = self._makeBoolAttribute( - attributes["custom_branch_policies"] - ) + self._custom_branch_policies = self._makeBoolAttribute(attributes["custom_branch_policies"]) class EnvironmentDeploymentBranchPolicyParams: @@ -60,9 +56,7 @@ class EnvironmentDeploymentBranchPolicyParams: This class presents the deployment branch policy parameters as can be configured for an Environment. """ - def __init__( - self, protected_branches: bool = False, custom_branch_policies: bool = False - ): + def __init__(self, protected_branches: bool = False, custom_branch_policies: bool = False): assert isinstance(protected_branches, bool) assert isinstance(custom_branch_policies, bool) self.protected_branches = protected_branches diff --git a/github/EnvironmentProtectionRule.py b/github/EnvironmentProtectionRule.py index 6f1ee5e6..ce7271bc 100644 --- a/github/EnvironmentProtectionRule.py +++ b/github/EnvironmentProtectionRule.py @@ -49,9 +49,7 @@ class EnvironmentProtectionRule(github.GithubObject.NonCompletableGithubObject): @property def reviewers( self, - ) -> List[ - github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer - ]: + ) -> List[github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer]: return self._reviewers.value @property diff --git a/github/EnvironmentProtectionRuleReviewer.py b/github/EnvironmentProtectionRuleReviewer.py index 9ddfb3c6..690dbd20 100644 --- a/github/EnvironmentProtectionRuleReviewer.py +++ b/github/EnvironmentProtectionRuleReviewer.py @@ -53,13 +53,9 @@ class EnvironmentProtectionRuleReviewer(github.GithubObject.NonCompletableGithub if "reviewer" in attributes: # pragma no branch assert self._type.value in ("User", "Team") if self._type.value == "User": - self._reviewer = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["reviewer"] - ) + self._reviewer = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["reviewer"]) elif self._type.value == "Team": - self._reviewer = self._makeClassAttribute( - github.Team.Team, attributes["reviewer"] - ) + self._reviewer = self._makeClassAttribute(github.Team.Team, attributes["reviewer"]) class ReviewerParams: diff --git a/github/Event.py b/github/Event.py index 61d03773..dc506d31 100644 --- a/github/Event.py +++ b/github/Event.py @@ -110,24 +110,18 @@ class Event(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch - self._actor = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["actor"] - ) + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "org" in attributes: # pragma no branch - self._org = self._makeClassAttribute( - github.Organization.Organization, attributes["org"] - ) + self._org = self._makeClassAttribute(github.Organization.Organization, attributes["org"]) if "payload" in attributes: # pragma no branch self._payload = self._makeDictAttribute(attributes["payload"]) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "repo" in attributes: # pragma no branch - self._repo = self._makeClassAttribute( - github.Repository.Repository, attributes["repo"] - ) + self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) diff --git a/github/File.py b/github/File.py index cc07442c..14a4941e 100644 --- a/github/File.py +++ b/github/File.py @@ -39,9 +39,7 @@ class File(github.GithubObject.NonCompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"sha": self._sha.value, "filename": self._filename.value} - ) + return self.get__repr__({"sha": self._sha.value, "filename": self._filename.value}) @property def additions(self): @@ -149,9 +147,7 @@ class File(github.GithubObject.NonCompletableGithubObject): if "patch" in attributes: # pragma no branch self._patch = self._makeStringAttribute(attributes["patch"]) if "previous_filename" in attributes: # pragma no branch - self._previous_filename = self._makeStringAttribute( - attributes["previous_filename"] - ) + self._previous_filename = self._makeStringAttribute(attributes["previous_filename"]) if "raw_url" in attributes: # pragma no branch self._raw_url = self._makeStringAttribute(attributes["raw_url"]) if "sha" in attributes: # pragma no branch diff --git a/github/Gist.py b/github/Gist.py index b8187305..1f5b5d16 100644 --- a/github/Gist.py +++ b/github/Gist.py @@ -209,12 +209,8 @@ class Gist(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/comments", input=post_parameters - ) - return github.GistComment.GistComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/comments", input=post_parameters) + return github.GistComment.GistComment(self._requester, headers, data, completed=True) def create_fork(self): """ @@ -231,33 +227,23 @@ class Gist(github.GithubObject.CompletableGithubObject): """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) - def edit( - self, description=github.GithubObject.NotSet, files=github.GithubObject.NotSet - ): + def edit(self, description=github.GithubObject.NotSet, files=github.GithubObject.NotSet): """ :calls: `PATCH /gists/{id} `_ :param description: string :param files: dict of string to :class:`github.InputFileContent.InputFileContent` :rtype: None """ - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert description is github.GithubObject.NotSet or isinstance(description, str), description assert files is github.GithubObject.NotSet or all( - element is None or isinstance(element, github.InputFileContent) - for element in files.values() + element is None or isinstance(element, github.InputFileContent) for element in files.values() ), files post_parameters = dict() if description is not github.GithubObject.NotSet: post_parameters["description"] = description if files is not github.GithubObject.NotSet: - post_parameters["files"] = { - key: None if value is None else value._identity - for key, value in files.items() - } - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + post_parameters["files"] = {key: None if value is None else value._identity for key, value in files.items()} + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_comment(self, id): @@ -267,12 +253,8 @@ class Gist(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GistComment.GistComment` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/comments/{id}" - ) - return github.GistComment.GistComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/comments/{id}") + return github.GistComment.GistComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -299,9 +281,7 @@ class Gist(github.GithubObject.CompletableGithubObject): :calls: `DELETE /gists/{id}/star `_ :rtype: None """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/star" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/star") def set_starred(self): """ @@ -343,9 +323,7 @@ class Gist(github.GithubObject.CompletableGithubObject): if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch - self._files = self._makeDictOfStringsToClassesAttribute( - github.GistFile.GistFile, attributes["files"] - ) + self._files = self._makeDictOfStringsToClassesAttribute(github.GistFile.GistFile, attributes["files"]) if "fork_of" in attributes: # pragma no branch self._fork_of = self._makeClassAttribute(Gist, attributes["fork_of"]) if "forks" in attributes: # pragma no branch @@ -365,9 +343,7 @@ class Gist(github.GithubObject.CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "owner" in attributes: # pragma no branch - self._owner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["owner"] - ) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch @@ -375,6 +351,4 @@ class Gist(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/GistComment.py b/github/GistComment.py index 4ba5c5f3..f5a0a7b9 100644 --- a/github/GistComment.py +++ b/github/GistComment.py @@ -105,9 +105,7 @@ class GistComment(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def _initAttributes(self): @@ -130,6 +128,4 @@ class GistComment(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py index 5cb96908..ded73e7d 100644 --- a/github/GistHistoryState.py +++ b/github/GistHistoryState.py @@ -231,9 +231,7 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "change_status" in attributes: # pragma no branch - self._change_status = self._makeClassAttribute( - github.CommitStats.CommitStats, attributes["change_status"] - ) + self._change_status = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["change_status"]) if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch @@ -247,13 +245,9 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch - self._files = self._makeDictOfStringsToClassesAttribute( - github.GistFile.GistFile, attributes["files"] - ) + self._files = self._makeDictOfStringsToClassesAttribute(github.GistFile.GistFile, attributes["files"]) if "forks" in attributes: # pragma no branch - self._forks = self._makeListOfClassesAttribute( - github.Gist.Gist, attributes["forks"] - ) + self._forks = self._makeListOfClassesAttribute(github.Gist.Gist, attributes["forks"]) if "forks_url" in attributes: # pragma no branch self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "git_pull_url" in attributes: # pragma no branch @@ -261,17 +255,13 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): if "git_push_url" in attributes: # pragma no branch self._git_push_url = self._makeStringAttribute(attributes["git_push_url"]) if "history" in attributes: # pragma no branch - self._history = self._makeListOfClassesAttribute( - GistHistoryState, attributes["history"] - ) + self._history = self._makeListOfClassesAttribute(GistHistoryState, attributes["history"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "owner" in attributes: # pragma no branch - self._owner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["owner"] - ) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch @@ -279,8 +269,6 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) if "version" in attributes: # pragma no branch self._version = self._makeStringAttribute(attributes["version"]) diff --git a/github/GitCommit.py b/github/GitCommit.py index 601aa4fa..4269fc4d 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -121,26 +121,18 @@ class GitCommit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - self._author = self._makeClassAttribute( - github.GitAuthor.GitAuthor, attributes["author"] - ) + self._author = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["author"]) if "committer" in attributes: # pragma no branch - self._committer = self._makeClassAttribute( - github.GitAuthor.GitAuthor, attributes["committer"] - ) + self._committer = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["committer"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "parents" in attributes: # pragma no branch - self._parents = self._makeListOfClassesAttribute( - GitCommit, attributes["parents"] - ) + self._parents = self._makeListOfClassesAttribute(GitCommit, attributes["parents"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch - self._tree = self._makeClassAttribute( - github.GitTree.GitTree, attributes["tree"] - ) + self._tree = self._makeClassAttribute(github.GitTree.GitTree, attributes["tree"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitRef.py b/github/GitRef.py index 5b46d1bb..c161b35e 100644 --- a/github/GitRef.py +++ b/github/GitRef.py @@ -34,13 +34,7 @@ from typing import TYPE_CHECKING import github.GithubObject import github.GitObject -from github.GithubObject import ( - Attribute, - CompletableGithubObject, - NotSet, - Opt, - is_optional, -) +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_optional if TYPE_CHECKING: from github.GitObject import GitObject @@ -87,16 +81,12 @@ class GitRef(CompletableGithubObject): assert isinstance(sha, str), sha assert is_optional(force, bool), force post_parameters = NotSet.remove_unset_items({"sha": sha, "force": force}) - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def _useAttributes(self, attributes) -> None: if "object" in attributes: # pragma no branch - self._object = self._makeClassAttribute( - github.GitObject.GitObject, attributes["object"] - ) + self._object = self._makeClassAttribute(github.GitObject.GitObject, attributes["object"]) if "ref" in attributes: # pragma no branch self._ref = self._makeStringAttribute(attributes["ref"]) if "url" in attributes: # pragma no branch diff --git a/github/GitRelease.py b/github/GitRelease.py index af1453e8..36886c5b 100644 --- a/github/GitRelease.py +++ b/github/GitRelease.py @@ -227,12 +227,8 @@ class GitRelease(github.GithubObject.CompletableGithubObject): # altogether in that case, in order to match the Github API behaviour. Only send it when set. if target_commitish is not github.GithubObject.NotSet: post_parameters["target_commitish"] = target_commitish - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) - return github.GitRelease.GitRelease( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) def upload_asset( self, @@ -268,9 +264,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject): headers=headers, input=path, ) - return github.GitReleaseAsset.GitReleaseAsset( - self._requester, resp_headers, data, completed=True - ) + return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_headers, data, completed=True) def upload_asset_from_memory( self, @@ -295,11 +289,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject): assert isinstance(label, str), label post_parameters = {"label": label, "name": name} - content_type = ( - content_type - if content_type is not github.GithubObject.NotSet - else Consts.defaultMediaType - ) + content_type = content_type if content_type is not github.GithubObject.NotSet else Consts.defaultMediaType headers = {"Content-Type": content_type, "Content-Length": str(file_size)} resp_headers, data = self._requester.requestMemoryBlobAndCheck( @@ -309,9 +299,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject): headers=headers, file_like=file_like, ) - return github.GitReleaseAsset.GitReleaseAsset( - self._requester, resp_headers, data, completed=True - ) + return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_headers, data, completed=True) def get_assets(self): """ @@ -354,21 +342,15 @@ class GitRelease(github.GithubObject.CompletableGithubObject): if "tag_name" in attributes: self._tag_name = self._makeStringAttribute(attributes["tag_name"]) if "target_commitish" in attributes: - self._target_commitish = self._makeStringAttribute( - attributes["target_commitish"] - ) + self._target_commitish = self._makeStringAttribute(attributes["target_commitish"]) if "draft" in attributes: self._draft = self._makeBoolAttribute(attributes["draft"]) if "prerelease" in attributes: self._prerelease = self._makeBoolAttribute(attributes["prerelease"]) if "generate_release_notes" in attributes: - self._generate_release_notes = self._makeBoolAttribute( - attributes["generate_release_notes"] - ) + self._generate_release_notes = self._makeBoolAttribute(attributes["generate_release_notes"]) if "author" in attributes: - self._author = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["author"] - ) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "url" in attributes: self._url = self._makeStringAttribute(attributes["url"]) if "upload_url" in attributes: diff --git a/github/GitReleaseAsset.py b/github/GitReleaseAsset.py index 832e10b2..54f862e0 100644 --- a/github/GitReleaseAsset.py +++ b/github/GitReleaseAsset.py @@ -146,9 +146,7 @@ class GitReleaseAsset(github.GithubObject.CompletableGithubObject): assert isinstance(name, str), name assert isinstance(label, str), label post_parameters = {"name": name, "label": label} - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) return GitReleaseAsset(self._requester, headers, data, completed=True) def _initAttributes(self): @@ -175,9 +173,7 @@ class GitReleaseAsset(github.GithubObject.CompletableGithubObject): if "label" in attributes: # pragma no branch self._label = self._makeStringAttribute(attributes["label"]) if "uploader" in attributes: # pragma no branch - self._uploader = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["uploader"] - ) + self._uploader = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["uploader"]) if "content_type" in attributes: # pragma no branch self._content_type = self._makeStringAttribute(attributes["content_type"]) if "state" in attributes: # pragma no branch @@ -191,6 +187,4 @@ class GitReleaseAsset(github.GithubObject.CompletableGithubObject): if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "browser_download_url" in attributes: # pragma no branch - self._browser_download_url = self._makeStringAttribute( - attributes["browser_download_url"] - ) + self._browser_download_url = self._makeStringAttribute(attributes["browser_download_url"]) diff --git a/github/GitTag.py b/github/GitTag.py index 9c7250f1..0af148e4 100644 --- a/github/GitTag.py +++ b/github/GitTag.py @@ -93,16 +93,12 @@ class GitTag(CompletableGithubObject): if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "object" in attributes: # pragma no branch - self._object = self._makeClassAttribute( - github.GitObject.GitObject, attributes["object"] - ) + self._object = self._makeClassAttribute(github.GitObject.GitObject, attributes["object"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tag" in attributes: # pragma no branch self._tag = self._makeStringAttribute(attributes["tag"]) if "tagger" in attributes: # pragma no branch - self._tagger = self._makeClassAttribute( - github.GitAuthor.GitAuthor, attributes["tagger"] - ) + self._tagger = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["tagger"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitTree.py b/github/GitTree.py index 09caacfe..5a8a9cbd 100644 --- a/github/GitTree.py +++ b/github/GitTree.py @@ -75,8 +75,6 @@ class GitTree(CompletableGithubObject): if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch - self._tree = self._makeListOfClassesAttribute( - github.GitTreeElement.GitTreeElement, attributes["tree"] - ) + self._tree = self._makeListOfClassesAttribute(github.GitTreeElement.GitTreeElement, attributes["tree"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GithubApp.py b/github/GithubApp.py index 883cf2d9..08b71825 100644 --- a/github/GithubApp.py +++ b/github/GithubApp.py @@ -157,9 +157,7 @@ class GithubApp(github.GithubObject.CompletableGithubObject): if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "owner" in attributes: # pragma no branch - self._owner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["owner"] - ) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "permissions" in attributes: # pragma no branch self._permissions = self._makeDictAttribute(attributes["permissions"]) if "slug" in attributes: # pragma no branch diff --git a/github/GithubIntegration.py b/github/GithubIntegration.py index 22f77222..29bccc54 100644 --- a/github/GithubIntegration.py +++ b/github/GithubIntegration.py @@ -64,19 +64,13 @@ class GithubIntegration: if integration_id is not None: assert isinstance(integration_id, (int, str)), integration_id if private_key is not None: - assert isinstance( - private_key, str - ), "supplied private key should be a string" + assert isinstance(private_key, str), "supplied private key should be a string" assert isinstance(base_url, str), base_url assert isinstance(timeout, int), timeout assert user_agent is None or isinstance(user_agent, str), user_agent assert isinstance(per_page, int), per_page assert isinstance(verify, (bool, str)), verify - assert ( - retry is None - or isinstance(retry, int) - or isinstance(retry, urllib3.util.Retry) - ), retry + assert retry is None or isinstance(retry, int) or isinstance(retry, urllib3.util.Retry), retry assert pool_size is None or isinstance(pool_size, int), pool_size assert seconds_between_requests is None or seconds_between_requests >= 0 assert seconds_between_writes is None or seconds_between_writes >= 0 @@ -127,9 +121,7 @@ class GithubIntegration: def get_github_for_installation(self, installation_id): # The installation has to authenticate as an installation, not an app - auth = self.auth.get_installation_auth( - installation_id, requester=self.__requester - ) + auth = self.auth.get_installation_auth(installation_id, requester=self.__requester) return github.Github(**self.__requester.withAuth(auth).kwargs) def _get_headers(self): @@ -149,9 +141,7 @@ class GithubIntegration: :param url: str :rtype: :class:`github.Installation.Installation` """ - headers, response = self.__requester.requestJsonAndCheck( - "GET", url, headers=self._get_headers() - ) + headers, response = self.__requester.requestJsonAndCheck("GET", url, headers=self._get_headers()) return Installation( requester=self.__requester, @@ -183,9 +173,7 @@ class GithubIntegration: permissions = {} if not isinstance(permissions, dict): - raise GithubException( - status=400, data={"message": "Invalid permissions"}, headers=None - ) + raise GithubException(status=400, data={"message": "Invalid permissions"}, headers=None) body = {"permissions": permissions} headers, response = self.__requester.requestJsonAndCheck( @@ -267,9 +255,5 @@ class GithubIntegration: :rtype: :class:`github.GithubApp.GithubApp` """ - headers, data = self.__requester.requestJsonAndCheck( - "GET", "/app", headers=self._get_headers() - ) - return GithubApp( - requester=self.__requester, headers=headers, attributes=data, completed=True - ) + headers, data = self.__requester.requestJsonAndCheck("GET", "/app", headers=self._get_headers()) + return GithubApp(requester=self.__requester, headers=headers, attributes=data, completed=True) diff --git a/github/GithubObject.py b/github/GithubObject.py index 6233e591..4f54c5b6 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -41,17 +41,7 @@ import typing from datetime import datetime, timezone from operator import itemgetter -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - List, - Optional, - Tuple, - Type, - Union, -) +from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Type, Union from dateutil import parser from typing_extensions import Protocol, TypeGuard @@ -83,11 +73,7 @@ class _NotSetType: @staticmethod def remove_unset_items(data: Dict[str, Any]) -> Dict[str, Any]: - return { - key: value - for key, value in data.items() - if not isinstance(value, _NotSetType) - } + return {key: value for key, value in data.items() if not isinstance(value, _NotSetType)} NotSet = _NotSetType() @@ -108,11 +94,7 @@ def is_optional(v, type: Union[Type, Tuple[Type, ...]]) -> bool: def is_optional_list(v, type: Union[Type, Tuple[Type, ...]]) -> bool: - return ( - isinstance(v, _NotSetType) - or isinstance(v, list) - and all(isinstance(element, type) for element in v) - ) + return isinstance(v, _NotSetType) or isinstance(v, list) and all(isinstance(element, type) for element in v) class _ValuedAttribute(Attribute[T]): @@ -125,9 +107,7 @@ class _ValuedAttribute(Attribute[T]): class _BadAttribute(Attribute): - def __init__( - self, value: Any, expectedType: Any, exception: Optional[Exception] = None - ): + def __init__(self, value: Any, expectedType: Any, exception: Optional[Exception] = None): self.__value = value self.__expectedType = expectedType self.__exception = exception @@ -170,9 +150,7 @@ class GithubObject: if self.CHECK_AFTER_INIT_FLAG: # pragma no branch (Flag always set in tests) requester.check_me(self) - def _storeAndUseAttributes( - self, headers: Dict[str, Union[str, int]], attributes: Any - ) -> None: + def _storeAndUseAttributes(self, headers: Dict[str, Union[str, int]], attributes: Any) -> None: # Make sure headers are assigned before calling _useAttributes # (Some derived classes will use headers in _useAttributes) self._headers = headers @@ -208,17 +186,13 @@ class GithubObject: @staticmethod def __makeSimpleListAttribute(value: list, type: Type[T]) -> Attribute[T]: - if isinstance(value, list) and all( - isinstance(element, type) for element in value - ): + if isinstance(value, list) and all(isinstance(element, type) for element in value): return _ValuedAttribute(value) # type: ignore else: return _BadAttribute(value, [type]) # type: ignore @staticmethod - def __makeTransformedAttribute( - value: T, type: Type[T], transform: Callable[[T], K] - ) -> Attribute[K]: + def __makeTransformedAttribute(value: T, type: Type[T], transform: Callable[[T], K]) -> Attribute[K]: if value is None: return _ValuedAttribute(None) # type: ignore elif isinstance(value, type): @@ -269,9 +243,7 @@ class GithubObject: ) @staticmethod - def _makeListOfStringsAttribute( - value: Union[List[List[str]], List[str], List[Union[str, int]]] - ) -> Attribute: + def _makeListOfStringsAttribute(value: Union[List[List[str]], List[str], List[Union[str, int]]]) -> Attribute: return GithubObject.__makeSimpleListAttribute(value, str) @staticmethod @@ -290,17 +262,10 @@ class GithubObject: ) -> Attribute: return GithubObject.__makeSimpleListAttribute(value, list) - def _makeListOfClassesAttribute( - self, klass: Any, value: Any - ) -> Union[_ValuedAttribute, _BadAttribute]: - if isinstance(value, list) and all( - isinstance(element, dict) for element in value - ): + def _makeListOfClassesAttribute(self, klass: Any, value: Any) -> Union[_ValuedAttribute, _BadAttribute]: + if isinstance(value, list) and all(isinstance(element, dict) for element in value): return _ValuedAttribute( - [ - klass(self._requester, self._headers, element, completed=False) - for element in value - ] + [klass(self._requester, self._headers, element, completed=False) for element in value] ) else: return _BadAttribute(value, [dict]) @@ -314,14 +279,10 @@ class GithubObject: ], ) -> Union[_ValuedAttribute, _BadAttribute]: if isinstance(value, dict) and all( - isinstance(key, str) and isinstance(element, dict) - for key, element in value.items() + isinstance(key, str) and isinstance(element, dict) for key, element in value.items() ): return _ValuedAttribute( - { - key: klass(self._requester, self._headers, element, completed=False) - for key, element in value.items() - } + {key: klass(self._requester, self._headers, element, completed=False) for key, element in value.items()} ) else: return _BadAttribute(value, {str: dict}) @@ -428,9 +389,7 @@ class CompletableGithubObject(GithubObject): if status == 304: return False else: - headers, data = self._requester._Requester__check( # type: ignore - status, responseHeaders, output - ) + headers, data = self._requester._Requester__check(status, responseHeaders, output) # type: ignore self._storeAndUseAttributes(headers, data) self.__completed = True return True diff --git a/github/GithubRetry.py b/github/GithubRetry.py index 73fb2ec9..2d2f6ba1 100644 --- a/github/GithubRetry.py +++ b/github/GithubRetry.py @@ -58,9 +58,7 @@ class GithubRetry(Retry): # references the class, not the module (due to re-exporting in github/__init__.py) __datetime = datetime - def __init__( - self, secondary_rate_wait: float = DEFAULT_SECONDARY_RATE_WAIT, **kwargs - ): + def __init__(self, secondary_rate_wait: float = DEFAULT_SECONDARY_RATE_WAIT, **kwargs): """ :param secondary_rate_wait: seconds to wait before retrying secondary rate limit errors :param kwargs: see urllib3.Retry for more arguments @@ -69,12 +67,8 @@ class GithubRetry(Retry): # 403 is too broad to be retried, but GitHub API signals rate limits via 403 # we retry 403 and look into the response header via Retry.increment # to determine if we really retry that 403 - kwargs["status_forcelist"] = kwargs.get( - "status_forcelist", list(range(500, 600)) - ) + [403] - kwargs["allowed_methods"] = kwargs.get( - "allowed_methods", Retry.DEFAULT_ALLOWED_METHODS.union({"GET", "POST"}) - ) + kwargs["status_forcelist"] = kwargs.get("status_forcelist", list(range(500, 600))) + [403] + kwargs["allowed_methods"] = kwargs.get("allowed_methods", Retry.DEFAULT_ALLOWED_METHODS.union({"GET", "POST"})) super().__init__(**kwargs) def new(self, **kw): @@ -116,30 +110,20 @@ class GithubRetry(Retry): # we want to fall back to the actual github exception (probably a rate limit error) # but provide some context why we could not deal with it without another exception try: - raise RuntimeError( - "Failed to inspect response message" - ) from e + raise RuntimeError("Failed to inspect response message") from e except RuntimeError as e: - raise GithubException( - response.status, content, response.headers - ) from e + raise GithubException(response.status, content, response.headers) from e try: if Requester.isRateLimitError(message): - rate_type = ( - "primary" - if Requester.isPrimaryRateLimitError(message) - else "secondary" - ) + rate_type = "primary" if Requester.isPrimaryRateLimitError(message) else "secondary" self.__log( logging.DEBUG, f"Response body indicates retry-able {rate_type} rate limit error: {message}", ) # check early that we are retrying at all - retry = super().increment( - method, url, response, error, _pool, _stacktrace - ) + retry = super().increment(method, url, response, error, _pool, _stacktrace) # we backoff primary rate limit at least until X-RateLimit-Reset, # we backoff secondary rate limit at for secondary_rate_wait seconds @@ -149,12 +133,8 @@ class GithubRetry(Retry): if "X-RateLimit-Reset" in response.headers: value = response.headers.get("X-RateLimit-Reset") if value and value.isdigit(): - reset = self.__datetime.fromtimestamp( - int(value), timezone.utc - ) - delta = reset - self.__datetime.now( - timezone.utc - ) + reset = self.__datetime.fromtimestamp(int(value), timezone.utc) + delta = reset - self.__datetime.now(timezone.utc) resetBackoff = delta.total_seconds() if resetBackoff > 0: @@ -175,9 +155,7 @@ class GithubRetry(Retry): self.__log( logging.DEBUG, f"Retry backoff of {retry_backoff}s exceeds " - f"required rate limit backoff of {backoff}s".replace( - ".0s", "s" - ), + f"required rate limit backoff of {backoff}s".replace(".0s", "s"), ) backoff = retry_backoff @@ -186,9 +164,7 @@ class GithubRetry(Retry): self.__log( logging.INFO, - f"Setting next backoff to {backoff}s".replace( - ".0s", "s" - ), + f"Setting next backoff to {backoff}s".replace(".0s", "s"), ) retry.get_backoff_time = get_backoff_time # type: ignore return retry @@ -197,22 +173,16 @@ class GithubRetry(Retry): logging.DEBUG, "Response message does not indicate retry-able error", ) - raise Requester.createException( - response.status, response.headers, content - ) + raise Requester.createException(response.status, response.headers, content) except (MaxRetryError, GithubException): raise except Exception as e: # we want to fall back to the actual github exception (probably a rate limit error) # but provide some context why we could not deal with it without another exception try: - raise RuntimeError( - "Failed to determine retry backoff" - ) from e + raise RuntimeError("Failed to determine retry backoff") from e except RuntimeError as e: - raise GithubException( - response.status, content, response.headers - ) from e + raise GithubException(response.status, content, response.headers) from e raise GithubException(response.status, content, response.headers) diff --git a/github/Hook.py b/github/Hook.py index 9c4a2de9..8d5e9073 100644 --- a/github/Hook.py +++ b/github/Hook.py @@ -157,9 +157,7 @@ class Hook(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all( - isinstance(element, str) for element in events - ), events + assert events is github.GithubObject.NotSet or all(isinstance(element, str) for element in events), events assert add_events is github.GithubObject.NotSet or all( isinstance(element, str) for element in add_events ), add_events @@ -179,9 +177,7 @@ class Hook(github.GithubObject.CompletableGithubObject): post_parameters["remove_events"] = remove_events if active is not github.GithubObject.NotSet: post_parameters["active"] = active - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def test(self): diff --git a/github/HookDelivery.py b/github/HookDelivery.py index b3625e64..77560631 100644 --- a/github/HookDelivery.py +++ b/github/HookDelivery.py @@ -124,9 +124,7 @@ class HookDeliverySummary(github.GithubObject.NonCompletableGithubObject): if "action" in attributes: # pragma no branch self._action = self._makeStringAttribute(attributes["action"]) if "installation_id" in attributes: # pragma no branch - self._installation_id = self._makeIntAttribute( - attributes["installation_id"] - ) + self._installation_id = self._makeIntAttribute(attributes["installation_id"]) if "repository_id" in attributes: # pragma no branch self._repository_id = self._makeIntAttribute(attributes["repository_id"]) if "url" in attributes: # pragma no branch @@ -211,11 +209,7 @@ class HookDelivery(HookDeliverySummary): def _useAttributes(self, attributes: Dict[str, Any]) -> None: super()._useAttributes(attributes) if "request" in attributes: # pragma no branch - self._request = self._makeClassAttribute( - HookDeliveryRequest, attributes["request"] - ) + self._request = self._makeClassAttribute(HookDeliveryRequest, attributes["request"]) if "response" in attributes: # pragma no branch - self._response = self._makeClassAttribute( - HookDeliveryResponse, attributes["response"] - ) + self._response = self._makeClassAttribute(HookDeliveryResponse, attributes["response"]) # self._response = self._makeDictAttribute(attributes["response"]) diff --git a/github/HookDescription.py b/github/HookDescription.py index f3da40cb..86eb560c 100644 --- a/github/HookDescription.py +++ b/github/HookDescription.py @@ -70,6 +70,4 @@ class HookDescription(NonCompletableGithubObject): if "schema" in attributes: # pragma no branch self._schema = self._makeListOfListOfStringsAttribute(attributes["schema"]) if "supported_events" in attributes: # pragma no branch - self._supported_events = self._makeListOfStringsAttribute( - attributes["supported_events"] - ) + self._supported_events = self._makeListOfStringsAttribute(attributes["supported_events"]) diff --git a/github/InstallationAuthorization.py b/github/InstallationAuthorization.py index 8309b58c..be9a903f 100644 --- a/github/InstallationAuthorization.py +++ b/github/InstallationAuthorization.py @@ -76,12 +76,8 @@ class InstallationAuthorization(NonCompletableGithubObject): if "expires_at" in attributes: # pragma no branch self._expires_at = self._makeDatetimeAttribute(attributes["expires_at"]) if "on_behalf_of" in attributes: # pragma no branch - self._on_behalf_of = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["on_behalf_of"] - ) + self._on_behalf_of = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["on_behalf_of"]) if "permissions" in attributes: # pragma no branch self._permissions = self._makeDictAttribute(attributes["permissions"]) if "repository_selection" in attributes: # pragma no branch - self._repository_selection = self._makeStringAttribute( - attributes["repository_selection"] - ) + self._repository_selection = self._makeStringAttribute(attributes["repository_selection"]) diff --git a/github/Invitation.py b/github/Invitation.py index 971085a0..0bed0d37 100644 --- a/github/Invitation.py +++ b/github/Invitation.py @@ -109,19 +109,13 @@ class Invitation(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "invitee" in attributes: # pragma no branch - self._invitee = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["invitee"] - ) + self._invitee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["invitee"]) if "inviter" in attributes: # pragma no branch - self._inviter = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["inviter"] - ) + self._inviter = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["inviter"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) diff --git a/github/Issue.py b/github/Issue.py index c2153f3d..d6e95b07 100644 --- a/github/Issue.py +++ b/github/Issue.py @@ -117,9 +117,7 @@ class Issue(CompletableGithubObject): self._user: Attribute[NamedUser] = NotSet def __repr__(self): - return self.get__repr__( - {"number": self._number.value, "title": self._title.value} - ) + return self.get__repr__({"number": self._number.value, "title": self._title.value}) @property def assignee(self) -> NamedUser | None: @@ -208,9 +206,7 @@ class Issue(CompletableGithubObject): # The repository was not set automatically, so it must be looked up by url. repo_url = "/".join(self.url.split("/")[:-2]) self._repository = github.GithubObject._ValuedAttribute( - github.Repository.Repository( - self._requester, self._headers, {"url": repo_url}, completed=False - ) + github.Repository.Repository(self._requester, self._headers, {"url": repo_url}, completed=False) ) return self._repository.value @@ -258,48 +254,30 @@ class Issue(CompletableGithubObject): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number} `_ """ - headers, data = self._requester.requestJsonAndCheck( - "GET", "/pulls/".join(self.url.rsplit("/issues/", 1)) - ) - return github.PullRequest.PullRequest( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", "/pulls/".join(self.url.rsplit("/issues/", 1))) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def add_to_assignees(self, *assignees: NamedUser | str) -> None: """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/assignees `_ """ - assert all( - isinstance(element, (github.NamedUser.NamedUser, str)) - for element in assignees - ), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees), assignees post_parameters = { "assignees": [ - assignee.login - if isinstance(assignee, github.NamedUser.NamedUser) - else assignee + assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/assignees", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/assignees", input=post_parameters) self._useAttributes(data) def add_to_labels(self, *labels: Label | str) -> None: """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/labels `_ """ - assert all( - isinstance(element, (github.Label.Label, str)) for element in labels - ), labels - post_parameters = [ - label.name if isinstance(label, github.Label.Label) else label - for label in labels - ] - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/labels", input=post_parameters - ) + assert all(isinstance(element, (github.Label.Label, str)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/labels", input=post_parameters) def create_comment(self, body: str) -> IssueComment: """ @@ -309,20 +287,14 @@ class Issue(CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/comments", input=post_parameters - ) - return github.IssueComment.IssueComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/comments", input=post_parameters) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def delete_labels(self) -> None: """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels `_ """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/labels" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/labels") def edit( self, @@ -342,14 +314,10 @@ class Issue(CompletableGithubObject): """ assert is_optional(title, str), title assert is_optional(body, str), body - assert assignee is None or is_optional( - assignee, (github.NamedUser.NamedUser, str) - ), assignee + assert assignee is None or is_optional(assignee, (github.NamedUser.NamedUser, str)), assignee assert is_optional_list(assignees, (github.NamedUser.NamedUser, str)), assignees assert is_optional(state, str), state - assert milestone is None or is_optional( - milestone, github.Milestone.Milestone - ), milestone + assert milestone is None or is_optional(milestone, github.Milestone.Milestone), milestone assert is_optional_list(labels, str), labels post_parameters = NotSet.remove_unset_items( @@ -370,15 +338,11 @@ class Issue(CompletableGithubObject): if is_defined(assignees): post_parameters["assignees"] = [ - element._identity - if isinstance(element, github.NamedUser.NamedUser) - else element + element._identity if isinstance(element, github.NamedUser.NamedUser) else element for element in assignees ] - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def lock(self, lock_reason: str) -> None: @@ -398,25 +362,17 @@ class Issue(CompletableGithubObject): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock `_ """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/lock" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/lock") def get_comment(self, id: int) -> IssueComment: """ :calls: `GET /repos/{owner}/{repo}/issues/comments/{id} `_ """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self._parentUrl(self.url)}/comments/{id}" - ) - return github.IssueComment.IssueComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self._parentUrl(self.url)}/comments/{id}") + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) - def get_comments( - self, since: Opt[datetime] = NotSet - ) -> PaginatedList[IssueComment]: + def get_comments(self, since: Opt[datetime] = NotSet) -> PaginatedList[IssueComment]: """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/comments `_ """ @@ -448,29 +404,20 @@ class Issue(CompletableGithubObject): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/labels `_ """ - return PaginatedList( - github.Label.Label, self._requester, f"{self.url}/labels", None - ) + return PaginatedList(github.Label.Label, self._requester, f"{self.url}/labels", None) def remove_from_assignees(self, *assignees: NamedUser | str) -> None: """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/assignees `_ """ - assert all( - isinstance(element, (github.NamedUser.NamedUser, str)) - for element in assignees - ), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees), assignees post_parameters = { "assignees": [ - assignee.login - if isinstance(assignee, github.NamedUser.NamedUser) - else assignee + assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/assignees", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/assignees", input=post_parameters) self._useAttributes(data) def remove_from_labels(self, label: Label | str) -> None: @@ -482,24 +429,15 @@ class Issue(CompletableGithubObject): label = label._identity else: label = urllib.parse.quote(label) - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/labels/{label}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/labels/{label}") def set_labels(self, *labels: Label | str) -> None: """ :calls: `PUT /repos/{owner}/{repo}/issues/{number}/labels `_ """ - assert all( - isinstance(element, (github.Label.Label, str)) for element in labels - ), labels - post_parameters = [ - label.name if isinstance(label, github.Label.Label) else label - for label in labels - ] - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.url}/labels", input=post_parameters - ) + assert all(isinstance(element, (github.Label.Label, str)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/labels", input=post_parameters) def get_reactions(self) -> PaginatedList[Reaction]: """ @@ -559,34 +497,22 @@ class Issue(CompletableGithubObject): def _useAttributes(self, attributes) -> None: if "active_lock_reason" in attributes: # pragma no branch - self._active_lock_reason = self._makeStringAttribute( - attributes["active_lock_reason"] - ) + self._active_lock_reason = self._makeStringAttribute(attributes["active_lock_reason"]) if "assignee" in attributes: # pragma no branch - self._assignee = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["assignee"] - ) + self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) if "assignees" in attributes: # pragma no branch - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, attributes["assignees"] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, attributes["assignees"]) elif "assignee" in attributes: if attributes["assignee"] is not None: - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, [attributes["assignee"]] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, [attributes["assignee"]]) else: - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, [] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, []) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "closed_at" in attributes: # pragma no branch self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "closed_by" in attributes: # pragma no branch - self._closed_by = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["closed_by"] - ) + self._closed_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["closed_by"]) if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch @@ -600,17 +526,13 @@ class Issue(CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "labels" in attributes: # pragma no branch - self._labels = self._makeListOfClassesAttribute( - github.Label.Label, attributes["labels"] - ) + self._labels = self._makeListOfClassesAttribute(github.Label.Label, attributes["labels"]) if "labels_url" in attributes: # pragma no branch self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "locked" in attributes: # pragma no branch self._locked = self._makeBoolAttribute(attributes["locked"]) if "milestone" in attributes: # pragma no branch - self._milestone = self._makeClassAttribute( - github.Milestone.Milestone, attributes["milestone"] - ) + self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"]) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "pull_request" in attributes: # pragma no branch @@ -618,9 +540,7 @@ class Issue(CompletableGithubObject): github.IssuePullRequest.IssuePullRequest, attributes["pull_request"] ) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "state_reason" in attributes: # pragma no branch @@ -632,6 +552,4 @@ class Issue(CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/IssueComment.py b/github/IssueComment.py index 9620a68c..294aa6ec 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -127,9 +127,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_reactions(self): @@ -206,6 +204,4 @@ class IssueComment(github.GithubObject.CompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/IssueEvent.py b/github/IssueEvent.py index aea8f0e0..36297425 100644 --- a/github/IssueEvent.py +++ b/github/IssueEvent.py @@ -208,9 +208,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch - self._actor = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["actor"] - ) + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch @@ -220,9 +218,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issue" in attributes: # pragma no branch - self._issue = self._makeClassAttribute( - github.Issue.Issue, attributes["issue"] - ) + self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "node_id" in attributes: # pragma no branch @@ -230,17 +226,11 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): if "commit_url" in attributes: # pragma no branch self._commit_url = self._makeStringAttribute(attributes["commit_url"]) if "label" in attributes: # pragma no branch - self._label = self._makeClassAttribute( - github.Label.Label, attributes["label"] - ) + self._label = self._makeClassAttribute(github.Label.Label, attributes["label"]) if "assignee" in attributes: # pragma no branch - self._assignee = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["assignee"] - ) + self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) if "assigner" in attributes: # pragma no branch - self._assigner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["assigner"] - ) + self._assigner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assigner"]) if "review_requester" in attributes: # pragma no branch self._review_requester = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["review_requester"] @@ -250,14 +240,10 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): github.NamedUser.NamedUser, attributes["requested_reviewer"] ) if "milestone" in attributes: # pragma no branch - self._milestone = self._makeClassAttribute( - github.Milestone.Milestone, attributes["milestone"] - ) + self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"]) if "rename" in attributes: # pragma no branch self._rename = self._makeDictAttribute(attributes["rename"]) if "dismissed_review" in attributes: # pragma no branch - self._dismissed_review = self._makeDictAttribute( - attributes["dismissed_review"] - ) + self._dismissed_review = self._makeDictAttribute(attributes["dismissed_review"]) if "lock_reason" in attributes: # pragma no branch self._lock_reason = self._makeStringAttribute(attributes["lock_reason"]) diff --git a/github/Label.py b/github/Label.py index 1d83d3c1..d8c6fdf8 100644 --- a/github/Label.py +++ b/github/Label.py @@ -93,9 +93,7 @@ class Label(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(color, str), color - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert description is github.GithubObject.NotSet or isinstance(description, str), description post_parameters = { "new_name": name, "color": color, diff --git a/github/Label.pyi b/github/Label.pyi index cc24477a..f205c8b6 100644 --- a/github/Label.pyi +++ b/github/Label.pyi @@ -13,9 +13,7 @@ class Label(CompletableGithubObject): def delete(self) -> None: ... @property def description(self) -> Optional[str]: ... - def edit( - self, name: str, color: str, description: Union[str, _NotSetType] = ... - ) -> None: ... + def edit(self, name: str, color: str, description: Union[str, _NotSetType] = ...) -> None: ... @property def name(self) -> str: ... @property diff --git a/github/License.py b/github/License.py index 0b1df082..90c90245 100644 --- a/github/License.py +++ b/github/License.py @@ -146,20 +146,12 @@ class License(github.GithubObject.CompletableGithubObject): if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "implementation" in attributes: # pragma no branch - self._implementation = self._makeStringAttribute( - attributes["implementation"] - ) + self._implementation = self._makeStringAttribute(attributes["implementation"]) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "permissions" in attributes: # pragma no branch - self._permissions = self._makeListOfStringsAttribute( - attributes["permissions"] - ) + self._permissions = self._makeListOfStringsAttribute(attributes["permissions"]) if "conditions" in attributes: # pragma no branch - self._conditions = self._makeListOfStringsAttribute( - attributes["conditions"] - ) + self._conditions = self._makeListOfStringsAttribute(attributes["conditions"]) if "limitations" in attributes: # pragma no branch - self._limitations = self._makeListOfStringsAttribute( - attributes["limitations"] - ) + self._limitations = self._makeListOfStringsAttribute(attributes["limitations"]) diff --git a/github/MainClass.py b/github/MainClass.py index 8f3b1f7b..05813ccd 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -135,11 +135,7 @@ class Github: assert user_agent is None or isinstance(user_agent, str), user_agent assert isinstance(per_page, int), per_page assert isinstance(verify, (bool, str)), verify - assert ( - retry is None - or isinstance(retry, int) - or isinstance(retry, urllib3.util.Retry) - ), retry + assert retry is None or isinstance(retry, int) or isinstance(retry, urllib3.util.Retry), retry assert pool_size is None or isinstance(pool_size, int), pool_size assert seconds_between_requests is None or seconds_between_requests >= 0 assert seconds_between_writes is None or seconds_between_writes >= 0 @@ -154,8 +150,7 @@ class Github: auth = Auth.Login(login_or_token, password) elif login_or_token is not None: warnings.warn( - "Argument login_or_token is deprecated, please use " - "auth=github.Auth.Token(...) instead", + "Argument login_or_token is deprecated, please use " "auth=github.Auth.Token(...) instead", category=DeprecationWarning, ) auth = Auth.Token(login_or_token) @@ -169,8 +164,7 @@ class Github: auth = Auth.AppAuthToken(jwt) elif app_auth is not None: warnings.warn( - "Argument app_auth is deprecated, please use " - "auth=github.Auth.AppInstallationAuth(...) instead", + "Argument app_auth is deprecated, please use " "auth=github.Auth.AppInstallationAuth(...) instead", category=DeprecationWarning, ) auth = app_auth @@ -273,9 +267,7 @@ class Github: url_parameters = dict() - return github.PaginatedList.PaginatedList( - github.License.License, self.__requester, "/licenses", url_parameters - ) + return github.PaginatedList.PaginatedList(github.License.License, self.__requester, "/licenses", url_parameters) def get_events(self): """ @@ -283,9 +275,7 @@ class Github: :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ - return github.PaginatedList.PaginatedList( - github.Event.Event, self.__requester, "/events", None - ) + return github.PaginatedList.PaginatedList(github.Event.Event, self.__requester, "/events", None) def get_user(self, login=github.GithubObject.NotSet): """ @@ -295,16 +285,10 @@ class Github: """ assert login is github.GithubObject.NotSet or isinstance(login, str), login if login is github.GithubObject.NotSet: - return AuthenticatedUser.AuthenticatedUser( - self.__requester, {}, {"url": "/user"}, completed=False - ) + return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) else: - headers, data = self.__requester.requestJsonAndCheck( - "GET", f"/users/{login}" - ) - return github.NamedUser.NamedUser( - self.__requester, headers, data, completed=True - ) + headers, data = self.__requester.requestJsonAndCheck("GET", f"/users/{login}") + return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True) def get_user_by_id(self, user_id): """ @@ -314,9 +298,7 @@ class Github: """ assert isinstance(user_id, int), user_id headers, data = self.__requester.requestJsonAndCheck("GET", f"/user/{user_id}") - return github.NamedUser.NamedUser( - self.__requester, headers, data, completed=True - ) + return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True) def get_users(self, since=github.GithubObject.NotSet): """ @@ -340,9 +322,7 @@ class Github: """ assert isinstance(login, str), login headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}") - return github.Organization.Organization( - self.__requester, headers, data, completed=True - ) + return github.Organization.Organization(self.__requester, headers, data, completed=True) def get_organizations(self, since=github.GithubObject.NotSet): """ @@ -370,15 +350,11 @@ class Github: url_base = "/repositories/" if isinstance(full_name_or_id, int) else "/repos/" url = f"{url_base}{full_name_or_id}" if lazy: - return Repository.Repository( - self.__requester, {}, {"url": url}, completed=False - ) + return Repository.Repository(self.__requester, {}, {"url": url}, completed=False) headers, data = self.__requester.requestJsonAndCheck("GET", url) return Repository.Repository(self.__requester, headers, data, completed=True) - def get_repos( - self, since=github.GithubObject.NotSet, visibility=github.GithubObject.NotSet - ): + def get_repos(self, since=github.GithubObject.NotSet, visibility=github.GithubObject.NotSet): """ :calls: `GET /repositories `_ :param since: integer @@ -423,9 +399,7 @@ class Github: "/projects/columns/%d" % id, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) - return github.ProjectColumn.ProjectColumn( - self.__requester, headers, data, completed=True - ) + return github.ProjectColumn.ProjectColumn(self.__requester, headers, data, completed=True) def get_gist(self, id): """ @@ -447,9 +421,7 @@ class Github: url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") - return github.PaginatedList.PaginatedList( - github.Gist.Gist, self.__requester, "/gists/public", url_parameters - ) + return github.PaginatedList.PaginatedList(github.Gist.Gist, self.__requester, "/gists/public", url_parameters) def search_repositories( self, @@ -468,14 +440,10 @@ class Github: """ assert isinstance(query, str), query url_parameters = dict() - if ( - sort is not github.GithubObject.NotSet - ): # pragma no branch (Should be covered) + if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert sort in ("stars", "forks", "updated"), sort url_parameters["sort"] = sort - if ( - order is not github.GithubObject.NotSet - ): # pragma no branch (Should be covered) + if order is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert order in ("asc", "desc"), order url_parameters["order"] = order @@ -594,14 +562,10 @@ class Github: """ assert isinstance(query, str), query url_parameters = dict() - if ( - sort is not github.GithubObject.NotSet - ): # pragma no branch (Should be covered) + if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert sort in ("indexed",), sort url_parameters["sort"] = sort - if ( - order is not github.GithubObject.NotSet - ): # pragma no branch (Should be covered) + if order is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert order in ("asc", "desc"), order url_parameters["order"] = order @@ -703,16 +667,12 @@ class Github: :rtype: string """ assert isinstance(text, str), text - assert context is github.GithubObject.NotSet or isinstance( - context, github.Repository.Repository - ), context + assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context post_parameters = {"text": text} if context is not github.GithubObject.NotSet: post_parameters["mode"] = "gfm" post_parameters["context"] = context._identity - status, headers, data = self.__requester.requestJson( - "POST", "/markdown", input=post_parameters - ) + status, headers, data = self.__requester.requestJson("POST", "/markdown", input=post_parameters) return data def get_hook(self, name): @@ -722,12 +682,8 @@ class Github: :rtype: :class:`github.HookDescription.HookDescription` """ assert isinstance(name, str), name - headers, attributes = self.__requester.requestJsonAndCheck( - "GET", f"/hooks/{name}" - ) - return HookDescription.HookDescription( - self.__requester, headers, attributes, completed=True - ) + headers, attributes = self.__requester.requestJsonAndCheck("GET", f"/hooks/{name}") + return HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) def get_hooks(self): """ @@ -736,9 +692,7 @@ class Github: """ headers, data = self.__requester.requestJsonAndCheck("GET", "/hooks") return [ - HookDescription.HookDescription( - self.__requester, headers, attributes, completed=True - ) + HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) for attributes in data ] @@ -751,12 +705,8 @@ class Github: """ assert isinstance(hook_id, int), hook_id assert isinstance(delivery_id, int), delivery_id - headers, attributes = self.__requester.requestJsonAndCheck( - "GET", f"/hooks/{hook_id}/deliveries/{delivery_id}" - ) - return HookDelivery.HookDelivery( - self.__requester, headers, attributes, completed=True - ) + headers, attributes = self.__requester.requestJsonAndCheck("GET", f"/hooks/{hook_id}/deliveries/{delivery_id}") + return HookDelivery.HookDelivery(self.__requester, headers, attributes, completed=True) def get_hook_deliveries(self, hook_id: int) -> List[HookDeliverySummary]: """ @@ -765,13 +715,9 @@ class Github: :rtype: list of :class:`github.HookDelivery.HookDeliverySummary` """ assert isinstance(hook_id, int), hook_id - headers, data = self.__requester.requestJsonAndCheck( - "GET", f"/hooks/{hook_id}/deliveries" - ) + headers, data = self.__requester.requestJsonAndCheck("GET", f"/hooks/{hook_id}/deliveries") return [ - HookDelivery.HookDeliverySummary( - self.__requester, headers, attributes, completed=True - ) + HookDelivery.HookDeliverySummary(self.__requester, headers, attributes, completed=True) for attributes in data ] @@ -780,9 +726,7 @@ class Github: :calls: `GET /gitignore/templates `_ :rtype: list of string """ - headers, data = self.__requester.requestJsonAndCheck( - "GET", "/gitignore/templates" - ) + headers, data = self.__requester.requestJsonAndCheck("GET", "/gitignore/templates") return data def get_gitignore_template(self, name): @@ -791,12 +735,8 @@ class Github: :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` """ assert isinstance(name, str), name - headers, attributes = self.__requester.requestJsonAndCheck( - "GET", f"/gitignore/templates/{name}" - ) - return GitignoreTemplate.GitignoreTemplate( - self.__requester, headers, attributes, completed=True - ) + headers, attributes = self.__requester.requestJsonAndCheck("GET", f"/gitignore/templates/{name}") + return GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True) def get_emojis(self): """ @@ -866,9 +806,7 @@ class Github: return GithubIntegration(auth=self.__requester.auth).get_app() else: # with a slug given, we can lazily load the GithubApp - return GithubApp.GithubApp( - self.__requester, {}, {"url": f"/apps/{slug}"}, completed=False - ) + return GithubApp.GithubApp(self.__requester, {}, {"url": f"/apps/{slug}"}, completed=False) # Retrocompatibility diff --git a/github/MainClass.pyi b/github/MainClass.pyi index 9049067d..7c770289 100644 --- a/github/MainClass.pyi +++ b/github/MainClass.pyi @@ -69,9 +69,7 @@ class Github: def get_emojis(self) -> Dict[str, str]: ... def get_events(self) -> PaginatedList[Event]: ... def get_gist(self, id: str) -> Gist: ... - def get_gists( - self, since: Union[datetime, _NotSetType] = ... - ) -> PaginatedList[Gist]: ... + def get_gists(self, since: Union[datetime, _NotSetType] = ...) -> PaginatedList[Gist]: ... def get_gitignore_template(self, name: str) -> GitignoreTemplate: ... def get_gitignore_templates(self) -> List[str]: ... def get_hook(self, name: str) -> HookDescription: ... @@ -79,15 +77,11 @@ class Github: def get_license(self, key: Union[str, _NotSetType] = ...) -> License: ... def get_licenses(self) -> PaginatedList[License]: ... def get_organization(self, login: str) -> Organization: ... - def get_organizations( - self, since: Union[int, _NotSetType] = ... - ) -> PaginatedList[Organization]: ... + def get_organizations(self, since: Union[int, _NotSetType] = ...) -> PaginatedList[Organization]: ... def get_project(self, id: int) -> Project: ... def get_project_column(self, id: int) -> ProjectColumn: ... def get_rate_limit(self) -> RateLimit: ... - def get_repo( - self, full_name_or_id: Union[int, str], lazy: bool = ... - ) -> Repository: ... + def get_repo(self, full_name_or_id: Union[int, str], lazy: bool = ...) -> Repository: ... def get_repos( self, since: Union[int, _NotSetType] = ..., @@ -96,62 +90,38 @@ class Github: @overload def get_user(self, login: _NotSetType = ...) -> AuthenticatedUser: ... @overload - def get_user( - self, login: Union[str, _NotSetType] = ... - ) -> Union[NamedUser, AuthenticatedUser]: ... + def get_user(self, login: Union[str, _NotSetType] = ...) -> Union[NamedUser, AuthenticatedUser]: ... def get_user_by_id(self, user_id: int) -> NamedUser: ... - def get_users( - self, since: Union[int, _NotSetType] = ... - ) -> PaginatedList[NamedUser]: ... + def get_users(self, since: Union[int, _NotSetType] = ...) -> PaginatedList[NamedUser]: ... def load(self, f: BytesIO) -> Repository: ... # argument slug is deprecated, not included here def get_app(self): ... - def get_oauth_application( - self, client_id: str, client_secret: str - ) -> ApplicationOAuth: ... + def get_oauth_application(self, client_id: str, client_secret: str) -> ApplicationOAuth: ... @property def oauth_scopes(self) -> Optional[List[str]]: ... @property def rate_limiting(self) -> Tuple[int, int]: ... @property def rate_limiting_resettime(self) -> int: ... - def render_markdown( - self, text: str, context: Union[Repository, _NotSetType] = ... - ) -> str: ... + def render_markdown(self, text: str, context: Union[Repository, _NotSetType] = ...) -> str: ... def search_code( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., highlight: bool = ..., - **qualifiers: Any + **qualifiers: Any, ) -> PaginatedList[ContentFile]: ... def search_commits( - self, - query: str, - sort: Union[str, _NotSetType] = ..., - order: Union[str, _NotSetType] = ..., - **qualifiers: Any + self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Commit]: ... def search_issues( - self, - query: str, - sort: Union[str, _NotSetType] = ..., - order: Union[str, _NotSetType] = ..., - **qualifiers: Any + self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Issue]: ... def search_repositories( - self, - query: str, - sort: Union[str, _NotSetType] = ..., - order: Union[str, _NotSetType] = ..., - **qualifiers: Any + self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Repository]: ... def search_topics(self, query: str, **qualifiers: Any) -> PaginatedList[Topic]: ... def search_users( - self, - query: str, - sort: Union[str, _NotSetType] = ..., - order: Union[str, _NotSetType] = ..., - **qualifiers: Any + self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[NamedUser]: ... diff --git a/github/Membership.py b/github/Membership.py index 24269b7a..9ffca70d 100644 --- a/github/Membership.py +++ b/github/Membership.py @@ -113,14 +113,8 @@ class Membership(github.GithubObject.CompletableGithubObject): if "role" in attributes: # pragma no branch self._role = self._makeStringAttribute(attributes["role"]) if "organization_url" in attributes: # pragma no branch - self._organization_url = self._makeStringAttribute( - attributes["organization_url"] - ) + self._organization_url = self._makeStringAttribute(attributes["organization_url"]) if "organization" in attributes: # pragma no branch - self._organization = self._makeClassAttribute( - github.Organization.Organization, attributes["organization"] - ) + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/Migration.py b/github/Migration.py index 5ab0caea..20156dff 100644 --- a/github/Migration.py +++ b/github/Migration.py @@ -188,21 +188,15 @@ class Migration(github.GithubObject.CompletableGithubObject): if "id" in attributes: self._id = self._makeIntAttribute(attributes["id"]) if "owner" in attributes: - self._owner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["owner"] - ) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "guid" in attributes: self._guid = self._makeStringAttribute(attributes["guid"]) if "state" in attributes: self._state = self._makeStringAttribute(attributes["state"]) if "lock_repositories" in attributes: - self._lock_repositories = self._makeBoolAttribute( - attributes["lock_repositories"] - ) + self._lock_repositories = self._makeBoolAttribute(attributes["lock_repositories"]) if "exclude_attachments" in attributes: - self._exclude_attachments = self._makeBoolAttribute( - attributes["exclude_attachments"] - ) + self._exclude_attachments = self._makeBoolAttribute(attributes["exclude_attachments"]) if "repositories" in attributes: self._repositories = self._makeListOfClassesAttribute( github.Repository.Repository, attributes["repositories"] diff --git a/github/Milestone.py b/github/Milestone.py index ae5cdaae..778ea2fa 100644 --- a/github/Milestone.py +++ b/github/Milestone.py @@ -42,9 +42,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"number": self._number.value, "title": self._title.value} - ) + return self.get__repr__({"number": self._number.value, "title": self._title.value}) @property def closed_issues(self): @@ -174,9 +172,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): """ assert isinstance(title, str), title assert state is github.GithubObject.NotSet or isinstance(state, str), state - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert description is github.GithubObject.NotSet or isinstance(description, str), description assert due_on is github.GithubObject.NotSet or isinstance(due_on, date), due_on post_parameters = { "title": title, @@ -187,9 +183,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): post_parameters["description"] = description if due_on is not github.GithubObject.NotSet: post_parameters["due_on"] = due_on.strftime("%Y-%m-%d") - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_labels(self): @@ -197,9 +191,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/milestones/{number}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ - return github.PaginatedList.PaginatedList( - github.Label.Label, self._requester, f"{self.url}/labels", None - ) + return github.PaginatedList.PaginatedList(github.Label.Label, self._requester, f"{self.url}/labels", None) @property def _identity(self): @@ -226,9 +218,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "due_on" in attributes: # pragma no branch diff --git a/github/NamedUser.py b/github/NamedUser.py index 86d8bd11..029edc35 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -78,11 +78,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): return hash((self.id, self.login)) def __eq__(self, other): - return ( - isinstance(other, type(self)) - and self.login == other.login - and self.id == other.id - ) + return isinstance(other, type(self)) and self.login == other.login and self.id == other.id @property def avatar_url(self): @@ -433,27 +429,21 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /users/{user}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ - return github.PaginatedList.PaginatedList( - github.Event.Event, self._requester, f"{self.url}/events", None - ) + return github.PaginatedList.PaginatedList(github.Event.Event, self._requester, f"{self.url}/events", None) def get_followers(self): """ :calls: `GET /users/{user}/followers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - return github.PaginatedList.PaginatedList( - NamedUser, self._requester, f"{self.url}/followers", None - ) + return github.PaginatedList.PaginatedList(NamedUser, self._requester, f"{self.url}/followers", None) def get_following(self): """ :calls: `GET /users/{user}/following `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - return github.PaginatedList.PaginatedList( - NamedUser, self._requester, f"{self.url}/following", None - ) + return github.PaginatedList.PaginatedList(NamedUser, self._requester, f"{self.url}/following", None) def get_gists(self, since=github.GithubObject.NotSet): """ @@ -474,9 +464,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :calls: `GET /users/{user}/keys `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.UserKey.UserKey` """ - return github.PaginatedList.PaginatedList( - github.UserKey.UserKey, self._requester, f"{self.url}/keys", None - ) + return github.PaginatedList.PaginatedList(github.UserKey.UserKey, self._requester, f"{self.url}/keys", None) def get_orgs(self): """ @@ -540,12 +528,8 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/repos/{self.login}/{name}" - ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/repos/{self.login}/{name}") + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos( self, @@ -562,9 +546,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): """ assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction url_parameters = dict() if type is not github.GithubObject.NotSet: url_parameters["type"] = type @@ -616,9 +598,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(following, github.NamedUser.NamedUser), following - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/following/{following._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/following/{following._identity}") return status == 204 @property @@ -631,17 +611,11 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :param org: string or :class:`github.Organization.Organization` :rtype: :class:`github.Membership.Membership` """ - assert isinstance(org, str) or isinstance( - org, github.Organization.Organization - ), org + assert isinstance(org, str) or isinstance(org, github.Organization.Organization), org if isinstance(org, github.Organization.Organization): org = org.login - headers, data = self._requester.requestJsonAndCheck( - "GET", f"/orgs/{org}/memberships/{self.login}" - ) - return github.Membership.Membership( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"/orgs/{org}/memberships/{self.login}") + return github.Membership.Membership(self._requester, headers, data, completed=True) def _initAttributes(self): self._avatar_url = github.GithubObject.NotSet @@ -730,13 +704,9 @@ class NamedUser(github.GithubObject.CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "invitation_teams_url" in attributes: # pragma no branch - self._invitation_teams_url = self._makeStringAttribute( - attributes["invitation_teams_url"] - ) + self._invitation_teams_url = self._makeStringAttribute(attributes["invitation_teams_url"]) if "inviter" in attributes: # pragma no branch - self._inviter = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["inviter"] - ) + self._inviter = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["inviter"]) if "location" in attributes: # pragma no branch self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch @@ -746,17 +716,11 @@ class NamedUser(github.GithubObject.CompletableGithubObject): if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "organizations_url" in attributes: # pragma no branch - self._organizations_url = self._makeStringAttribute( - attributes["organizations_url"] - ) + self._organizations_url = self._makeStringAttribute(attributes["organizations_url"]) if "owned_private_repos" in attributes: # pragma no branch - self._owned_private_repos = self._makeIntAttribute( - attributes["owned_private_repos"] - ) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "permissions" in attributes: # pragma no branch - self._permissions = self._makeClassAttribute( - github.Permissions.Permissions, attributes["permissions"] - ) + self._permissions = self._makeClassAttribute(github.Permissions.Permissions, attributes["permissions"]) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch @@ -766,9 +730,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch - self._received_events_url = self._makeStringAttribute( - attributes["received_events_url"] - ) + self._received_events_url = self._makeStringAttribute(attributes["received_events_url"]) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "role" in attributes: # pragma no branch @@ -778,21 +740,15 @@ class NamedUser(github.GithubObject.CompletableGithubObject): if "starred_url" in attributes: # pragma no branch self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch - self._subscriptions_url = self._makeStringAttribute( - attributes["subscriptions_url"] - ) + self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"]) if "suspended_at" in attributes: # pragma no branch self._suspended_at = self._makeDatetimeAttribute(attributes["suspended_at"]) if "team_count" in attributes: self._team_count = self._makeIntAttribute(attributes["team_count"]) if "total_private_repos" in attributes: # pragma no branch - self._total_private_repos = self._makeIntAttribute( - attributes["total_private_repos"] - ) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "twitter_username" in attributes: # pragma no branch - self._twitter_username = self._makeStringAttribute( - attributes["twitter_username"] - ) + self._twitter_username = self._makeStringAttribute(attributes["twitter_username"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch diff --git a/github/NamedUser.pyi b/github/NamedUser.pyi index 34062950..4b514058 100644 --- a/github/NamedUser.pyi +++ b/github/NamedUser.pyi @@ -52,9 +52,7 @@ class NamedUser(CompletableGithubObject): def get_events(self) -> PaginatedList[Event]: ... def get_followers(self) -> PaginatedList[NamedUser]: ... def get_following(self) -> PaginatedList[NamedUser]: ... - def get_gists( - self, since: Union[_NotSetType, datetime] = ... - ) -> PaginatedList[Gist]: ... + def get_gists(self, since: Union[_NotSetType, datetime] = ...) -> PaginatedList[Gist]: ... def get_keys(self) -> PaginatedList[UserKey]: ... def get_organization_membership(self, org: int) -> Membership: ... def get_orgs(self) -> PaginatedList[Organization]: ... diff --git a/github/Notification.py b/github/Notification.py index 8ef0f04e..8dbc3b35 100644 --- a/github/Notification.py +++ b/github/Notification.py @@ -126,9 +126,7 @@ class Notification(github.GithubObject.CompletableGithubObject): :type: :class:github.PullRequest.PullRequest """ headers, data = self._requester.requestJsonAndCheck("GET", self.subject.url) - return github.PullRequest.PullRequest( - self._requester, headers, data, completed=True - ) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def get_issue(self): """ @@ -153,9 +151,7 @@ class Notification(github.GithubObject.CompletableGithubObject): if "last_read_at" in attributes: # pragma no branch self._last_read_at = self._makeDatetimeAttribute(attributes["last_read_at"]) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "subject" in attributes: # pragma no branch self._subject = self._makeClassAttribute( github.NotificationSubject.NotificationSubject, attributes["subject"] @@ -163,9 +159,7 @@ class Notification(github.GithubObject.CompletableGithubObject): if "reason" in attributes: # pragma no branch self._reason = self._makeStringAttribute(attributes["reason"]) if "subscription_url" in attributes: # pragma no branch - self._subscription_url = self._makeStringAttribute( - attributes["subscription_url"] - ) + self._subscription_url = self._makeStringAttribute(attributes["subscription_url"]) if "unread" in attributes: # pragma no branch self._unread = self._makeBoolAttribute(attributes["unread"]) if "updated_at" in attributes: # pragma no branch diff --git a/github/NotificationSubject.py b/github/NotificationSubject.py index 59343303..962f5204 100644 --- a/github/NotificationSubject.py +++ b/github/NotificationSubject.py @@ -66,8 +66,6 @@ class NotificationSubject(NonCompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "latest_comment_url" in attributes: # pragma no branch - self._latest_comment_url = self._makeStringAttribute( - attributes["latest_comment_url"] - ) + self._latest_comment_url = self._makeStringAttribute(attributes["latest_comment_url"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) diff --git a/github/Organization.py b/github/Organization.py index fc682966..a50b2cc5 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -424,12 +424,8 @@ class Organization(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(repo, github.Repository.Repository), repo - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert private is github.GithubObject.NotSet or isinstance(private, bool), private post_parameters = { "name": name, "owner": self.login, @@ -444,9 +440,7 @@ class Organization(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": "application/vnd.github.v3+json"}, ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_hook( self, @@ -465,9 +459,7 @@ class Organization(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all( - isinstance(element, str) for element in events - ), events + assert events is github.GithubObject.NotSet or all(isinstance(element, str) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -477,9 +469,7 @@ class Organization(github.GithubObject.CompletableGithubObject): post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/hooks", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/hooks", input=post_parameters) return github.Hook.Hook(self._requester, headers, data, completed=True) def create_project(self, name, body=github.GithubObject.NotSet): @@ -545,39 +535,17 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert homepage is github.GithubObject.NotSet or isinstance( - homepage, str - ), homepage - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private - assert visibility is github.GithubObject.NotSet or isinstance( - visibility, str - ), visibility - assert has_issues is github.GithubObject.NotSet or isinstance( - has_issues, bool - ), has_issues - assert has_wiki is github.GithubObject.NotSet or isinstance( - has_wiki, bool - ), has_wiki - assert has_downloads is github.GithubObject.NotSet or isinstance( - has_downloads, bool - ), has_downloads - assert has_projects is github.GithubObject.NotSet or isinstance( - has_projects, bool - ), has_projects - assert team_id is github.GithubObject.NotSet or isinstance( - team_id, int - ), team_id - assert auto_init is github.GithubObject.NotSet or isinstance( - auto_init, bool - ), auto_init - assert license_template is github.GithubObject.NotSet or isinstance( - license_template, str - ), license_template + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, str), homepage + assert private is github.GithubObject.NotSet or isinstance(private, bool), private + assert visibility is github.GithubObject.NotSet or isinstance(visibility, str), visibility + assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues + assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki + assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads + assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects + assert team_id is github.GithubObject.NotSet or isinstance(team_id, int), team_id + assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init + assert license_template is github.GithubObject.NotSet or isinstance(license_template, str), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance( gitignore_template, str ), gitignore_template @@ -639,18 +607,14 @@ class Organization(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": Consts.repoVisibilityPreview}, ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_secret( self, secret_name, unencrypted_value, visibility="all", - selected_repositories: github.GithubObject.Opt[ - list[github.Repository.Repository] - ] = github.GithubObject.NotSet, + selected_repositories: github.GithubObject.Opt[list[github.Repository.Repository]] = github.GithubObject.NotSet, ): """ :calls: `PUT /orgs/{org}/actions/secrets/{secret_name} `_ @@ -665,8 +629,7 @@ class Organization(github.GithubObject.CompletableGithubObject): assert isinstance(visibility, str), visibility if visibility == "selected": assert isinstance(selected_repositories, list) and all( - isinstance(element, github.Repository.Repository) - for element in selected_repositories + isinstance(element, github.Repository.Repository) for element in selected_repositories ), selected_repositories else: assert selected_repositories is github.GithubObject.NotSet @@ -679,9 +642,7 @@ class Organization(github.GithubObject.CompletableGithubObject): "visibility": visibility, } if selected_repositories is not github.GithubObject.NotSet: - put_parameters["selected_repository_ids"] = [ - element.id for element in selected_repositories - ] + put_parameters["selected_repository_ids"] = [element.id for element in selected_repositories] status, headers, data = self._requester.requestJson( "PUT", f"{self.url}/actions/secrets/{secret_name}", input=put_parameters @@ -709,31 +670,21 @@ class Organization(github.GithubObject.CompletableGithubObject): assert repo_names is github.GithubObject.NotSet or all( isinstance(element, github.Repository.Repository) for element in repo_names ), repo_names - assert permission is github.GithubObject.NotSet or isinstance( - permission, str - ), permission - assert privacy is github.GithubObject.NotSet or isinstance( - privacy, str - ), privacy - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert permission is github.GithubObject.NotSet or isinstance(permission, str), permission + assert privacy is github.GithubObject.NotSet or isinstance(privacy, str), privacy + assert description is github.GithubObject.NotSet or isinstance(description, str), description post_parameters = { "name": name, } if repo_names is not github.GithubObject.NotSet: - post_parameters["repo_names"] = [ - element._identity for element in repo_names - ] + post_parameters["repo_names"] = [element._identity for element in repo_names] if permission is not github.GithubObject.NotSet: post_parameters["permission"] = permission if privacy is not github.GithubObject.NotSet: post_parameters["privacy"] = privacy if description is not github.GithubObject.NotSet: post_parameters["description"] = description - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/teams", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/teams", input=post_parameters) return github.Team.Team(self._requester, headers, data, completed=True) def create_variable( @@ -741,9 +692,7 @@ class Organization(github.GithubObject.CompletableGithubObject): variable_name: str, value: str, visibility: str = "all", - selected_repositories: github.GithubObject.Opt[ - list[github.Repository.Repository] - ] = github.GithubObject.NotSet, + selected_repositories: github.GithubObject.Opt[list[github.Repository.Repository]] = github.GithubObject.NotSet, ) -> bool: """ :calls: `PUT /orgs/{org}/actions/variables/ `_ @@ -758,8 +707,7 @@ class Organization(github.GithubObject.CompletableGithubObject): assert isinstance(visibility, str), visibility if visibility == "selected": assert isinstance(selected_repositories, list) and all( - isinstance(element, github.Repository.Repository) - for element in selected_repositories + isinstance(element, github.Repository.Repository) for element in selected_repositories ), selected_repositories else: assert selected_repositories is github.GithubObject.NotSet @@ -770,9 +718,7 @@ class Organization(github.GithubObject.CompletableGithubObject): "visibility": visibility, } if selected_repositories is not github.GithubObject.NotSet: - post_parameters["selected_repository_ids"] = [ - element.id for element in selected_repositories - ] + post_parameters["selected_repository_ids"] = [element.id for element in selected_repositories] status, headers, data = self._requester.requestJson( "POST", f"{self.url}/actions/variables", input=post_parameters ) @@ -785,9 +731,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: None` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/hooks/{id}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/hooks/{id}") def delete_secret(self, secret_name): """ @@ -796,9 +740,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(secret_name, str), secret_name - status, headers, data = self._requester.requestJson( - "DELETE", f"{self.url}/actions/secrets/{secret_name}" - ) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/actions/secrets/{secret_name}") return status == 204 def delete_variable(self, variable_name: str) -> bool: @@ -808,9 +750,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(variable_name, str), variable_name - status, headers, data = self._requester.requestJson( - "DELETE", f"{self.url}/actions/variables/{variable_name}" - ) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/actions/variables/{variable_name}") return status == 204 def edit( @@ -834,20 +774,12 @@ class Organization(github.GithubObject.CompletableGithubObject): :param name: string :rtype: None """ - assert billing_email is github.GithubObject.NotSet or isinstance( - billing_email, str - ), billing_email + assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, str), billing_email assert blog is github.GithubObject.NotSet or isinstance(blog, str), blog - assert company is github.GithubObject.NotSet or isinstance( - company, str - ), company - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert company is github.GithubObject.NotSet or isinstance(company, str), company + assert description is github.GithubObject.NotSet or isinstance(description, str), description assert email is github.GithubObject.NotSet or isinstance(email, str), email - assert location is github.GithubObject.NotSet or isinstance( - location, str - ), location + assert location is github.GithubObject.NotSet or isinstance(location, str), location assert name is github.GithubObject.NotSet or isinstance(name, str), name post_parameters = dict() if billing_email is not github.GithubObject.NotSet: @@ -864,9 +796,7 @@ class Organization(github.GithubObject.CompletableGithubObject): post_parameters["location"] = location if name is not github.GithubObject.NotSet: post_parameters["name"] = name - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def edit_hook( @@ -889,9 +819,7 @@ class Organization(github.GithubObject.CompletableGithubObject): assert isinstance(id, int), id assert isinstance(name, str), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all( - isinstance(element, str) for element in events - ), events + assert events is github.GithubObject.NotSet or all(isinstance(element, str) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -901,9 +829,7 @@ class Organization(github.GithubObject.CompletableGithubObject): post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active - headers, data = self._requester.requestJsonAndCheck( - "PATCH", f"{self.url}/hooks/{id}", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", f"{self.url}/hooks/{id}", input=post_parameters) return github.Hook.Hook(self._requester, headers, data, completed=True) def update_variable( @@ -911,9 +837,7 @@ class Organization(github.GithubObject.CompletableGithubObject): variable_name: str, value: str, visibility: str = "all", - selected_repositories: github.GithubObject.Opt[ - list[github.Repository.Repository] - ] = github.GithubObject.NotSet, + selected_repositories: github.GithubObject.Opt[list[github.Repository.Repository]] = github.GithubObject.NotSet, ) -> bool: """ :calls: `PATCH /orgs/{org}/actions/variables/{variable_name} `_ @@ -928,8 +852,7 @@ class Organization(github.GithubObject.CompletableGithubObject): assert isinstance(visibility, str), visibility if visibility == "selected": assert isinstance(selected_repositories, list) and all( - isinstance(element, github.Repository.Repository) - for element in selected_repositories + isinstance(element, github.Repository.Repository) for element in selected_repositories ), selected_repositories else: assert selected_repositories is github.GithubObject.NotSet @@ -940,9 +863,7 @@ class Organization(github.GithubObject.CompletableGithubObject): "visibility": visibility, } if selected_repositories is not github.GithubObject.NotSet: - patch_parameters["selected_repository_ids"] = [ - element.id for element in selected_repositories - ] + patch_parameters["selected_repository_ids"] = [element.id for element in selected_repositories] status, headers, data = self._requester.requestJson( "PATCH", @@ -956,9 +877,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :calls: `GET /orgs/{org}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ - return github.PaginatedList.PaginatedList( - github.Event.Event, self._requester, f"{self.url}/events", None - ) + return github.PaginatedList.PaginatedList(github.Event.Event, self._requester, f"{self.url}/events", None) def get_hook(self, id): """ @@ -967,9 +886,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Hook.Hook` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/hooks/{id}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/hooks/{id}") return github.Hook.Hook(self._requester, headers, data, completed=True) def get_hooks(self): @@ -977,13 +894,9 @@ class Organization(github.GithubObject.CompletableGithubObject): :calls: `GET /orgs/{owner}/hooks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Hook.Hook` """ - return github.PaginatedList.PaginatedList( - github.Hook.Hook, self._requester, f"{self.url}/hooks", None - ) + return github.PaginatedList.PaginatedList(github.Hook.Hook, self._requester, f"{self.url}/hooks", None) - def get_hook_delivery( - self, hook_id: int, delivery_id: int - ) -> github.HookDelivery.HookDelivery: + def get_hook_delivery(self, hook_id: int, delivery_id: int) -> github.HookDelivery.HookDelivery: """ :calls: `GET /orgs/{owner}/hooks/{hook_id}/deliveries/{delivery_id} `_ :param hook_id: integer @@ -995,9 +908,7 @@ class Organization(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/hooks/{hook_id}/deliveries/{delivery_id}" ) - return github.HookDelivery.HookDelivery( - self._requester, headers, data, completed=True - ) + return github.HookDelivery.HookDelivery(self._requester, headers, data, completed=True) def get_hook_deliveries( self, hook_id: int @@ -1041,9 +952,7 @@ class Organization(github.GithubObject.CompletableGithubObject): isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -1062,18 +971,14 @@ class Organization(github.GithubObject.CompletableGithubObject): github.Issue.Issue, self._requester, f"{self.url}/issues", url_parameters ) - def get_members( - self, filter_=github.GithubObject.NotSet, role=github.GithubObject.NotSet - ): + def get_members(self, filter_=github.GithubObject.NotSet, role=github.GithubObject.NotSet): """ :calls: `GET /orgs/{org}/members `_ :param filter_: string :param role: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - assert filter_ is github.GithubObject.NotSet or isinstance( - filter_, str - ), filter_ + assert filter_ is github.GithubObject.NotSet or isinstance(filter_, str), filter_ assert role is github.GithubObject.NotSet or isinstance(role, str), role url_parameters = {} @@ -1125,9 +1030,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param filter_: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - assert filter_ is github.GithubObject.NotSet or isinstance( - filter_, str - ), filter_ + assert filter_ is github.GithubObject.NotSet or isinstance(filter_, str), filter_ url_parameters = {} if filter_ is not github.GithubObject.NotSet: @@ -1166,12 +1069,8 @@ class Organization(github.GithubObject.CompletableGithubObject): :calls: `GET /orgs/{org}/actions/secrets/public-key `_ :rtype: :class:`github.PublicKey.PublicKey` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/secrets/public-key" - ) - return github.PublicKey.PublicKey( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/secrets/public-key") + return github.PublicKey.PublicKey(self._requester, headers, data, completed=True) def get_repo(self, name): """ @@ -1185,9 +1084,7 @@ class Organization(github.GithubObject.CompletableGithubObject): f"/repos/{self.login}/{name}", headers={"Accept": Consts.repoVisibilityPreview}, ) - return github.Repository.Repository( - self._requester, headers, data, completed=True - ) + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos( self, @@ -1204,9 +1101,7 @@ class Organization(github.GithubObject.CompletableGithubObject): """ assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction url_parameters = dict() if type is not github.GithubObject.NotSet: @@ -1240,9 +1135,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Team.Team` """ assert isinstance(slug, str), slug - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/teams/{slug}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/teams/{slug}") return github.Team.Team(self._requester, headers, data, completed=True) def get_teams(self): @@ -1250,9 +1143,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :calls: `GET /orgs/{org}/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ - return github.PaginatedList.PaginatedList( - github.Team.Team, self._requester, f"{self.url}/teams", None - ) + return github.PaginatedList.PaginatedList(github.Team.Team, self._requester, f"{self.url}/teams", None) def invitations(self): """ @@ -1282,9 +1173,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param teams: array of :class:`github.Team.Team` :rtype: None """ - assert user is github.GithubObject.NotSet or isinstance( - user, github.NamedUser.NamedUser - ), user + assert user is github.GithubObject.NotSet or isinstance(user, github.NamedUser.NamedUser), user assert email is github.GithubObject.NotSet or isinstance(email, str), email assert (email is github.GithubObject.NotSet) ^ ( user is github.GithubObject.NotSet @@ -1315,9 +1204,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(invitee, github.NamedUser.NamedUser), invitee - status, headers, data = self._requester.requestJson( - "DELETE", f"{self.url}/invitations/{invitee.id}" - ) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/invitations/{invitee.id}") return status == 204 def has_in_members(self, member): @@ -1327,13 +1214,9 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(member, github.NamedUser.NamedUser), member - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/members/{member._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/members/{member._identity}") if status == 302: - status, headers, data = self._requester.requestJson( - "GET", headers["location"] - ) + status, headers, data = self._requester.requestJson("GET", headers["location"]) return status == 204 def has_in_public_members(self, public_member): @@ -1355,9 +1238,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/memberships/{member._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/memberships/{member._identity}") def remove_from_members(self, member): """ @@ -1366,9 +1247,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/members/{member._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/members/{member._identity}") def remove_from_public_members(self, public_member): """ @@ -1396,9 +1275,7 @@ class Organization(github.GithubObject.CompletableGithubObject): """ assert isinstance(repos, (list, tuple)), repos assert all(isinstance(repo, str) for repo in repos), repos - assert lock_repositories is github.GithubObject.NotSet or isinstance( - lock_repositories, bool - ), lock_repositories + assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance( exclude_attachments, bool ), exclude_attachments @@ -1413,9 +1290,7 @@ class Organization(github.GithubObject.CompletableGithubObject): input=post_parameters, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) - return github.Migration.Migration( - self._requester, headers, data, completed=True - ) + return github.Migration.Migration(self._requester, headers, data, completed=True) def get_migrations(self): """ @@ -1498,9 +1373,7 @@ class Organization(github.GithubObject.CompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "default_repository_permission" in attributes: # pragma no branch - self._default_repository_permission = self._makeStringAttribute( - attributes["default_repository_permission"] - ) + self._default_repository_permission = self._makeStringAttribute(attributes["default_repository_permission"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "disk_usage" in attributes: # pragma no branch @@ -1516,13 +1389,9 @@ class Organization(github.GithubObject.CompletableGithubObject): if "gravatar_id" in attributes: # pragma no branch self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "has_organization_projects" in attributes: # pragma no branch - self._has_organization_projects = self._makeBoolAttribute( - attributes["has_organization_projects"] - ) + self._has_organization_projects = self._makeBoolAttribute(attributes["has_organization_projects"]) if "has_repository_projects" in attributes: # pragma no branch - self._has_repository_projects = self._makeBoolAttribute( - attributes["has_repository_projects"] - ) + self._has_repository_projects = self._makeBoolAttribute(attributes["has_repository_projects"]) if "hooks_url" in attributes: # pragma no branch self._hooks_url = self._makeStringAttribute(attributes["hooks_url"]) if "html_url" in attributes: # pragma no branch @@ -1544,9 +1413,7 @@ class Organization(github.GithubObject.CompletableGithubObject): if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "owned_private_repos" in attributes: # pragma no branch - self._owned_private_repos = self._makeIntAttribute( - attributes["owned_private_repos"] - ) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch @@ -1554,21 +1421,15 @@ class Organization(github.GithubObject.CompletableGithubObject): if "public_gists" in attributes: # pragma no branch self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_members_url" in attributes: # pragma no branch - self._public_members_url = self._makeStringAttribute( - attributes["public_members_url"] - ) + self._public_members_url = self._makeStringAttribute(attributes["public_members_url"]) if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "total_private_repos" in attributes: # pragma no branch - self._total_private_repos = self._makeIntAttribute( - attributes["total_private_repos"] - ) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "two_factor_requirement_enabled" in attributes: # pragma no branch - self._two_factor_requirement_enabled = self._makeBoolAttribute( - attributes["two_factor_requirement_enabled"] - ) + self._two_factor_requirement_enabled = self._makeBoolAttribute(attributes["two_factor_requirement_enabled"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch diff --git a/github/Organization.pyi b/github/Organization.pyi index b392df42..8822c4ff 100644 --- a/github/Organization.pyi +++ b/github/Organization.pyi @@ -20,9 +20,7 @@ class Organization(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - def add_to_members( - self, member: NamedUser, role: Union[_NotSetType, str] = ... - ) -> None: ... + def add_to_members(self, member: NamedUser, role: Union[_NotSetType, str] = ...) -> None: ... def add_to_public_members(self, public_member: NamedUser) -> None: ... @property def avatar_url(self) -> str: ... @@ -156,12 +154,8 @@ class Organization(CompletableGithubObject): ) -> PaginatedList[NamedUser]: ... def get_migrations(self) -> PaginatedList[Migration]: ... def get_installations(self) -> PaginatedList[Installation]: ... - def get_outside_collaborators( - self, filter_: Union[str, _NotSetType] = ... - ) -> PaginatedList[NamedUser]: ... - def get_projects( - self, state: Union[_NotSetType, str] = ... - ) -> PaginatedList[Project]: ... + def get_outside_collaborators(self, filter_: Union[str, _NotSetType] = ...) -> PaginatedList[NamedUser]: ... + def get_projects(self, state: Union[_NotSetType, str] = ...) -> PaginatedList[Project]: ... def get_public_key(self) -> PublicKey: ... def get_public_members(self) -> PaginatedList[NamedUser]: ... def get_repo(self, name: str) -> Repository: ... diff --git a/github/PaginatedList.py b/github/PaginatedList.py index af9fd1a9..0a22cb62 100644 --- a/github/PaginatedList.py +++ b/github/PaginatedList.py @@ -263,7 +263,4 @@ class PaginatedList(PaginatedListBase[T]): self.__totalCount = data.get("total_count") data = data[self.__list_item] - return [ - self.__contentClass(self.__requester, headers, element, completed=False) - for element in data - ] + return [self.__contentClass(self.__requester, headers, element, completed=False) for element in data] diff --git a/github/Project.py b/github/Project.py index f0da8b4e..f683776a 100644 --- a/github/Project.py +++ b/github/Project.py @@ -170,9 +170,7 @@ class Project(github.GithubObject.CompletableGithubObject): assert organization_permission is github.GithubObject.NotSet or isinstance( organization_permission, str ), organization_permission - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private + assert private is github.GithubObject.NotSet or isinstance(private, bool), private patch_parameters = dict() if name is not github.GithubObject.NotSet: patch_parameters["name"] = name @@ -217,9 +215,7 @@ class Project(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/columns", headers=import_header, input=post_parameters ) - return github.ProjectColumn.ProjectColumn( - self._requester, headers, data, completed=True - ) + return github.ProjectColumn.ProjectColumn(self._requester, headers, data, completed=True) def _initAttributes(self): self._body = github.GithubObject.NotSet @@ -244,9 +240,7 @@ class Project(github.GithubObject.CompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch diff --git a/github/ProjectCard.py b/github/ProjectCard.py index 56897991..e4551bd8 100644 --- a/github/ProjectCard.py +++ b/github/ProjectCard.py @@ -118,9 +118,7 @@ class ProjectCard(github.GithubObject.CompletableGithubObject): :param content_type: string, optional :rtype: :class:`github.PullRequest.PullRequest` or :class:`github.Issue.Issue` """ - assert content_type is github.GithubObject.NotSet or isinstance( - content_type, str - ), content_type + assert content_type is github.GithubObject.NotSet or isinstance(content_type, str), content_type if self.content_url is None: return None @@ -143,14 +141,10 @@ class ProjectCard(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(position, str), position - assert isinstance(column, github.ProjectColumn.ProjectColumn) or isinstance( - column, int - ), column + assert isinstance(column, github.ProjectColumn.ProjectColumn) or isinstance(column, int), column post_parameters = { "position": position, - "column_id": column.id - if isinstance(column, github.ProjectColumn.ProjectColumn) - else column, + "column_id": column.id if isinstance(column, github.ProjectColumn.ProjectColumn) else column, } status, _, _ = self._requester.requestJson( "POST", @@ -172,9 +166,7 @@ class ProjectCard(github.GithubObject.CompletableGithubObject): ) return status == 204 - def edit( - self, note=github.GithubObject.NotSet, archived=github.GithubObject.NotSet - ): + def edit(self, note=github.GithubObject.NotSet, archived=github.GithubObject.NotSet): """ :calls: `PATCH /projects/columns/cards/{card_id} `_ :param note: string @@ -182,9 +174,7 @@ class ProjectCard(github.GithubObject.CompletableGithubObject): :rtype: None """ assert note is github.GithubObject.NotSet or isinstance(note, str), note - assert archived is github.GithubObject.NotSet or isinstance( - archived, bool - ), archived + assert archived is github.GithubObject.NotSet or isinstance(archived, bool), archived patch_parameters = dict() if note is not github.GithubObject.NotSet: patch_parameters["note"] = note @@ -220,9 +210,7 @@ class ProjectCard(github.GithubObject.CompletableGithubObject): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - self._creator = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["creator"] - ) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "node_id" in attributes: # pragma no branch diff --git a/github/ProjectCard.pyi b/github/ProjectCard.pyi index e1644ea8..e9f14dc0 100644 --- a/github/ProjectCard.pyi +++ b/github/ProjectCard.pyi @@ -20,12 +20,8 @@ class ProjectCard(CompletableGithubObject): def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... - def get_content( - self, content_type: Union[_NotSetType, str] = ... - ) -> Optional[Union[PullRequest, Issue]]: ... - def edit( - self, note=Union[_NotSetType, str], archived=Union[_NotSetType, bool] - ) -> None: ... + def get_content(self, content_type: Union[_NotSetType, str] = ...) -> Optional[Union[PullRequest, Issue]]: ... + def edit(self, note=Union[_NotSetType, str], archived=Union[_NotSetType, bool]) -> None: ... @property def id(self) -> int: ... @property diff --git a/github/ProjectColumn.py b/github/ProjectColumn.py index 781f72c0..fa8e1e2e 100644 --- a/github/ProjectColumn.py +++ b/github/ProjectColumn.py @@ -97,9 +97,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard` :param archived_state: string """ - assert archived_state is github.GithubObject.NotSet or isinstance( - archived_state, str - ), archived_state + assert archived_state is github.GithubObject.NotSet or isinstance(archived_state, str), archived_state url_parameters = dict() if archived_state is not github.GithubObject.NotSet: @@ -141,9 +139,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/cards", headers=import_header, input=post_parameters ) - return github.ProjectCard.ProjectCard( - self._requester, headers, data, completed=True - ) + return github.ProjectCard.ProjectCard(self._requester, headers, data, completed=True) def move(self, position): """ diff --git a/github/ProjectColumn.pyi b/github/ProjectColumn.pyi index a30d11df..e280b18f 100644 --- a/github/ProjectColumn.pyi +++ b/github/ProjectColumn.pyi @@ -19,9 +19,7 @@ class ProjectColumn(CompletableGithubObject): ) -> ProjectCard: ... @property def created_at(self) -> datetime: ... - def get_cards( - self, archived_state: Union[_NotSetType, str] = ... - ) -> PaginatedList[ProjectCard]: ... + def get_cards(self, archived_state: Union[_NotSetType, str] = ...) -> PaginatedList[ProjectCard]: ... @property def id(self) -> int: ... @property diff --git a/github/PullRequest.py b/github/PullRequest.py index c966baaf..a1ea383f 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -64,9 +64,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"number": self._number.value, "title": self._title.value} - ) + return self.get__repr__({"number": self._number.value, "title": self._title.value}) @property def additions(self): @@ -442,16 +440,12 @@ class PullRequest(github.GithubObject.CompletableGithubObject): assert isinstance(path, str), path assert line is github.GithubObject.NotSet or isinstance(line, int), line assert side is github.GithubObject.NotSet or side in ["LEFT", "RIGHT"], side - assert start_line is github.GithubObject.NotSet or isinstance( - start_line, int - ), start_line + assert start_line is github.GithubObject.NotSet or isinstance(start_line, int), start_line assert start_side is github.GithubObject.NotSet or start_side in [ "LEFT", "RIGHT", ], start_side - assert in_reply_to is github.GithubObject.NotSet or isinstance( - in_reply_to, int - ), in_reply_to + assert in_reply_to is github.GithubObject.NotSet or isinstance(in_reply_to, int), in_reply_to assert subject_type is github.GithubObject.NotSet or subject_type in [ "LINE", "FILE", @@ -478,12 +472,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): post_parameters["in_reply_to"] = in_reply_to if subject_type is not github.GithubObject.NotSet: post_parameters["subject_type"] = subject_type - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/comments", input=post_parameters - ) - return github.PullRequestComment.PullRequestComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/comments", input=post_parameters) + return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True) def create_review_comment_reply(self, comment_id, body): """ @@ -500,9 +490,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): f"{self.url}/comments/{comment_id}/replies", input=post_parameters, ) - return github.PullRequestComment.PullRequestComment( - self._requester, headers, data, completed=True - ) + return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True) def create_issue_comment(self, body): """ @@ -514,12 +502,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.issue_url}/comments", input=post_parameters - ) - return github.IssueComment.IssueComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.issue_url}/comments", input=post_parameters) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def create_review( self, @@ -536,32 +520,22 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param comments: list :rtype: :class:`github.PullRequestReview.PullRequestReview` """ - assert commit is github.GithubObject.NotSet or isinstance( - commit, github.Commit.Commit - ), commit + assert commit is github.GithubObject.NotSet or isinstance(commit, github.Commit.Commit), commit assert body is github.GithubObject.NotSet or isinstance(body, str), body assert event is github.GithubObject.NotSet or isinstance(event, str), event - assert comments is github.GithubObject.NotSet or isinstance( - comments, list - ), comments + assert comments is github.GithubObject.NotSet or isinstance(comments, list), comments post_parameters = dict() if commit is not github.GithubObject.NotSet: post_parameters["commit_id"] = commit.sha if body is not github.GithubObject.NotSet: post_parameters["body"] = body - post_parameters["event"] = ( - "COMMENT" if event == github.GithubObject.NotSet else event - ) + post_parameters["event"] = "COMMENT" if event == github.GithubObject.NotSet else event if comments is github.GithubObject.NotSet: post_parameters["comments"] = [] else: post_parameters["comments"] = comments - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/reviews", input=post_parameters - ) - return github.PullRequestReview.PullRequestReview( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/reviews", input=post_parameters) + return github.PullRequestReview.PullRequestReview(self._requester, headers, data, completed=True) def create_review_request( self, @@ -579,9 +553,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): assert all(isinstance(element, str) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: - assert all( - isinstance(element, str) for element in team_reviewers - ), team_reviewers + assert all(isinstance(element, str) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/requested_reviewers", input=post_parameters @@ -603,9 +575,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): assert all(isinstance(element, str) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: - assert all( - isinstance(element, str) for element in team_reviewers - ), team_reviewers + assert all(isinstance(element, str) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/requested_reviewers", input=post_parameters @@ -646,9 +616,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): post_parameters["base"] = base if maintainer_can_modify is not github.GithubObject.NotSet: post_parameters["maintainer_can_modify"] = maintainer_can_modify - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_comment(self, id): @@ -666,12 +634,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PullRequestComment.PullRequestComment` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self._parentUrl(self.url)}/comments/{id}" - ) - return github.PullRequestComment.PullRequestComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self._parentUrl(self.url)}/comments/{id}") + return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True) def get_comments( self, @@ -706,9 +670,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if sort is not github.GithubObject.NotSet: @@ -743,18 +705,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/pulls/{number}/commits `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ - return github.PaginatedList.PaginatedList( - github.Commit.Commit, self._requester, f"{self.url}/commits", None - ) + return github.PaginatedList.PaginatedList(github.Commit.Commit, self._requester, f"{self.url}/commits", None) def get_files(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/files `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.File.File` """ - return github.PaginatedList.PaginatedList( - github.File.File, self._requester, f"{self.url}/files", None - ) + return github.PaginatedList.PaginatedList(github.File.File, self._requester, f"{self.url}/files", None) def get_issue_comment(self, id): """ @@ -763,12 +721,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self._parentUrl(self.issue_url)}/comments/{id}" - ) - return github.IssueComment.IssueComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self._parentUrl(self.issue_url)}/comments/{id}") + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def get_issue_comments(self): """ @@ -806,9 +760,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): "GET", f"{self.url}/reviews/{id}", ) - return github.PullRequestReview.PullRequestReview( - self._requester, headers, data, completed=True - ) + return github.PullRequestReview.PullRequestReview(self._requester, headers, data, completed=True) def get_reviews(self): """ @@ -849,9 +801,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ - return github.PaginatedList.PaginatedList( - github.Label.Label, self._requester, f"{self.issue_url}/labels", None - ) + return github.PaginatedList.PaginatedList(github.Label.Label, self._requester, f"{self.issue_url}/labels", None) def add_to_labels(self, *labels): """ @@ -859,25 +809,16 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param label: :class:`github.Label.Label` or string :rtype: None """ - assert all( - isinstance(element, (github.Label.Label, str)) for element in labels - ), labels - post_parameters = [ - label.name if isinstance(label, github.Label.Label) else label - for label in labels - ] - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.issue_url}/labels", input=post_parameters - ) + assert all(isinstance(element, (github.Label.Label, str)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.issue_url}/labels", input=post_parameters) def delete_labels(self): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: None """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.issue_url}/labels" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.issue_url}/labels") def remove_from_labels(self, label): """ @@ -890,9 +831,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): label = label._identity else: label = urllib.parse.quote(label) - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.issue_url}/labels/{label}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.issue_url}/labels/{label}") def set_labels(self, *labels): """ @@ -900,16 +839,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param labels: list of :class:`github.Label.Label` or strings :rtype: None """ - assert all( - isinstance(element, (github.Label.Label, str)) for element in labels - ), labels - post_parameters = [ - label.name if isinstance(label, github.Label.Label) else label - for label in labels - ] - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.issue_url}/labels", input=post_parameters - ) + assert all(isinstance(element, (github.Label.Label, str)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.issue_url}/labels", input=post_parameters) def is_merged(self): """ @@ -934,15 +866,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` """ - assert commit_message is github.GithubObject.NotSet or isinstance( - commit_message, str - ), commit_message - assert commit_title is github.GithubObject.NotSet or isinstance( - commit_title, str - ), commit_title - assert merge_method is github.GithubObject.NotSet or isinstance( - merge_method, str - ), merge_method + assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, str), commit_message + assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, str), commit_title + assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, str), merge_method assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha post_parameters = dict() if commit_message is not github.GithubObject.NotSet: @@ -953,12 +879,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): post_parameters["merge_method"] = merge_method if sha is not github.GithubObject.NotSet: post_parameters["sha"] = sha - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.url}/merge", input=post_parameters - ) - return github.PullRequestMergeStatus.PullRequestMergeStatus( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/merge", input=post_parameters) + return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, headers, data, completed=True) def add_to_assignees(self, *assignees): """ @@ -966,15 +888,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param assignees: list of :class:`github.NamedUser.NamedUser` or string :rtype: None """ - assert all( - isinstance(element, (github.NamedUser.NamedUser, str)) - for element in assignees - ), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees), assignees post_parameters = { "assignees": [ - assignee.login - if isinstance(assignee, github.NamedUser.NamedUser) - else assignee + assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } @@ -990,15 +907,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param assignees: list of :class:`github.NamedUser.NamedUser` or string :rtype: None """ - assert all( - isinstance(element, (github.NamedUser.NamedUser, str)) - for element in assignees - ), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees), assignees post_parameters = { "assignees": [ - assignee.login - if isinstance(assignee, github.NamedUser.NamedUser) - else assignee + assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } @@ -1014,9 +926,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param expected_head_sha: string :rtype: bool """ - assert expected_head_sha is github.GithubObject.NotSet or isinstance( - expected_head_sha, str - ), expected_head_sha + assert expected_head_sha is github.GithubObject.NotSet or isinstance(expected_head_sha, str), expected_head_sha post_parameters = {} if expected_head_sha is not github.GithubObject.NotSet: post_parameters["expected_head_sha"] = expected_head_sha @@ -1075,26 +985,16 @@ class PullRequest(github.GithubObject.CompletableGithubObject): if "additions" in attributes: # pragma no branch self._additions = self._makeIntAttribute(attributes["additions"]) if "assignee" in attributes: # pragma no branch - self._assignee = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["assignee"] - ) + self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) if "assignees" in attributes: # pragma no branch - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, attributes["assignees"] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, attributes["assignees"]) elif "assignee" in attributes: if attributes["assignee"] is not None: - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, [attributes["assignee"]] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, [attributes["assignee"]]) else: - self._assignees = self._makeListOfClassesAttribute( - github.NamedUser.NamedUser, [] - ) + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, []) if "base" in attributes: # pragma no branch - self._base = self._makeClassAttribute( - github.PullRequestPart.PullRequestPart, attributes["base"] - ) + self._base = self._makeClassAttribute(github.PullRequestPart.PullRequestPart, attributes["base"]) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "changed_files" in attributes: # pragma no branch @@ -1118,9 +1018,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): if "draft" in attributes: # pragma no branch self._draft = self._makeBoolAttribute(attributes["draft"]) if "head" in attributes: # pragma no branch - self._head = self._makeClassAttribute( - github.PullRequestPart.PullRequestPart, attributes["head"] - ) + self._head = self._makeClassAttribute(github.PullRequestPart.PullRequestPart, attributes["head"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch @@ -1128,35 +1026,23 @@ class PullRequest(github.GithubObject.CompletableGithubObject): if "issue_url" in attributes: # pragma no branch self._issue_url = self._makeStringAttribute(attributes["issue_url"]) if "labels" in attributes: # pragma no branch - self._labels = self._makeListOfClassesAttribute( - github.Label.Label, attributes["labels"] - ) + self._labels = self._makeListOfClassesAttribute(github.Label.Label, attributes["labels"]) if "maintainer_can_modify" in attributes: # pragma no branch - self._maintainer_can_modify = self._makeBoolAttribute( - attributes["maintainer_can_modify"] - ) + self._maintainer_can_modify = self._makeBoolAttribute(attributes["maintainer_can_modify"]) if "merge_commit_sha" in attributes: # pragma no branch - self._merge_commit_sha = self._makeStringAttribute( - attributes["merge_commit_sha"] - ) + self._merge_commit_sha = self._makeStringAttribute(attributes["merge_commit_sha"]) if "mergeable" in attributes: # pragma no branch self._mergeable = self._makeBoolAttribute(attributes["mergeable"]) if "mergeable_state" in attributes: # pragma no branch - self._mergeable_state = self._makeStringAttribute( - attributes["mergeable_state"] - ) + self._mergeable_state = self._makeStringAttribute(attributes["mergeable_state"]) if "merged" in attributes: # pragma no branch self._merged = self._makeBoolAttribute(attributes["merged"]) if "merged_at" in attributes: # pragma no branch self._merged_at = self._makeDatetimeAttribute(attributes["merged_at"]) if "merged_by" in attributes: # pragma no branch - self._merged_by = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["merged_by"] - ) + self._merged_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["merged_by"]) if "milestone" in attributes: # pragma no branch - self._milestone = self._makeClassAttribute( - github.Milestone.Milestone, attributes["milestone"] - ) + self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"]) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "patch_url" in attributes: # pragma no branch @@ -1164,17 +1050,11 @@ class PullRequest(github.GithubObject.CompletableGithubObject): if "rebaseable" in attributes: # pragma no branch self._rebaseable = self._makeBoolAttribute(attributes["rebaseable"]) if "review_comment_url" in attributes: # pragma no branch - self._review_comment_url = self._makeStringAttribute( - attributes["review_comment_url"] - ) + self._review_comment_url = self._makeStringAttribute(attributes["review_comment_url"]) if "review_comments" in attributes: # pragma no branch - self._review_comments = self._makeIntAttribute( - attributes["review_comments"] - ) + self._review_comments = self._makeIntAttribute(attributes["review_comments"]) if "review_comments_url" in attributes: # pragma no branch - self._review_comments_url = self._makeStringAttribute( - attributes["review_comments_url"] - ) + self._review_comments_url = self._makeStringAttribute(attributes["review_comments_url"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch @@ -1184,14 +1064,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) if "requested_reviewers" in attributes: self._requested_reviewers = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, attributes["requested_reviewers"] ) if "requested_teams" in attributes: - self._requested_teams = self._makeListOfClassesAttribute( - github.Team.Team, attributes["requested_teams"] - ) + self._requested_teams = self._makeListOfClassesAttribute(github.Team.Team, attributes["requested_teams"]) diff --git a/github/PullRequest.pyi b/github/PullRequest.pyi index 05b6d5b5..4f719958 100644 --- a/github/PullRequest.pyi +++ b/github/PullRequest.pyi @@ -49,9 +49,7 @@ class PullRequest(CompletableGithubObject): def commits(self) -> int: ... @property def commits_url(self) -> str: ... - def create_comment( - self, body: str, commit_id: Commit, path: str, position: int - ) -> PullRequestComment: ... + def create_comment(self, body: str, commit_id: Commit, path: str, position: int) -> PullRequestComment: ... def create_issue_comment(self, body: str) -> IssueComment: ... def create_review( self, @@ -60,9 +58,7 @@ class PullRequest(CompletableGithubObject): event: Union[_NotSetType, str] = ..., comments: Union[_NotSetType, str] = ..., ) -> PullRequestReview: ... - def create_review_comment( - self, body: str, commit_id: Commit, path: str, position: int - ) -> PullRequestComment: ... + def create_review_comment(self, body: str, commit_id: Commit, path: str, position: int) -> PullRequestComment: ... def create_review_request( self, reviewers: Union[_NotSetType, List[str]] = ..., @@ -110,9 +106,7 @@ class PullRequest(CompletableGithubObject): direction: Union[_NotSetType, str] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[PullRequestComment]: ... - def get_single_review_comments( - self, id: int - ) -> PaginatedList[PullRequestComment]: ... + def get_single_review_comments(self, id: int) -> PaginatedList[PullRequestComment]: ... def get_review_requests( self, ) -> Tuple[PaginatedList[NamedUser], PaginatedList[Team]]: ... diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index 58b0103c..d5d213d2 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -184,9 +184,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): post_parameters = { "body": body, } - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_reactions(self): @@ -268,21 +266,15 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): if "in_reply_to_id" in attributes: # pragma no branch self._in_reply_to_id = self._makeIntAttribute(attributes["in_reply_to_id"]) if "original_commit_id" in attributes: # pragma no branch - self._original_commit_id = self._makeStringAttribute( - attributes["original_commit_id"] - ) + self._original_commit_id = self._makeStringAttribute(attributes["original_commit_id"]) if "original_position" in attributes: # pragma no branch - self._original_position = self._makeIntAttribute( - attributes["original_position"] - ) + self._original_position = self._makeIntAttribute(attributes["original_position"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "position" in attributes: # pragma no branch self._position = self._makeIntAttribute(attributes["position"]) if "pull_request_url" in attributes: # pragma no branch - self._pull_request_url = self._makeStringAttribute( - attributes["pull_request_url"] - ) + self._pull_request_url = self._makeStringAttribute(attributes["pull_request_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch @@ -290,6 +282,4 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index 054dbf49..a48a376c 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -81,12 +81,8 @@ class PullRequestPart(NonCompletableGithubObject): if "ref" in attributes: # pragma no branch self._ref = self._makeStringAttribute(attributes["ref"]) if "repo" in attributes: # pragma no branch - self._repo = self._makeClassAttribute( - github.Repository.Repository, attributes["repo"] - ) + self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/PullRequestReview.py b/github/PullRequestReview.py index bd70f68f..01c48ee6 100644 --- a/github/PullRequestReview.py +++ b/github/PullRequestReview.py @@ -110,9 +110,7 @@ class PullRequestReview(github.GithubObject.NonCompletableGithubObject): :calls: `DELETE /repos/:owner/:repo/pulls/:number/reviews/:review_id `_ :rtype: None """ - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.pull_request_url}/reviews/{self.id}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.pull_request_url}/reviews/{self.id}") def _initAttributes(self): self._id = github.GithubObject.NotSet @@ -128,9 +126,7 @@ class PullRequestReview(github.GithubObject.NonCompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch @@ -140,8 +136,6 @@ class PullRequestReview(github.GithubObject.NonCompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "pull_request_url" in attributes: # pragma no branch - self._pull_request_url = self._makeStringAttribute( - attributes["pull_request_url"] - ) + self._pull_request_url = self._makeStringAttribute(attributes["pull_request_url"]) if "submitted_at" in attributes: # pragma no branch self._submitted_at = self._makeDatetimeAttribute(attributes["submitted_at"]) diff --git a/github/RateLimit.py b/github/RateLimit.py index 203d7d68..73875b91 100644 --- a/github/RateLimit.py +++ b/github/RateLimit.py @@ -80,10 +80,6 @@ class RateLimit(NonCompletableGithubObject): if "core" in attributes: # pragma no branch self._core = self._makeClassAttribute(github.Rate.Rate, attributes["core"]) if "search" in attributes: # pragma no branch - self._search = self._makeClassAttribute( - github.Rate.Rate, attributes["search"] - ) + self._search = self._makeClassAttribute(github.Rate.Rate, attributes["search"]) if "graphql" in attributes: # pragma no branch - self._graphql = self._makeClassAttribute( - github.Rate.Rate, attributes["graphql"] - ) + self._graphql = self._makeClassAttribute(github.Rate.Rate, attributes["graphql"]) diff --git a/github/Reaction.py b/github/Reaction.py index f88b3767..3cd0c43d 100644 --- a/github/Reaction.py +++ b/github/Reaction.py @@ -88,6 +88,4 @@ class Reaction(CompletableGithubObject): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/Repository.py b/github/Repository.py index 680b3237..039e40e1 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -778,9 +778,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ :type: integer """ - self._completeIfNotSet( - self._stargazers_count - ) # pragma no cover (Should be covered) + self._completeIfNotSet(self._stargazers_count) # pragma no cover (Should be covered) return self._stargazers_count.value # pragma no cover (Should be covered) @property @@ -910,12 +908,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param permission: string 'pull', 'push' or 'admin' :rtype: None """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( - collaborator, str - ), collaborator - assert permission is github.GithubObject.NotSet or isinstance( - permission, str - ), permission + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator + assert permission is github.GithubObject.NotSet or isinstance(permission, str), permission if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity @@ -931,9 +925,7 @@ class Repository(github.GithubObject.CompletableGithubObject): # return an invitation object if there's data returned by the API. If data is empty # there's a pending invitation for the given user. return ( - github.Invitation.Invitation(self._requester, headers, data, completed=True) - if data is not None - else None + github.Invitation.Invitation(self._requester, headers, data, completed=True) if data is not None else None ) def get_collaborator_permission(self, collaborator): @@ -942,9 +934,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: string """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( - collaborator, str - ), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( @@ -972,9 +962,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(invite_id, int), invite_id - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/invitations/{invite_id}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/invitations/{invite_id}") def compare(self, base, head): """ @@ -985,12 +973,8 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(base, str), base assert isinstance(head, str), head - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/compare/{base}...{head}" - ) - return github.Comparison.Comparison( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/compare/{base}...{head}") + return github.Comparison.Comparison(self._requester, headers, data, completed=True) def create_autolink(self, key_prefix, url_template): """ @@ -1003,9 +987,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(url_template, str), url_template post_parameters = {"key_prefix": key_prefix, "url_template": url_template} - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/autolinks", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/autolinks", input=post_parameters) return github.Autolink.Autolink(self._requester, headers, data, completed=True) def create_git_blob(self, content, encoding): @@ -1021,9 +1003,7 @@ class Repository(github.GithubObject.CompletableGithubObject): "content": content, "encoding": encoding, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/git/blobs", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/blobs", input=post_parameters) return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def create_git_commit( @@ -1045,15 +1025,9 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(message, str), message assert isinstance(tree, github.GitTree.GitTree), tree - assert all( - isinstance(element, github.GitCommit.GitCommit) for element in parents - ), parents - assert author is github.GithubObject.NotSet or isinstance( - author, github.InputGitAuthor - ), author - assert committer is github.GithubObject.NotSet or isinstance( - committer, github.InputGitAuthor - ), committer + assert all(isinstance(element, github.GitCommit.GitCommit) for element in parents), parents + assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor), author + assert committer is github.GithubObject.NotSet or isinstance(committer, github.InputGitAuthor), committer post_parameters = { "message": message, "tree": tree._identity, @@ -1063,12 +1037,8 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["author"] = author._identity if committer is not github.GithubObject.NotSet: post_parameters["committer"] = committer._identity - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/git/commits", input=post_parameters - ) - return github.GitCommit.GitCommit( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/commits", input=post_parameters) + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) def create_git_ref(self, ref, sha): """ @@ -1083,9 +1053,7 @@ class Repository(github.GithubObject.CompletableGithubObject): "ref": ref, "sha": sha, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/git/refs", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/refs", input=post_parameters) return github.GitRef.GitRef(self._requester, headers, data, completed=True) def create_git_tag_and_release( @@ -1175,20 +1143,12 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["target_commitish"] = target_commitish elif isinstance(target_commitish, github.Branch.Branch): post_parameters["target_commitish"] = target_commitish.name - elif isinstance( - target_commitish, (github.Commit.Commit, github.GitCommit.GitCommit) - ): + elif isinstance(target_commitish, (github.Commit.Commit, github.GitCommit.GitCommit)): post_parameters["target_commitish"] = target_commitish.sha - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/releases", input=post_parameters - ) - return github.GitRelease.GitRelease( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/releases", input=post_parameters) + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) - def create_git_tag( - self, tag, message, object, type, tagger=github.GithubObject.NotSet - ): + def create_git_tag(self, tag, message, object, type, tagger=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/git/tags `_ :param tag: string @@ -1202,9 +1162,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(message, str), message assert isinstance(object, str), object assert isinstance(type, str), type - assert tagger is github.GithubObject.NotSet or isinstance( - tagger, github.InputGitAuthor - ), tagger + assert tagger is github.GithubObject.NotSet or isinstance(tagger, github.InputGitAuthor), tagger post_parameters = { "tag": tag, "message": message, @@ -1213,9 +1171,7 @@ class Repository(github.GithubObject.CompletableGithubObject): } if tagger is not github.GithubObject.NotSet: post_parameters["tagger"] = tagger._identity - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/git/tags", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/tags", input=post_parameters) return github.GitTag.GitTag(self._requester, headers, data, completed=True) def create_git_tree(self, tree, base_tree=github.GithubObject.NotSet): @@ -1225,20 +1181,14 @@ class Repository(github.GithubObject.CompletableGithubObject): :param base_tree: :class:`github.GitTree.GitTree` :rtype: :class:`github.GitTree.GitTree` """ - assert all( - isinstance(element, github.InputGitTreeElement) for element in tree - ), tree - assert base_tree is github.GithubObject.NotSet or isinstance( - base_tree, github.GitTree.GitTree - ), base_tree + assert all(isinstance(element, github.InputGitTreeElement) for element in tree), tree + assert base_tree is github.GithubObject.NotSet or isinstance(base_tree, github.GitTree.GitTree), base_tree post_parameters = { "tree": [element._identity for element in tree], } if base_tree is not github.GithubObject.NotSet: post_parameters["base_tree"] = base_tree._identity - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/git/trees", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/trees", input=post_parameters) return github.GitTree.GitTree(self._requester, headers, data, completed=True) def create_hook( @@ -1258,9 +1208,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all( - isinstance(element, str) for element in events - ), events + assert events is github.GithubObject.NotSet or all(isinstance(element, str) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -1270,9 +1218,7 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/hooks", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/hooks", input=post_parameters) return github.Hook.Hook(self._requester, headers, data, completed=True) def create_issue( @@ -1302,15 +1248,11 @@ class Repository(github.GithubObject.CompletableGithubObject): or isinstance(assignee, str) ), assignee assert assignees is github.GithubObject.NotSet or all( - isinstance(element, github.NamedUser.NamedUser) or isinstance(element, str) - for element in assignees + isinstance(element, github.NamedUser.NamedUser) or isinstance(element, str) for element in assignees ), assignees - assert milestone is github.GithubObject.NotSet or isinstance( - milestone, github.Milestone.Milestone - ), milestone + assert milestone is github.GithubObject.NotSet or isinstance(milestone, github.Milestone.Milestone), milestone assert labels is github.GithubObject.NotSet or all( - isinstance(element, github.Label.Label) or isinstance(element, str) - for element in labels + isinstance(element, github.Label.Label) or isinstance(element, str) for element in labels ), labels post_parameters = { @@ -1325,21 +1267,16 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["assignee"] = assignee._identity if assignees is not github.GithubObject.NotSet: post_parameters["assignees"] = [ - element._identity - if isinstance(element, github.NamedUser.NamedUser) - else element + element._identity if isinstance(element, github.NamedUser.NamedUser) else element for element in assignees ] if milestone is not github.GithubObject.NotSet: post_parameters["milestone"] = milestone._identity if labels is not github.GithubObject.NotSet: post_parameters["labels"] = [ - element.name if isinstance(element, github.Label.Label) else element - for element in labels + element.name if isinstance(element, github.Label.Label) else element for element in labels ] - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/issues", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/issues", input=post_parameters) return github.Issue.Issue(self._requester, headers, data, completed=True) def create_key(self, title, key, read_only=False): @@ -1358,12 +1295,8 @@ class Repository(github.GithubObject.CompletableGithubObject): "key": key, "read_only": read_only, } - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/keys", input=post_parameters - ) - return github.RepositoryKey.RepositoryKey( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/keys", input=post_parameters) + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True) def create_label(self, name, color, description=github.GithubObject.NotSet): """ @@ -1375,9 +1308,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(color, str), color - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert description is github.GithubObject.NotSet or isinstance(description, str), description post_parameters = { "name": name, "color": color, @@ -1409,12 +1340,8 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(title, str), title assert state is github.GithubObject.NotSet or isinstance(state, str), state - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert due_on is github.GithubObject.NotSet or isinstance( - due_on, (datetime, date) - ), due_on + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert due_on is github.GithubObject.NotSet or isinstance(due_on, (datetime, date)), due_on post_parameters = { "title": title, } @@ -1427,12 +1354,8 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["due_on"] = due_on.strftime("%Y-%m-%dT%H:%M:%SZ") else: post_parameters["due_on"] = due_on.isoformat() - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/milestones", input=post_parameters - ) - return github.Milestone.Milestone( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/milestones", input=post_parameters) + return github.Milestone.Milestone(self._requester, headers, data, completed=True) def create_project(self, name, body=github.GithubObject.NotSet): """ @@ -1498,9 +1421,7 @@ class Repository(github.GithubObject.CompletableGithubObject): draft=draft, ) else: - return self.__create_pull( - title=title, body=body, base=base, head=head, draft=draft - ) + return self.__create_pull(title=title, body=body, base=base, head=head, draft=draft) def __create_pull_2(self, issue, base, head): assert isinstance(issue, github.Issue.Issue), issue @@ -1511,12 +1432,8 @@ class Repository(github.GithubObject.CompletableGithubObject): def __create_pull(self, **kwds): post_parameters = kwds - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/pulls", input=post_parameters - ) - return github.PullRequest.PullRequest( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/pulls", input=post_parameters) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def create_repository_advisory( self, @@ -1525,14 +1442,10 @@ class Repository(github.GithubObject.CompletableGithubObject): severity_or_cvss_vector_string: str, cve_id: typing.Optional[str] = None, vulnerabilities: typing.Optional[ - typing.Iterable[ - github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability - ] + typing.Iterable[github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability] ] = None, cwe_ids: typing.Optional[typing.Iterable[str]] = None, - credits: typing.Optional[ - typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit] - ] = None, + credits: typing.Optional[typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit]] = None, ) -> github.RepositoryAdvisory.RepositoryAdvisory: """ :calls: `POST /repos/{owner}/{repo}/security-advisories `_ @@ -1563,14 +1476,10 @@ class Repository(github.GithubObject.CompletableGithubObject): severity_or_cvss_vector_string: str, cve_id: typing.Optional[str] = None, vulnerabilities: typing.Optional[ - typing.Iterable[ - github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability - ] + typing.Iterable[github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability] ] = None, cwe_ids: typing.Optional[typing.Iterable[str]] = None, - credits: typing.Optional[ - typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit] - ] = None, + credits: typing.Optional[typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit]] = None, ) -> github.RepositoryAdvisory.RepositoryAdvisory: """ :calls: `POST /repos/{owner}/{repo}/security-advisories/reports `_ @@ -1600,15 +1509,9 @@ class Repository(github.GithubObject.CompletableGithubObject): description: str, severity_or_cvss_vector_string: str, cve_id: typing.Optional[str], - vulnerabilities: typing.Optional[ - typing.Iterable[ - github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability - ] - ], + vulnerabilities: typing.Optional[typing.Iterable[github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability]], cwe_ids: typing.Optional[typing.Iterable[str]], - credits: typing.Optional[ - typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit] - ], + credits: typing.Optional[typing.Iterable[github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit]], private_vulnerability_reporting: bool, ) -> github.RepositoryAdvisory.RepositoryAdvisory: if vulnerabilities is None: @@ -1617,9 +1520,7 @@ class Repository(github.GithubObject.CompletableGithubObject): cwe_ids = [] assert isinstance(summary, str), summary assert isinstance(description, str), description - assert isinstance( - severity_or_cvss_vector_string, str - ), severity_or_cvss_vector_string + assert isinstance(severity_or_cvss_vector_string, str), severity_or_cvss_vector_string assert isinstance(cve_id, (str, type(None))), cve_id assert isinstance(vulnerabilities, typing.Iterable), vulnerabilities for vulnerability in vulnerabilities: @@ -1633,17 +1534,13 @@ class Repository(github.GithubObject.CompletableGithubObject): if credits is not None: for credit in credits: # noinspection PyProtectedMember - github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._validate_credit( - credit - ) + github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._validate_credit(credit) # noinspection PyProtectedMember post_parameters = { "summary": summary, "description": description, "vulnerabilities": [ - github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict( - vulnerability - ) + github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict(vulnerability) for vulnerability in vulnerabilities ], "cwe_ids": list(cwe_ids), @@ -1653,10 +1550,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if credits is not None: # noinspection PyProtectedMember post_parameters["credits"] = [ - github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._to_github_dict( - credit - ) - for credit in credits + github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._to_github_dict(credit) for credit in credits ] if severity_or_cvss_vector_string.startswith("CVSS:"): post_parameters["cvss_vector_string"] = severity_or_cvss_vector_string @@ -1670,13 +1564,9 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/security-advisories", input=post_parameters ) - return github.RepositoryAdvisory.RepositoryAdvisory( - self._requester, headers, data, completed=True - ) + return github.RepositoryAdvisory.RepositoryAdvisory(self._requester, headers, data, completed=True) - def create_repository_dispatch( - self, event_type, client_payload=github.GithubObject.NotSet - ): + def create_repository_dispatch(self, event_type, client_payload=github.GithubObject.NotSet): """ :calls: POST /repos/{owner}/{repo}/dispatches :param event_type: string @@ -1684,15 +1574,11 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(event_type, str), event_type - assert client_payload is github.GithubObject.NotSet or isinstance( - client_payload, dict - ), client_payload + assert client_payload is github.GithubObject.NotSet or isinstance(client_payload, dict), client_payload post_parameters = {"event_type": event_type} if client_payload is not github.GithubObject.NotSet: post_parameters["client_payload"] = client_payload - status, headers, data = self._requester.requestJson( - "POST", f"{self.url}/dispatches", input=post_parameters - ) + status, headers, data = self._requester.requestJson("POST", f"{self.url}/dispatches", input=post_parameters) return status == 204 def create_secret(self, secret_name, unencrypted_value): @@ -1760,9 +1646,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(secret_name, str), secret_name - status, headers, data = self._requester.requestJson( - "DELETE", f"{self.url}/actions/secrets/{secret_name}" - ) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/actions/secrets/{secret_name}") return status == 204 def delete_variable(self, variable_name: str) -> bool: @@ -1772,9 +1656,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(variable_name, str), variable_name - status, headers, data = self._requester.requestJson( - "DELETE", f"{self.url}/actions/variables/{variable_name}" - ) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/actions/variables/{variable_name}") return status == 204 def create_source_import( @@ -1794,12 +1676,8 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(vcs, str), vcs assert isinstance(vcs_url, str), vcs_url - assert vcs_username is github.GithubObject.NotSet or isinstance( - vcs_username, str - ), vcs_username - assert vcs_password is github.GithubObject.NotSet or isinstance( - vcs_password, str - ), vcs_password + assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, str), vcs_username + assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, str), vcs_password put_parameters = {"vcs": vcs, "vcs_url": vcs_url} if vcs_username is not github.GithubObject.NotSet: @@ -1814,9 +1692,7 @@ class Repository(github.GithubObject.CompletableGithubObject): "PUT", f"{self.url}/import", headers=import_header, input=put_parameters ) - return github.SourceImport.SourceImport( - self._requester, headers, data, completed=False - ) + return github.SourceImport.SourceImport(self._requester, headers, data, completed=False) def delete(self): """ @@ -1868,36 +1744,16 @@ class Repository(github.GithubObject.CompletableGithubObject): if name is None: name = self.name assert isinstance(name, str), name - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert homepage is github.GithubObject.NotSet or isinstance( - homepage, str - ), homepage - assert private is github.GithubObject.NotSet or isinstance( - private, bool - ), private - assert has_issues is github.GithubObject.NotSet or isinstance( - has_issues, bool - ), has_issues - assert has_projects is github.GithubObject.NotSet or isinstance( - has_projects, bool - ), has_projects - assert has_wiki is github.GithubObject.NotSet or isinstance( - has_wiki, bool - ), has_wiki - assert has_downloads is github.GithubObject.NotSet or isinstance( - has_downloads, bool - ), has_downloads - assert default_branch is github.GithubObject.NotSet or isinstance( - default_branch, str - ), default_branch - assert allow_auto_merge is github.GithubObject.NotSet or isinstance( - allow_auto_merge, bool - ), allow_auto_merge - assert allow_forking is github.GithubObject.NotSet or isinstance( - allow_forking, bool - ), allow_forking + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, str), homepage + assert private is github.GithubObject.NotSet or isinstance(private, bool), private + assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues + assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects + assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki + assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads + assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, str), default_branch + assert allow_auto_merge is github.GithubObject.NotSet or isinstance(allow_auto_merge, bool), allow_auto_merge + assert allow_forking is github.GithubObject.NotSet or isinstance(allow_forking, bool), allow_forking assert allow_squash_merge is github.GithubObject.NotSet or isinstance( allow_squash_merge, bool ), allow_squash_merge @@ -1913,9 +1769,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert allow_update_branch is github.GithubObject.NotSet or isinstance( allow_update_branch, bool ), allow_update_branch - assert archived is github.GithubObject.NotSet or isinstance( - archived, bool - ), archived + assert archived is github.GithubObject.NotSet or isinstance(archived, bool), archived post_parameters = { "name": name, } @@ -1951,9 +1805,7 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["allow_update_branch"] = allow_update_branch if archived is not github.GithubObject.NotSet: post_parameters["archived"] = archived - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_archive_link(self, archive_format, ref=github.GithubObject.NotSet): @@ -1987,9 +1839,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Branch.Branch` """ assert isinstance(branch, str), branch - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/branches/{branch}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/branches/{branch}") return github.Branch.Branch(self._requester, headers, data, completed=True) def rename_branch(self, branch, new_name): @@ -2008,9 +1858,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if is_branch: branch = branch.name parameters = {"new_name": new_name} - status, _, _ = self._requester.requestJson( - "POST", f"{self.url}/branches/{branch}/rename", input=parameters - ) + status, _, _ = self._requester.requestJson("POST", f"{self.url}/branches/{branch}/rename", input=parameters) return status == 201 def get_branches(self): @@ -2018,9 +1866,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/branches `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Branch.Branch` """ - return github.PaginatedList.PaginatedList( - github.Branch.Branch, self._requester, f"{self.url}/branches", None - ) + return github.PaginatedList.PaginatedList(github.Branch.Branch, self._requester, f"{self.url}/branches", None) def get_collaborators(self, affiliation=github.GithubObject.NotSet): """ @@ -2033,9 +1879,7 @@ class Repository(github.GithubObject.CompletableGithubObject): allowed_affiliations = ["outside", "direct", "all"] if affiliation is not github.GithubObject.NotSet: assert isinstance(affiliation, str), affiliation - assert ( - affiliation in allowed_affiliations - ), f"Affiliation can be one of {', '.join(allowed_affiliations)}" + assert affiliation in allowed_affiliations, f"Affiliation can be one of {', '.join(allowed_affiliations)}" url_parameters["affiliation"] = affiliation return github.PaginatedList.PaginatedList( @@ -2052,12 +1896,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.CommitComment.CommitComment` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/comments/{id}" - ) - return github.CommitComment.CommitComment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/comments/{id}") + return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -2078,9 +1918,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Commit.Commit` """ assert isinstance(sha, str), sha - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/commits/{sha}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/commits/{sha}") return github.Commit.Commit(self._requester, headers, data, completed=True) def get_commits( @@ -2159,22 +1997,16 @@ class Repository(github.GithubObject.CompletableGithubObject): # Handle 302 redirect response if headers.get("status") == "302 Found" and headers.get("location"): - headers, data = self._requester.requestJsonAndCheck( - "GET", headers["location"], parameters=url_parameters - ) + headers, data = self._requester.requestJsonAndCheck("GET", headers["location"], parameters=url_parameters) if isinstance(data, list): return [ # Lazy completion only makes sense for files. See discussion # here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 - github.ContentFile.ContentFile( - self._requester, headers, item, completed=(item["type"] != "file") - ) + github.ContentFile.ContentFile(self._requester, headers, item, completed=(item["type"] != "file")) for item in data ] - return github.ContentFile.ContentFile( - self._requester, headers, data, completed=True - ) + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) def get_deployments( self, @@ -2194,9 +2026,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref assert task is github.GithubObject.NotSet or isinstance(task, str), task - assert environment is github.GithubObject.NotSet or isinstance( - environment, str - ), environment + assert environment is github.GithubObject.NotSet or isinstance(environment, str), environment parameters = {} if sha is not github.GithubObject.NotSet: parameters["sha"] = sha @@ -2226,9 +2056,7 @@ class Repository(github.GithubObject.CompletableGithubObject): f"{self.url}/deployments/{id_}", headers={"Accept": Consts.deploymentEnhancementsPreview}, ) - return github.Deployment.Deployment( - self._requester, headers, data, completed=True - ) + return github.Deployment.Deployment(self._requester, headers, data, completed=True) def create_deployment( self, @@ -2257,21 +2085,13 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(ref, str), ref assert task is github.GithubObject.NotSet or isinstance(task, str), task - assert auto_merge is github.GithubObject.NotSet or isinstance( - auto_merge, bool - ), auto_merge + assert auto_merge is github.GithubObject.NotSet or isinstance(auto_merge, bool), auto_merge assert required_contexts is github.GithubObject.NotSet or isinstance( required_contexts, list ), required_contexts # need to do better checking here - assert payload is github.GithubObject.NotSet or isinstance( - payload, dict - ), payload - assert environment is github.GithubObject.NotSet or isinstance( - environment, str - ), environment - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description + assert payload is github.GithubObject.NotSet or isinstance(payload, dict), payload + assert environment is github.GithubObject.NotSet or isinstance(environment, str), environment + assert description is github.GithubObject.NotSet or isinstance(description, str), description assert transient_environment is github.GithubObject.NotSet or isinstance( transient_environment, bool ), transient_environment @@ -2304,37 +2124,25 @@ class Repository(github.GithubObject.CompletableGithubObject): headers={"Accept": Consts.deploymentEnhancementsPreview}, ) - return github.Deployment.Deployment( - self._requester, headers, data, completed=True - ) + return github.Deployment.Deployment(self._requester, headers, data, completed=True) def get_top_referrers(self): """ :calls: `GET /repos/{owner}/{repo}/traffic/popular/referrers `_ :rtype: :class:`list` of :class:`github.Referrer.Referrer` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/traffic/popular/referrers" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/traffic/popular/referrers") if isinstance(data, list): - return [ - github.Referrer.Referrer(self._requester, headers, item, completed=True) - for item in data - ] + return [github.Referrer.Referrer(self._requester, headers, item, completed=True) for item in data] def get_top_paths(self): """ :calls: `GET /repos/{owner}/{repo}/traffic/popular/paths `_ :rtype: :class:`list` of :class:`github.Path.Path` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/traffic/popular/paths" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/traffic/popular/paths") if isinstance(data, list): - return [ - github.Path.Path(self._requester, headers, item, completed=True) - for item in data - ] + return [github.Path.Path(self._requester, headers, item, completed=True) for item in data] def get_views_traffic(self, per=github.GithubObject.NotSet): """ @@ -2351,15 +2159,8 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/views", parameters=url_parameters ) - if ( - (isinstance(data, dict)) - and ("views" in data) - and (isinstance(data["views"], list)) - ): - data["views"] = [ - github.View.View(self._requester, headers, item, completed=True) - for item in data["views"] - ] + if (isinstance(data, dict)) and ("views" in data) and (isinstance(data["views"], list)): + data["views"] = [github.View.View(self._requester, headers, item, completed=True) for item in data["views"]] return data def get_clones_traffic(self, per=github.GithubObject.NotSet): @@ -2377,14 +2178,9 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/clones", parameters=url_parameters ) - if ( - (isinstance(data, dict)) - and ("clones" in data) - and (isinstance(data["clones"], list)) - ): + if (isinstance(data, dict)) and ("clones" in data) and (isinstance(data["clones"], list)): data["clones"] = [ - github.Clones.Clones(self._requester, headers, item, completed=True) - for item in data["clones"] + github.Clones.Clones(self._requester, headers, item, completed=True) for item in data["clones"] ] return data @@ -2442,12 +2238,8 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(message, str) assert isinstance(content, (str, bytes)) assert branch is github.GithubObject.NotSet or isinstance(branch, str) - assert author is github.GithubObject.NotSet or isinstance( - author, github.InputGitAuthor - ) - assert committer is github.GithubObject.NotSet or isinstance( - committer, github.InputGitAuthor - ) + assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor) + assert committer is github.GithubObject.NotSet or isinstance(committer, github.InputGitAuthor) if not isinstance(content, bytes): content = content.encode("utf-8") @@ -2468,12 +2260,8 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return { - "content": github.ContentFile.ContentFile( - self._requester, headers, data["content"], completed=False - ), - "commit": github.Commit.Commit( - self._requester, headers, data["commit"], completed=True - ), + "content": github.ContentFile.ContentFile(self._requester, headers, data["content"], completed=False), + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), } def get_repository_advisories( @@ -2490,20 +2278,14 @@ class Repository(github.GithubObject.CompletableGithubObject): None, ) - def get_repository_advisory( - self, ghsa: str - ) -> github.RepositoryAdvisory.RepositoryAdvisory: + def get_repository_advisory(self, ghsa: str) -> github.RepositoryAdvisory.RepositoryAdvisory: """ :calls: `GET /repos/{owner}/{repo}/security-advisories/{ghsa} `_ :param ghsa: string :rtype: :class:`github.RepositoryAdvisory.RepositoryAdvisory` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/security-advisories/{ghsa}" - ) - return github.RepositoryAdvisory.RepositoryAdvisory( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/security-advisories/{ghsa}") + return github.RepositoryAdvisory.RepositoryAdvisory(self._requester, headers, data, completed=True) def update_file( self, @@ -2534,12 +2316,8 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(content, (str, bytes)) assert isinstance(sha, str) assert branch is github.GithubObject.NotSet or isinstance(branch, str) - assert author is github.GithubObject.NotSet or isinstance( - author, github.InputGitAuthor - ) - assert committer is github.GithubObject.NotSet or isinstance( - committer, github.InputGitAuthor - ) + assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor) + assert committer is github.GithubObject.NotSet or isinstance(committer, github.InputGitAuthor) if not isinstance(content, bytes): content = content.encode("utf-8") @@ -2561,12 +2339,8 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return { - "commit": github.Commit.Commit( - self._requester, headers, data["commit"], completed=True - ), - "content": github.ContentFile.ContentFile( - self._requester, headers, data["content"], completed=False - ), + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), + "content": github.ContentFile.ContentFile(self._requester, headers, data["content"], completed=False), } def delete_file( @@ -2594,9 +2368,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(path, str), "path must be str/unicode object" assert isinstance(message, str), "message must be str/unicode object" assert isinstance(sha, str), "sha must be a str/unicode object" - assert branch is github.GithubObject.NotSet or isinstance( - branch, str - ), "branch must be a str/unicode object" + assert branch is github.GithubObject.NotSet or isinstance(branch, str), "branch must be a str/unicode object" assert author is github.GithubObject.NotSet or isinstance( author, github.InputGitAuthor ), "author must be a github.InputGitAuthor object" @@ -2619,9 +2391,7 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return { - "commit": github.Commit.Commit( - self._requester, headers, data["commit"], completed=True - ), + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), "content": github.GithubObject.NotSet, } @@ -2664,9 +2434,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Download.Download` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/downloads/{id}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/downloads/{id}") return github.Download.Download(self._requester, headers, data, completed=True) def get_downloads(self): @@ -2683,18 +2451,14 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ - return github.PaginatedList.PaginatedList( - github.Event.Event, self._requester, f"{self.url}/events", None - ) + return github.PaginatedList.PaginatedList(github.Event.Event, self._requester, f"{self.url}/events", None) def get_forks(self): """ :calls: `GET /repos/{owner}/{repo}/forks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - return github.PaginatedList.PaginatedList( - Repository, self._requester, f"{self.url}/forks", None - ) + return github.PaginatedList.PaginatedList(Repository, self._requester, f"{self.url}/forks", None) def create_fork( self, @@ -2738,9 +2502,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GitBlob.GitBlob` """ assert isinstance(sha, str), sha - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/git/blobs/{sha}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/blobs/{sha}") return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def get_git_commit(self, sha): @@ -2750,12 +2512,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GitCommit.GitCommit` """ assert isinstance(sha, str), sha - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/git/commits/{sha}" - ) - return github.GitCommit.GitCommit( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/commits/{sha}") + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) def get_git_ref(self, ref): """ @@ -2767,9 +2525,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if not self._requester.FIX_REPO_GET_GIT_REF: prefix = "/git/" assert isinstance(ref, str), ref - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}{prefix}{ref}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}{prefix}{ref}") return github.GitRef.GitRef(self._requester, headers, data, completed=True) def get_git_refs(self): @@ -2777,9 +2533,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/git/refs `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRef.GitRef` """ - return github.PaginatedList.PaginatedList( - github.GitRef.GitRef, self._requester, f"{self.url}/git/refs", None - ) + return github.PaginatedList.PaginatedList(github.GitRef.GitRef, self._requester, f"{self.url}/git/refs", None) def get_git_matching_refs(self, ref): """ @@ -2801,9 +2555,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GitTag.GitTag` """ assert isinstance(sha, str), sha - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/git/tags/{sha}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/tags/{sha}") return github.GitTag.GitTag(self._requester, headers, data, completed=True) def get_git_tree(self, sha, recursive=github.GithubObject.NotSet): @@ -2814,9 +2566,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GitTree.GitTree` """ assert isinstance(sha, str), sha - assert recursive is github.GithubObject.NotSet or isinstance( - recursive, bool - ), recursive + assert recursive is github.GithubObject.NotSet or isinstance(recursive, bool), recursive url_parameters = dict() if recursive is not github.GithubObject.NotSet and recursive: # GitHub API requires the recursive parameter be set to 1. @@ -2833,9 +2583,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Hook.Hook` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/hooks/{id}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/hooks/{id}") return github.Hook.Hook(self._requester, headers, data, completed=True) def get_hooks(self): @@ -2843,13 +2591,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/hooks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Hook.Hook` """ - return github.PaginatedList.PaginatedList( - github.Hook.Hook, self._requester, f"{self.url}/hooks", None - ) + return github.PaginatedList.PaginatedList(github.Hook.Hook, self._requester, f"{self.url}/hooks", None) - def get_hook_delivery( - self, hook_id: int, delivery_id: int - ) -> github.HookDelivery.HookDelivery: + def get_hook_delivery(self, hook_id: int, delivery_id: int) -> github.HookDelivery.HookDelivery: """ :calls: `GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id} `_ :param hook_id: integer @@ -2861,9 +2605,7 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/hooks/{hook_id}/deliveries/{delivery_id}" ) - return github.HookDelivery.HookDelivery( - self._requester, headers, data, completed=True - ) + return github.HookDelivery.HookDelivery(self._requester, headers, data, completed=True) def get_hook_deliveries( self, hook_id: int @@ -2889,9 +2631,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Issue.Issue` """ assert isinstance(number, int), number - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/issues/{number}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/issues/{number}") return github.Issue.Issue(self._requester, headers, data, completed=True) def get_issues( @@ -2931,17 +2671,12 @@ class Repository(github.GithubObject.CompletableGithubObject): or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str) ), assignee - assert mentioned is github.GithubObject.NotSet or isinstance( - mentioned, github.NamedUser.NamedUser - ), mentioned + assert mentioned is github.GithubObject.NotSet or isinstance(mentioned, github.NamedUser.NamedUser), mentioned assert labels is github.GithubObject.NotSet or all( - isinstance(element, github.Label.Label) or isinstance(element, str) - for element in labels + isinstance(element, github.Label.Label) or isinstance(element, str) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since assert ( creator is github.GithubObject.NotSet @@ -2965,10 +2700,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters["mentioned"] = mentioned._identity if labels is not github.GithubObject.NotSet: url_parameters["labels"] = ",".join( - [ - label.name if isinstance(label, github.Label.Label) else label - for label in labels - ] + [label.name if isinstance(label, github.Label.Label) else label for label in labels] ) if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort @@ -2999,9 +2731,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` """ assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if sort is not github.GithubObject.NotSet: @@ -3029,9 +2759,7 @@ class Repository(github.GithubObject.CompletableGithubObject): f"{self.url}/issues/events/{id}", headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) - return github.IssueEvent.IssueEvent( - self._requester, headers, data, completed=True - ) + return github.IssueEvent.IssueEvent(self._requester, headers, data, completed=True) def get_issues_events(self): """ @@ -3053,12 +2781,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.RepositoryKey.RepositoryKey` """ assert isinstance(id, int), id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/keys/{id}" - ) - return github.RepositoryKey.RepositoryKey( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/keys/{id}") + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True) def get_keys(self): """ @@ -3079,9 +2803,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Label.Label` """ assert isinstance(name, str), name - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/labels/{urllib.parse.quote(name)}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/labels/{urllib.parse.quote(name)}") return github.Label.Label(self._requester, headers, data, completed=True) def get_labels(self): @@ -3089,18 +2811,14 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ - return github.PaginatedList.PaginatedList( - github.Label.Label, self._requester, f"{self.url}/labels", None - ) + return github.PaginatedList.PaginatedList(github.Label.Label, self._requester, f"{self.url}/labels", None) def get_languages(self): """ :calls: `GET /repos/{owner}/{repo}/languages `_ :rtype: dict of string to integer """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/languages" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/languages") return data def get_license(self): @@ -3109,12 +2827,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.ContentFile.ContentFile` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/license" - ) - return github.ContentFile.ContentFile( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/license") + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) def get_milestone(self, number): """ @@ -3123,12 +2837,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Milestone.Milestone` """ assert isinstance(number, int), number - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/milestones/{number}" - ) - return github.Milestone.Milestone( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/milestones/{number}") + return github.Milestone.Milestone(self._requester, headers, data, completed=True) def get_milestones( self, @@ -3145,9 +2855,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert state is github.GithubObject.NotSet or isinstance(state, str), state assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state @@ -3179,12 +2887,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/actions/secrets/public-key `_ :rtype: :class:`github.PublicKey.PublicKey` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/secrets/public-key" - ) - return github.PublicKey.PublicKey( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/secrets/public-key") + return github.PublicKey.PublicKey(self._requester, headers, data, completed=True) def get_pull(self, number): """ @@ -3193,12 +2897,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PullRequest.PullRequest` """ assert isinstance(number, int), number - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/pulls/{number}" - ) - return github.PullRequest.PullRequest( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/pulls/{number}") + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def get_pulls( self, @@ -3219,9 +2919,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert state is github.GithubObject.NotSet or isinstance(state, str), state assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert base is github.GithubObject.NotSet or isinstance(base, str), base assert head is github.GithubObject.NotSet or isinstance(head, str), head url_parameters = dict() @@ -3271,9 +2969,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort - assert direction is github.GithubObject.NotSet or isinstance( - direction, str - ), direction + assert direction is github.GithubObject.NotSet or isinstance(direction, str), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime), since url_parameters = dict() if sort is not github.GithubObject.NotSet: @@ -3299,12 +2995,8 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/readme", parameters=url_parameters - ) - return github.ContentFile.ContentFile( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/readme", parameters=url_parameters) + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) def get_self_hosted_runner(self, runner_id): """ @@ -3313,12 +3005,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` """ assert isinstance(runner_id, int), runner_id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/runners/{runner_id}" - ) - return github.SelfHostedActionsRunner.SelfHostedActionsRunner( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/runners/{runner_id}") + return github.SelfHostedActionsRunner.SelfHostedActionsRunner(self._requester, headers, data, completed=True) def get_self_hosted_runners(self): """ @@ -3347,9 +3035,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if not data: return None else: - return github.SourceImport.SourceImport( - self._requester, headers, data, completed=True - ) + return github.SourceImport.SourceImport(self._requester, headers, data, completed=True) def get_stargazers(self): """ @@ -3378,16 +3064,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/stats/contributors `_ :rtype: None or list of :class:`github.StatsContributor.StatsContributor` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/stats/contributors" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/contributors") if not data: return None else: return [ - github.StatsContributor.StatsContributor( - self._requester, headers, attributes, completed=True - ) + github.StatsContributor.StatsContributor(self._requester, headers, attributes, completed=True) for attributes in data ] @@ -3396,16 +3078,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/stats/commit_activity `_ :rtype: None or list of :class:`github.StatsCommitActivity.StatsCommitActivity` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/stats/commit_activity" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/commit_activity") if not data: return None else: return [ - github.StatsCommitActivity.StatsCommitActivity( - self._requester, headers, attributes, completed=True - ) + github.StatsCommitActivity.StatsCommitActivity(self._requester, headers, attributes, completed=True) for attributes in data ] @@ -3414,16 +3092,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/stats/code_frequency `_ :rtype: None or list of :class:`github.StatsCodeFrequency.StatsCodeFrequency` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/stats/code_frequency" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/code_frequency") if not data: return None else: return [ - github.StatsCodeFrequency.StatsCodeFrequency( - self._requester, headers, attributes, completed=True - ) + github.StatsCodeFrequency.StatsCodeFrequency(self._requester, headers, attributes, completed=True) for attributes in data ] @@ -3432,30 +3106,22 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/stats/participation `_ :rtype: None or :class:`github.StatsParticipation.StatsParticipation` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/stats/participation" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/participation") if not data: return None else: - return github.StatsParticipation.StatsParticipation( - self._requester, headers, data, completed=True - ) + return github.StatsParticipation.StatsParticipation(self._requester, headers, data, completed=True) def get_stats_punch_card(self): """ :calls: `GET /repos/{owner}/{repo}/stats/punch_card `_ :rtype: None or :class:`github.StatsPunchCard.StatsPunchCard` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/stats/punch_card" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/punch_card") if not data: return None else: - return github.StatsPunchCard.StatsPunchCard( - self._requester, headers, data, completed=True - ) + return github.StatsPunchCard.StatsPunchCard(self._requester, headers, data, completed=True) def get_subscribers(self): """ @@ -3471,9 +3137,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/tags `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Tag.Tag` """ - return github.PaginatedList.PaginatedList( - github.Tag.Tag, self._requester, f"{self.url}/tags", None - ) + return github.PaginatedList.PaginatedList(github.Tag.Tag, self._requester, f"{self.url}/tags", None) def get_releases(self): """ @@ -3491,40 +3155,26 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: None or :class:`github.GitRelease.GitRelease` """ if isinstance(id, int): - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/releases/{id}" - ) - return github.GitRelease.GitRelease( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/{id}") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) elif isinstance(id, str): - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/releases/tags/{id}" - ) - return github.GitRelease.GitRelease( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/tags/{id}") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) def get_latest_release(self): """ :calls: `GET /repos/{owner}/{repo}/releases/latest `_ :rtype: :class:`github.GitRelease.GitRelease` """ - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/releases/latest" - ) - return github.GitRelease.GitRelease( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/latest") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) def get_teams(self): """ :calls: `GET /repos/{owner}/{repo}/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ - return github.PaginatedList.PaginatedList( - github.Team.Team, self._requester, f"{self.url}/teams", None - ) + return github.PaginatedList.PaginatedList(github.Team.Team, self._requester, f"{self.url}/teams", None) def get_topics(self): """ @@ -3568,9 +3218,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Workflow.Workflow` """ assert isinstance(id_or_name, int) or isinstance(id_or_name, str), id_or_name - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/workflows/{id_or_name}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/workflows/{id_or_name}") return github.Workflow.Workflow(self._requester, headers, data, completed=True) def get_workflow_runs( @@ -3599,18 +3247,14 @@ class Repository(github.GithubObject.CompletableGithubObject): or isinstance(actor, str) ), actor assert ( - branch is github.GithubObject.NotSet - or isinstance(branch, github.Branch.Branch) - or isinstance(branch, str) + branch is github.GithubObject.NotSet or isinstance(branch, github.Branch.Branch) or isinstance(branch, str) ), branch assert event is github.GithubObject.NotSet or isinstance(event, str), event assert status is github.GithubObject.NotSet or isinstance(status, str), status assert exclude_pull_requests is github.GithubObject.NotSet or isinstance( exclude_pull_requests, bool ), exclude_pull_requests - assert head_sha is github.GithubObject.NotSet or isinstance( - head_sha, str - ), head_sha + assert head_sha is github.GithubObject.NotSet or isinstance(head_sha, str), head_sha url_parameters = dict() if actor is not github.GithubObject.NotSet: @@ -3627,10 +3271,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters["event"] = event if status is not github.GithubObject.NotSet: url_parameters["status"] = status - if ( - exclude_pull_requests is not github.GithubObject.NotSet - and exclude_pull_requests - ): + if exclude_pull_requests is not github.GithubObject.NotSet and exclude_pull_requests: url_parameters["exclude_pull_requests"] = 1 if head_sha is not github.GithubObject.NotSet: url_parameters["head_sha"] = head_sha @@ -3651,12 +3292,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.WorkflowRun.WorkflowRun` """ assert isinstance(id_, int) - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/runs/{id_}" - ) - return github.WorkflowRun.WorkflowRun( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/runs/{id_}") + return github.WorkflowRun.WorkflowRun(self._requester, headers, data, completed=True) def has_in_assignees(self, assignee): """ @@ -3664,16 +3301,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :param assignee: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ - assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance( - assignee, str - ), assignee + assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str), assignee if isinstance(assignee, github.NamedUser.NamedUser): assignee = assignee._identity - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/assignees/{assignee}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/assignees/{assignee}") return status == 204 def has_in_collaborators(self, collaborator): @@ -3682,16 +3315,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( - collaborator, str - ), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/collaborators/{collaborator}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/collaborators/{collaborator}") return status == 204 def _legacy_convert_issue(self, attributes): @@ -3704,9 +3333,7 @@ class Repository(github.GithubObject.CompletableGithubObject): }, } if "labels" in attributes: # pragma no branch - convertedAttributes["labels"] = [ - {"name": label} for label in attributes["labels"] - ] + convertedAttributes["labels"] = [{"name": label} for label in attributes["labels"]] for attr in ("title", "created_at", "comments", "body", "updated_at", "state"): if attr in attributes: # pragma no branch convertedAttributes[attr] = attributes[attr] @@ -3752,13 +3379,9 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert all is github.GithubObject.NotSet or isinstance(all, bool), all - assert participating is github.GithubObject.NotSet or isinstance( - participating, bool - ), participating + assert participating is github.GithubObject.NotSet or isinstance(participating, bool), participating assert since is github.GithubObject.NotSet or isinstance(since, datetime), since - assert before is github.GithubObject.NotSet or isinstance( - before, datetime - ), before + assert before is github.GithubObject.NotSet or isinstance(before, datetime), before params = dict() if all is not github.GithubObject.NotSet: @@ -3785,9 +3408,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(last_read_at, datetime) put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.url}/notifications", input=put_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/notifications", input=put_parameters) def merge(self, base, head, commit_message=github.GithubObject.NotSet): """ @@ -3799,18 +3420,14 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(base, str), base assert isinstance(head, str), head - assert commit_message is github.GithubObject.NotSet or isinstance( - commit_message, str - ), commit_message + assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, str), commit_message post_parameters = { "base": base, "head": head, } if commit_message is not github.GithubObject.NotSet: post_parameters["commit_message"] = commit_message - headers, data = self._requester.requestJsonAndCheck( - "POST", f"{self.url}/merges", input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/merges", input=post_parameters) if data is None: return None else: @@ -3896,16 +3513,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: None """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( - collaborator, str - ), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/collaborators/{collaborator}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/collaborators/{collaborator}") def remove_self_hosted_runner(self, runner): """ @@ -3913,16 +3526,14 @@ class Repository(github.GithubObject.CompletableGithubObject): :param runner: int or :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` :rtype: bool """ - assert isinstance( - runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner - ) or isinstance(runner, int), runner + assert isinstance(runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner) or isinstance( + runner, int + ), runner if isinstance(runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner): runner = runner.id - status, _, _ = self._requester.requestJson( - "DELETE", f"{self.url}/actions/runners/{runner}" - ) + status, _, _ = self._requester.requestJson("DELETE", f"{self.url}/actions/runners/{runner}") return status == 204 def remove_autolink(self, autolink): @@ -3971,9 +3582,7 @@ class Repository(github.GithubObject.CompletableGithubObject): f"{self.url}/check-suites", input={"head_sha": head_sha}, ) - return github.CheckSuite.CheckSuite( - self._requester, headers, data, completed=True - ) + return github.CheckSuite.CheckSuite(self._requester, headers, data, completed=True) def get_check_suite(self, check_suite_id): """ @@ -3988,9 +3597,7 @@ class Repository(github.GithubObject.CompletableGithubObject): f"{self.url}/check-suites/{check_suite_id}", headers=requestHeaders, ) - return github.CheckSuite.CheckSuite( - self._requester, headers, data, completed=True - ) + return github.CheckSuite.CheckSuite(self._requester, headers, data, completed=True) def update_check_suites_preferences(self, auto_trigger_checks): """ @@ -3998,17 +3605,13 @@ class Repository(github.GithubObject.CompletableGithubObject): :param auto_trigger_checks: list of dict :rtype: :class:`github.RepositoryPreferences.RepositoryPreferences` """ - assert all( - isinstance(element, dict) for element in auto_trigger_checks - ), auto_trigger_checks + assert all(isinstance(element, dict) for element in auto_trigger_checks), auto_trigger_checks headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.url}/check-suites/preferences", input={"auto_trigger_checks": auto_trigger_checks}, ) - return github.RepositoryPreferences.RepositoryPreferences( - self._requester, headers, data, completed=True - ) + return github.RepositoryPreferences.RepositoryPreferences(self._requester, headers, data, completed=True) def _hub(self, mode, event, callback, secret): assert isinstance(mode, str), mode @@ -4018,16 +3621,12 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters = collections.OrderedDict() post_parameters["hub.callback"] = callback - post_parameters[ - "hub.topic" - ] = f"https://github.com/{self.full_name}/events/{event}" + post_parameters["hub.topic"] = f"https://github.com/{self.full_name}/events/{event}" post_parameters["hub.mode"] = mode if secret is not github.GithubObject.NotSet: post_parameters["hub.secret"] = secret - headers, output = self._requester.requestMultipartAndCheck( - "POST", "/hub", input=post_parameters - ) + headers, output = self._requester.requestMultipartAndCheck("POST", "/hub", input=post_parameters) @property def _identity(self): @@ -4036,12 +3635,8 @@ class Repository(github.GithubObject.CompletableGithubObject): def get_release_asset(self, id): assert isinstance(id, (int)), id - resp_headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/releases/assets/{id}" - ) - return github.GitReleaseAsset.GitReleaseAsset( - self._requester, resp_headers, data, completed=True - ) + resp_headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/assets/{id}") + return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_headers, data, completed=True) def create_check_run( self, @@ -4072,26 +3667,14 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(name, str), name assert isinstance(head_sha, str), head_sha - assert details_url is github.GithubObject.NotSet or isinstance( - details_url, str - ), details_url - assert external_id is github.GithubObject.NotSet or isinstance( - external_id, str - ), external_id + assert details_url is github.GithubObject.NotSet or isinstance(details_url, str), details_url + assert external_id is github.GithubObject.NotSet or isinstance(external_id, str), external_id assert status is github.GithubObject.NotSet or isinstance(status, str), status - assert started_at is github.GithubObject.NotSet or isinstance( - started_at, datetime - ), started_at - assert conclusion is github.GithubObject.NotSet or isinstance( - conclusion, str - ), conclusion - assert completed_at is github.GithubObject.NotSet or isinstance( - completed_at, datetime - ), completed_at + assert started_at is github.GithubObject.NotSet or isinstance(started_at, datetime), started_at + assert conclusion is github.GithubObject.NotSet or isinstance(conclusion, str), conclusion + assert completed_at is github.GithubObject.NotSet or isinstance(completed_at, datetime), completed_at assert output is github.GithubObject.NotSet or isinstance(output, dict), output - assert actions is github.GithubObject.NotSet or all( - isinstance(element, dict) for element in actions - ), actions + assert actions is github.GithubObject.NotSet or all(isinstance(element, dict) for element in actions), actions post_parameters = { "name": name, @@ -4106,9 +3689,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if started_at is not github.GithubObject.NotSet: post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") if completed_at is not github.GithubObject.NotSet: - post_parameters["completed_at"] = completed_at.strftime( - "%Y-%m-%dT%H:%M:%SZ" - ) + post_parameters["completed_at"] = completed_at.strftime("%Y-%m-%dT%H:%M:%SZ") if conclusion is not github.GithubObject.NotSet: post_parameters["conclusion"] = conclusion if output is not github.GithubObject.NotSet: @@ -4130,9 +3711,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.CheckRun.CheckRun` """ assert isinstance(check_run_id, int), check_run_id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/check-runs/{check_run_id}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/check-runs/{check_run_id}") return github.CheckRun.CheckRun(self._requester, headers, data, completed=True) def get_artifacts(self, name=github.GithubObject.NotSet): @@ -4144,11 +3723,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert name is github.GithubObject.NotSet or isinstance(name, str), name - param = { - key: value - for key, value in {"name": name}.items() - if value is not github.GithubObject.NotSet - } + param = {key: value for key, value in {"name": name}.items() if value is not github.GithubObject.NotSet} return github.PaginatedList.PaginatedList( github.Artifact.Artifact, @@ -4165,9 +3740,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Artifact.Artifact` """ assert isinstance(artifact_id, int), artifact_id - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/actions/artifacts/{artifact_id}" - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/artifacts/{artifact_id}") return github.Artifact.Artifact(self._requester, headers, data, completed=True) @@ -4202,12 +3775,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Environment.Environment` """ assert isinstance(environment_name, str), environment_name - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/environments/{environment_name}" - ) - return github.Environment.Environment( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/environments/{environment_name}") + return github.Environment.Environment(self._requester, headers, data, completed=True) def create_environment( self, @@ -4228,12 +3797,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(wait_timer, int) assert isinstance(reviewers, list) assert all( - [ - isinstance( - reviewer, github.EnvironmentProtectionRuleReviewer.ReviewerParams - ) - for reviewer in reviewers - ] + [isinstance(reviewer, github.EnvironmentProtectionRuleReviewer.ReviewerParams) for reviewer in reviewers] ) assert ( isinstance( @@ -4246,17 +3810,13 @@ class Repository(github.GithubObject.CompletableGithubObject): put_parameters = { "wait_timer": wait_timer, "reviewers": [reviewer._asdict() for reviewer in reviewers], - "deployment_branch_policy": deployment_branch_policy._asdict() - if deployment_branch_policy - else None, + "deployment_branch_policy": deployment_branch_policy._asdict() if deployment_branch_policy else None, } headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/environments/{environment_name}", input=put_parameters ) - return github.Environment.Environment( - self._requester, headers, data, completed=True - ) + return github.Environment.Environment(self._requester, headers, data, completed=True) update_environment = create_environment @@ -4268,9 +3828,7 @@ class Repository(github.GithubObject.CompletableGithubObject): """ assert isinstance(environment_name, str), environment_name - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/environments/{environment_name}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/environments/{environment_name}") def _initAttributes(self): self._allow_auto_merge = github.GithubObject.NotSet @@ -4363,27 +3921,17 @@ class Repository(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "allow_auto_merge" in attributes: # pragma no branch - self._allow_auto_merge = self._makeBoolAttribute( - attributes["allow_auto_merge"] - ) + self._allow_auto_merge = self._makeBoolAttribute(attributes["allow_auto_merge"]) if "allow_forking" in attributes: # pragma no branch self._allow_forking = self._makeBoolAttribute(attributes["allow_forking"]) if "allow_merge_commit" in attributes: # pragma no branch - self._allow_merge_commit = self._makeBoolAttribute( - attributes["allow_merge_commit"] - ) + self._allow_merge_commit = self._makeBoolAttribute(attributes["allow_merge_commit"]) if "allow_rebase_merge" in attributes: # pragma no branch - self._allow_rebase_merge = self._makeBoolAttribute( - attributes["allow_rebase_merge"] - ) + self._allow_rebase_merge = self._makeBoolAttribute(attributes["allow_rebase_merge"]) if "allow_squash_merge" in attributes: # pragma no branch - self._allow_squash_merge = self._makeBoolAttribute( - attributes["allow_squash_merge"] - ) + self._allow_squash_merge = self._makeBoolAttribute(attributes["allow_squash_merge"]) if "allow_update_branch" in attributes: # pragma no branch - self._allow_update_branch = self._makeBoolAttribute( - attributes["allow_update_branch"] - ) + self._allow_update_branch = self._makeBoolAttribute(attributes["allow_update_branch"]) if "archived" in attributes: # pragma no branch self._archived = self._makeBoolAttribute(attributes["archived"]) if "archive_url" in attributes: # pragma no branch @@ -4397,9 +3945,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if "clone_url" in attributes: # pragma no branch self._clone_url = self._makeStringAttribute(attributes["clone_url"]) if "collaborators_url" in attributes: # pragma no branch - self._collaborators_url = self._makeStringAttribute( - attributes["collaborators_url"] - ) + self._collaborators_url = self._makeStringAttribute(attributes["collaborators_url"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch @@ -4409,23 +3955,15 @@ class Repository(github.GithubObject.CompletableGithubObject): if "contents_url" in attributes: # pragma no branch self._contents_url = self._makeStringAttribute(attributes["contents_url"]) if "contributors_url" in attributes: # pragma no branch - self._contributors_url = self._makeStringAttribute( - attributes["contributors_url"] - ) + self._contributors_url = self._makeStringAttribute(attributes["contributors_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "default_branch" in attributes: # pragma no branch - self._default_branch = self._makeStringAttribute( - attributes["default_branch"] - ) + self._default_branch = self._makeStringAttribute(attributes["default_branch"]) if "delete_branch_on_merge" in attributes: # pragma no branch - self._delete_branch_on_merge = self._makeBoolAttribute( - attributes["delete_branch_on_merge"] - ) + self._delete_branch_on_merge = self._makeBoolAttribute(attributes["delete_branch_on_merge"]) if "deployments_url" in attributes: # pragma no branch - self._deployments_url = self._makeStringAttribute( - attributes["deployments_url"] - ) + self._deployments_url = self._makeStringAttribute(attributes["deployments_url"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "downloads_url" in attributes: # pragma no branch @@ -4443,9 +3981,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if "full_name" in attributes: # pragma no branch self._full_name = self._makeStringAttribute(attributes["full_name"]) if "git_commits_url" in attributes: # pragma no branch - self._git_commits_url = self._makeStringAttribute( - attributes["git_commits_url"] - ) + self._git_commits_url = self._makeStringAttribute(attributes["git_commits_url"]) if "git_refs_url" in attributes: # pragma no branch self._git_refs_url = self._makeStringAttribute(attributes["git_refs_url"]) if "git_tags_url" in attributes: # pragma no branch @@ -4473,13 +4009,9 @@ class Repository(github.GithubObject.CompletableGithubObject): if "is_template" in attributes: # pragma no branch self._is_template = self._makeBoolAttribute(attributes["is_template"]) if "issue_comment_url" in attributes: # pragma no branch - self._issue_comment_url = self._makeStringAttribute( - attributes["issue_comment_url"] - ) + self._issue_comment_url = self._makeStringAttribute(attributes["issue_comment_url"]) if "issue_events_url" in attributes: # pragma no branch - self._issue_events_url = self._makeStringAttribute( - attributes["issue_events_url"] - ) + self._issue_events_url = self._makeStringAttribute(attributes["issue_events_url"]) if "issues_url" in attributes: # pragma no branch self._issues_url = self._makeStringAttribute(attributes["issues_url"]) if "keys_url" in attributes: # pragma no branch @@ -4495,9 +4027,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if "merges_url" in attributes: # pragma no branch self._merges_url = self._makeStringAttribute(attributes["merges_url"]) if "milestones_url" in attributes: # pragma no branch - self._milestones_url = self._makeStringAttribute( - attributes["milestones_url"] - ) + self._milestones_url = self._makeStringAttribute(attributes["milestones_url"]) if "mirror_url" in attributes: # pragma no branch self._mirror_url = self._makeStringAttribute(attributes["mirror_url"]) if "name" in attributes: # pragma no branch @@ -4505,29 +4035,19 @@ class Repository(github.GithubObject.CompletableGithubObject): if "network_count" in attributes: # pragma no branch self._network_count = self._makeIntAttribute(attributes["network_count"]) if "notifications_url" in attributes: # pragma no branch - self._notifications_url = self._makeStringAttribute( - attributes["notifications_url"] - ) + self._notifications_url = self._makeStringAttribute(attributes["notifications_url"]) if "open_issues" in attributes: # pragma no branch self._open_issues = self._makeIntAttribute(attributes["open_issues"]) if "open_issues_count" in attributes: # pragma no branch - self._open_issues_count = self._makeIntAttribute( - attributes["open_issues_count"] - ) + self._open_issues_count = self._makeIntAttribute(attributes["open_issues_count"]) if "organization" in attributes: # pragma no branch - self._organization = self._makeClassAttribute( - github.Organization.Organization, attributes["organization"] - ) + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) if "owner" in attributes: # pragma no branch - self._owner = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["owner"] - ) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "parent" in attributes: # pragma no branch self._parent = self._makeClassAttribute(Repository, attributes["parent"]) if "permissions" in attributes: # pragma no branch - self._permissions = self._makeClassAttribute( - github.Permissions.Permissions, attributes["permissions"] - ) + self._permissions = self._makeClassAttribute(github.Permissions.Permissions, attributes["permissions"]) if "private" in attributes: # pragma no branch self._private = self._makeBoolAttribute(attributes["private"]) if "pulls_url" in attributes: # pragma no branch @@ -4543,27 +4063,17 @@ class Repository(github.GithubObject.CompletableGithubObject): if "ssh_url" in attributes: # pragma no branch self._ssh_url = self._makeStringAttribute(attributes["ssh_url"]) if "stargazers_count" in attributes: # pragma no branch - self._stargazers_count = self._makeIntAttribute( - attributes["stargazers_count"] - ) + self._stargazers_count = self._makeIntAttribute(attributes["stargazers_count"]) if "stargazers_url" in attributes: # pragma no branch - self._stargazers_url = self._makeStringAttribute( - attributes["stargazers_url"] - ) + self._stargazers_url = self._makeStringAttribute(attributes["stargazers_url"]) if "statuses_url" in attributes: # pragma no branch self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) if "subscribers_url" in attributes: # pragma no branch - self._subscribers_url = self._makeStringAttribute( - attributes["subscribers_url"] - ) + self._subscribers_url = self._makeStringAttribute(attributes["subscribers_url"]) if "subscribers_count" in attributes: # pragma no branch - self._subscribers_count = self._makeIntAttribute( - attributes["subscribers_count"] - ) + self._subscribers_count = self._makeIntAttribute(attributes["subscribers_count"]) if "subscription_url" in attributes: # pragma no branch - self._subscription_url = self._makeStringAttribute( - attributes["subscription_url"] - ) + self._subscription_url = self._makeStringAttribute(attributes["subscription_url"]) if "svn_url" in attributes: # pragma no branch self._svn_url = self._makeStringAttribute(attributes["svn_url"]) if "tags_url" in attributes: # pragma no branch diff --git a/github/Repository.pyi b/github/Repository.pyi index 558f93d6..4598b5cc 100644 --- a/github/Repository.pyi +++ b/github/Repository.pyi @@ -74,9 +74,7 @@ from github.WorkflowRun import WorkflowRun class Repository(CompletableGithubObject): def __repr__(self) -> str: ... - def _hub( - self, mode: str, event: str, callback: str, secret: Union[str, _NotSetType] - ) -> None: ... + def _hub(self, mode: str, event: str, callback: str, secret: Union[str, _NotSetType]) -> None: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... @@ -135,9 +133,7 @@ class Repository(CompletableGithubObject): started_at: Union[_NotSetType, datetime] = ..., conclusion: Union[_NotSetType, str] = ..., completed_at: Union[_NotSetType, datetime] = ..., - output: Union[ - _NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]] - ] = ..., + output: Union[_NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]]] = ..., actions: Union[_NotSetType, List[Dict[str, str]]] = ..., ) -> CheckRun: ... def create_check_suite(self, head_sha: str) -> CheckSuite: ... @@ -160,9 +156,7 @@ class Repository(CompletableGithubObject): environment_name: str, wait_timer: int = ..., reviewers: List[ReviewerParams] = ..., - deployment_branch_policy: Optional[ - EnvironmentDeploymentBranchPolicyParams - ] = ..., + deployment_branch_policy: Optional[EnvironmentDeploymentBranchPolicyParams] = ..., ) -> Environment: ... def create_file( self, @@ -235,12 +229,8 @@ class Repository(CompletableGithubObject): labels: Union[List[Label], _NotSetType, List[str]] = ..., assignees: Union[_NotSetType, List[str], List[NamedUser]] = ..., ) -> Issue: ... - def create_key( - self, title: str, key: str, read_only: bool = ... - ) -> RepositoryKey: ... - def create_label( - self, name: str, color: str, description: Union[str, _NotSetType] = ... - ) -> Label: ... + def create_key(self, title: str, key: str, read_only: bool = ...) -> RepositoryKey: ... + def create_label(self, name: str, color: str, description: Union[str, _NotSetType] = ...) -> Label: ... def create_milestone( self, title: str, @@ -248,9 +238,7 @@ class Repository(CompletableGithubObject): description: Union[str, _NotSetType] = ..., due_on: Union[date, _NotSetType] = ..., ) -> Milestone: ... - def create_project( - self, name: str, body: Union[str, _NotSetType] = ... - ) -> Project: ... + def create_project(self, name: str, body: Union[str, _NotSetType] = ...) -> Project: ... @overload def create_pull( self, @@ -365,13 +353,9 @@ class Repository(CompletableGithubObject): def forks_url(self) -> str: ... @property def full_name(self) -> str: ... - def get_archive_link( - self, archive_format: str, ref: Union[str, _NotSetType] = ... - ) -> str: ... + def get_archive_link(self, archive_format: str, ref: Union[str, _NotSetType] = ...) -> str: ... def get_artifact(self, artifact_id: int) -> Artifact: ... - def get_artifacts( - self, name: Union[str, _NotSetType] = ... - ) -> PaginatedList[Artifact]: ... + def get_artifacts(self, name: Union[str, _NotSetType] = ...) -> PaginatedList[Artifact]: ... def get_codescan_alerts(self) -> PaginatedList[CodeScanAlert]: ... def get_assignees(self) -> PaginatedList[NamedUser]: ... def get_autolinks(self) -> PaginatedList[Autolink]: ... @@ -380,15 +364,9 @@ class Repository(CompletableGithubObject): def get_branches(self) -> PaginatedList[Branch]: ... def get_check_run(self, check_run_id: int) -> CheckRun: ... def get_check_suite(self, check_suite_id: int) -> CheckSuite: ... - def get_clones_traffic( - self, per: Union[str, _NotSetType] = ... - ) -> Dict[str, Union[int, List[Clones]]]: ... - def get_collaborator_permission( - self, collaborator: Union[str, NamedUser] - ) -> str: ... - def get_collaborators( - self, affiliation: Union[str, _NotSetType] = ... - ) -> PaginatedList[NamedUser]: ... + def get_clones_traffic(self, per: Union[str, _NotSetType] = ...) -> Dict[str, Union[int, List[Clones]]]: ... + def get_collaborator_permission(self, collaborator: Union[str, NamedUser]) -> str: ... + def get_collaborators(self, affiliation: Union[str, _NotSetType] = ...) -> PaginatedList[NamedUser]: ... def get_comment(self, id: int) -> CommitComment: ... def get_comments(self) -> PaginatedList[CommitComment]: ... def get_commit(self, sha: str) -> Commit: ... @@ -400,12 +378,8 @@ class Repository(CompletableGithubObject): until: Union[_NotSetType, datetime] = ..., author: Union[AuthenticatedUser, NamedUser, str, _NotSetType] = ..., ) -> PaginatedList[Commit]: ... - def get_contents( - self, path: str, ref: Union[str, _NotSetType] = ... - ) -> Union[List[ContentFile], ContentFile]: ... - def get_contributors( - self, anon: Union[str, _NotSetType] = ... - ) -> PaginatedList[NamedUser]: ... + def get_contents(self, path: str, ref: Union[str, _NotSetType] = ...) -> Union[List[ContentFile], ContentFile]: ... + def get_contributors(self, anon: Union[str, _NotSetType] = ...) -> PaginatedList[NamedUser]: ... def get_deployment(self, id_: int) -> Deployment: ... def get_deployments( self, @@ -414,9 +388,7 @@ class Repository(CompletableGithubObject): task: Union[str, _NotSetType] = ..., environment: Union[str, _NotSetType] = ..., ) -> PaginatedList[Deployment]: ... - def get_dir_contents( - self, path: str, ref: Union[str, _NotSetType] = ... - ) -> List[ContentFile]: ... + def get_dir_contents(self, path: str, ref: Union[str, _NotSetType] = ...) -> List[ContentFile]: ... def get_download(self, id: int) -> Download: ... def get_downloads(self) -> PaginatedList[Download]: ... def get_environments(self) -> PaginatedList[Environment]: ... @@ -435,15 +407,11 @@ class Repository(CompletableGithubObject): def get_git_ref(self, ref: str) -> GitRef: ... def get_git_refs(self) -> PaginatedList[GitRef]: ... def get_git_tag(self, sha: str) -> GitTag: ... - def get_git_tree( - self, sha: str, recursive: Union[bool, _NotSetType] = ... - ) -> GitTree: ... + def get_git_tree(self, sha: str, recursive: Union[bool, _NotSetType] = ...) -> GitTree: ... def get_hook(self, id: int) -> Hook: ... def get_hooks(self) -> PaginatedList[Hook]: ... def get_hook_delivery(self, hook_id: int, delivery_id: int) -> HookDelivery: ... - def get_hook_deliveries( - self, hook_id: int - ) -> PaginatedList[HookDeliverySummary]: ... + def get_hook_deliveries(self, hook_id: int) -> PaginatedList[HookDeliverySummary]: ... def get_issue(self, number: int) -> Issue: ... def get_issues( self, @@ -488,9 +456,7 @@ class Repository(CompletableGithubObject): before: Union[datetime, _NotSetType] = ..., ) -> PaginatedList[Notification]: ... def get_pending_invitations(self) -> PaginatedList[Invitation]: ... - def get_projects( - self, state: Union[str, _NotSetType] = ... - ) -> PaginatedList[Project]: ... + def get_projects(self, state: Union[str, _NotSetType] = ...) -> PaginatedList[Project]: ... def get_public_key(self) -> PublicKey: ... def get_pull(self, number: int) -> PullRequest: ... def get_pulls( @@ -533,9 +499,7 @@ class Repository(CompletableGithubObject): def get_top_paths(self) -> List[Path]: ... def get_top_referrers(self) -> List[Referrer]: ... def get_topics(self) -> List[str]: ... - def get_views_traffic( - self, per: Union[str, _NotSetType] = ... - ) -> Dict[str, Union[int, List[View]]]: ... + def get_views_traffic(self, per: Union[str, _NotSetType] = ...) -> Dict[str, Union[int, List[View]]]: ... def get_vulnerability_alert(self) -> bool: ... def get_watchers(self) -> PaginatedList[NamedUser]: ... def get_workflow(self, id_or_name: Union[str, int]) -> Workflow: ... @@ -601,9 +565,7 @@ class Repository(CompletableGithubObject): def mark_notifications_as_read(self, last_read_at: datetime = ...) -> None: ... @property def master_branch(self) -> Optional[str]: ... - def merge( - self, base: str, head: str, commit_message: Union[str, _NotSetType] = ... - ) -> Optional[Commit]: ... + def merge(self, base: str, head: str, commit_message: Union[str, _NotSetType] = ...) -> Optional[Commit]: ... @property def merges_url(self) -> str: ... @property @@ -637,12 +599,8 @@ class Repository(CompletableGithubObject): @property def releases_url(self) -> str: ... def remove_autolink(self, autolink: Union[Autolink, int]) -> bool: ... - def remove_from_collaborators( - self, collaborator: Union[str, NamedUser] - ) -> None: ... - def remove_self_hosted_runner( - self, runner: Union[SelfHostedActionsRunner, int] - ) -> bool: ... + def remove_from_collaborators(self, collaborator: Union[str, NamedUser]) -> None: ... + def remove_self_hosted_runner(self, runner: Union[SelfHostedActionsRunner, int]) -> bool: ... def remove_invitation(self, invite_id: int) -> None: ... def replace_topics(self, topics: List[str]) -> None: ... @property @@ -657,9 +615,7 @@ class Repository(CompletableGithubObject): def stargazers_url(self) -> str: ... @property def statuses_url(self) -> str: ... - def subscribe_to_hub( - self, event: str, callback: str, secret: Union[str, _NotSetType] = ... - ) -> None: ... + def subscribe_to_hub(self, event: str, callback: str, secret: Union[str, _NotSetType] = ...) -> None: ... @property def subscribers_count(self) -> int: ... @property @@ -682,9 +638,7 @@ class Repository(CompletableGithubObject): environment_name: str, wait_timer: int = ..., reviewers: List[ReviewerParams] = ..., - deployment_branch_policy: Optional[ - EnvironmentDeploymentBranchPolicyParams - ] = ..., + deployment_branch_policy: Optional[EnvironmentDeploymentBranchPolicyParams] = ..., ) -> Environment: ... def update_file( self, diff --git a/github/RepositoryAdvisory.py b/github/RepositoryAdvisory.py index 9de08e7f..75780f99 100644 --- a/github/RepositoryAdvisory.py +++ b/github/RepositoryAdvisory.py @@ -28,10 +28,7 @@ import github.NamedUser from github.CWE import CWE from github.RepositoryAdvisoryCredit import Credit, RepositoryAdvisoryCredit from github.RepositoryAdvisoryCreditDetailed import RepositoryAdvisoryCreditDetailed -from github.RepositoryAdvisoryVulnerability import ( - AdvisoryVulnerability, - RepositoryAdvisoryVulnerability, -) +from github.RepositoryAdvisoryVulnerability import AdvisoryVulnerability, RepositoryAdvisoryVulnerability from github.Requester import Requester @@ -215,9 +212,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): ] ) - def add_vulnerabilities( - self, vulnerabilities: typing.Iterable[AdvisoryVulnerability] - ): + def add_vulnerabilities(self, vulnerabilities: typing.Iterable[AdvisoryVulnerability]): """ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` :param vulnerabilities: iterable of :class:`github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability` @@ -231,9 +226,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): # noinspection PyProtectedMember post_parameters = { "vulnerabilities": [ - github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict( - vulnerability - ) + github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict(vulnerability) for vulnerability in (self.vulnerabilities + list(vulnerabilities)) ] } @@ -274,10 +267,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): RepositoryAdvisoryCredit._validate_credit(credit) # noinspection PyProtectedMember patch_parameters = { - "credits": [ - RepositoryAdvisoryCredit._to_github_dict(credit) - for credit in (self.credits + list(credited)) - ] + "credits": [RepositoryAdvisoryCredit._to_github_dict(credit) for credit in (self.credits + list(credited))] } headers, data = self._requester.requestJsonAndCheck( "PATCH", @@ -286,23 +276,17 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): ) self._useAttributes(data) - def revoke_credit( - self, login_or_user: typing.Union[str, "github.NamedUser.NamedUser"] - ): + def revoke_credit(self, login_or_user: typing.Union[str, "github.NamedUser.NamedUser"]): """ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id `_ :param login_or_user: string username or :class:`github.NamedUser.NamedUser` """ - assert isinstance( - login_or_user, (str, github.NamedUser.NamedUser) - ), login_or_user + assert isinstance(login_or_user, (str, github.NamedUser.NamedUser)), login_or_user if isinstance(login_or_user, github.NamedUser.NamedUser): login_or_user = login_or_user.login patch_parameters = { "credits": [ - dict(login=credit.login, type=credit.type) - for credit in self.credits - if credit.login != login_or_user + dict(login=credit.login, type=credit.type) for credit in self.credits if credit.login != login_or_user ] } headers, data = self._requester.requestJsonAndCheck( @@ -328,19 +312,11 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): self, summary: github.GithubObject.Opt[str] = github.GithubObject.NotSet, description: github.GithubObject.Opt[str] = github.GithubObject.NotSet, - severity_or_cvss_vector_string: github.GithubObject.Opt[ - str - ] = github.GithubObject.NotSet, + severity_or_cvss_vector_string: github.GithubObject.Opt[str] = github.GithubObject.NotSet, cve_id: github.GithubObject.Opt[str] = github.GithubObject.NotSet, - vulnerabilities: github.GithubObject.Opt[ - typing.Iterable[AdvisoryVulnerability] - ] = github.GithubObject.NotSet, - cwe_ids: github.GithubObject.Opt[ - typing.Iterable[str] - ] = github.GithubObject.NotSet, - credits: github.GithubObject.Opt[ - typing.Iterable[Credit] - ] = github.GithubObject.NotSet, + vulnerabilities: github.GithubObject.Opt[typing.Iterable[AdvisoryVulnerability]] = github.GithubObject.NotSet, + cwe_ids: github.GithubObject.Opt[typing.Iterable[str]] = github.GithubObject.NotSet, + credits: github.GithubObject.Opt[typing.Iterable[Credit]] = github.GithubObject.NotSet, state: github.GithubObject.Opt[str] = github.GithubObject.NotSet, ) -> "RepositoryAdvisory": """ @@ -355,16 +331,11 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): :param state: string :rtype: :class:`github.RepositoryAdvisory.RepositoryAdvisory` """ - assert summary is github.GithubObject.NotSet or isinstance( - summary, str - ), summary - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert ( - severity_or_cvss_vector_string is github.GithubObject.NotSet - or isinstance(severity_or_cvss_vector_string, str) - ), (severity_or_cvss_vector_string) + assert summary is github.GithubObject.NotSet or isinstance(summary, str), summary + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert severity_or_cvss_vector_string is github.GithubObject.NotSet or isinstance( + severity_or_cvss_vector_string, str + ), severity_or_cvss_vector_string assert cve_id is github.GithubObject.NotSet or isinstance(cve_id, str), cve_id assert vulnerabilities is github.GithubObject.NotSet or isinstance( vulnerabilities, typing.Iterable @@ -376,15 +347,12 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): vulnerability ) assert cwe_ids is github.GithubObject.NotSet or ( - isinstance(cwe_ids, typing.Iterable) - and all(isinstance(element, str) for element in cwe_ids) + isinstance(cwe_ids, typing.Iterable) and all(isinstance(element, str) for element in cwe_ids) ), cwe_ids if isinstance(credits, typing.Iterable): for credit in credits: # noinspection PyProtectedMember - github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._validate_credit( - credit - ) + github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._validate_credit(credit) assert state is github.GithubObject.NotSet or isinstance(state, str), state patch_parameters: typing.Dict[str, typing.Any] = dict() if summary is not github.GithubObject.NotSet: @@ -401,9 +369,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): if isinstance(vulnerabilities, typing.Iterable): # noinspection PyProtectedMember patch_parameters["vulnerabilities"] = [ - github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict( - vulnerability - ) + github.RepositoryAdvisoryVulnerability.RepositoryAdvisoryVulnerability._to_github_dict(vulnerability) for vulnerability in vulnerabilities ] if isinstance(cwe_ids, typing.Iterable): @@ -411,10 +377,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): if isinstance(credits, typing.Iterable): # noinspection PyProtectedMember patch_parameters["credits"] = [ - github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._to_github_dict( - credit - ) - for credit in credits + github.RepositoryAdvisoryCredit.RepositoryAdvisoryCredit._to_github_dict(credit) for credit in credits ] if state is not github.GithubObject.NotSet: patch_parameters["state"] = state @@ -491,18 +454,14 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): # noinspection PyPep8Naming def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - self._author = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["author"] - ) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "closed_at" in attributes: # pragma no branch - assert attributes["closed_at"] is None or isinstance( - attributes["closed_at"], str - ), attributes["closed_at"] + assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], str), attributes["closed_at"] self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance( - attributes["created_at"], str - ), attributes["created_at"] + assert attributes["created_at"] is None or isinstance(attributes["created_at"], str), attributes[ + "created_at" + ] self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "credits" in attributes: # pragma no branch self._credits = self._makeListOfClassesAttribute( @@ -527,9 +486,9 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "published_at" in attributes: # pragma no branch - assert attributes["published_at"] is None or isinstance( - attributes["published_at"], str - ), attributes["published_at"] + assert attributes["published_at"] is None or isinstance(attributes["published_at"], str), attributes[ + "published_at" + ] self._published_at = self._makeDatetimeAttribute(attributes["published_at"]) if "severity" in attributes: # pragma no branch self._severity = self._makeStringAttribute(attributes["severity"]) @@ -538,9 +497,9 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): if "summary" in attributes: # pragma no branch self._summary = self._makeStringAttribute(attributes["summary"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance( - attributes["updated_at"], str - ), attributes["updated_at"] + assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], str), attributes[ + "updated_at" + ] self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) @@ -550,7 +509,7 @@ class RepositoryAdvisory(github.GithubObject.NonCompletableGithubObject): attributes["vulnerabilities"], ) if "withdrawn_at" in attributes: # pragma no branch - assert attributes["withdrawn_at"] is None or isinstance( - attributes["withdrawn_at"], str - ), attributes["withdrawn_at"] + assert attributes["withdrawn_at"] is None or isinstance(attributes["withdrawn_at"], str), attributes[ + "withdrawn_at" + ] self._withdrawn_at = self._makeDatetimeAttribute(attributes["withdrawn_at"]) diff --git a/github/RepositoryAdvisoryCredit.py b/github/RepositoryAdvisoryCredit.py index d07c9825..99bd9359 100644 --- a/github/RepositoryAdvisoryCredit.py +++ b/github/RepositoryAdvisoryCredit.py @@ -78,9 +78,7 @@ class RepositoryAdvisoryCredit(github.GithubObject.NonCompletableGithubObject): if isinstance(credit, dict): assert "login" in credit, credit assert "type" in credit, credit - assert isinstance( - credit["login"], (str, github.NamedUser.NamedUser) - ), credit["login"] + assert isinstance(credit["login"], (str, github.NamedUser.NamedUser)), credit["login"] assert isinstance(credit["type"], str), credit["type"] else: assert isinstance(credit.login, str), credit.login @@ -92,9 +90,7 @@ class RepositoryAdvisoryCredit(github.GithubObject.NonCompletableGithubObject): if isinstance(credit, dict): assert "login" in credit, credit assert "type" in credit, credit - assert isinstance( - credit["login"], (str, github.NamedUser.NamedUser) - ), credit["login"] + assert isinstance(credit["login"], (str, github.NamedUser.NamedUser)), credit["login"] login = credit["login"] if isinstance(login, github.NamedUser.NamedUser): login = login.login diff --git a/github/RepositoryAdvisoryCreditDetailed.py b/github/RepositoryAdvisoryCreditDetailed.py index a26524c0..9ceed418 100644 --- a/github/RepositoryAdvisoryCreditDetailed.py +++ b/github/RepositoryAdvisoryCreditDetailed.py @@ -65,6 +65,4 @@ class RepositoryAdvisoryCreditDetailed(github.GithubObject.NonCompletableGithubO if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "user" in attributes: # pragma no branch - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/RepositoryAdvisoryVulnerability.py b/github/RepositoryAdvisoryVulnerability.py index 236e9f0f..e91118bf 100644 --- a/github/RepositoryAdvisoryVulnerability.py +++ b/github/RepositoryAdvisoryVulnerability.py @@ -48,9 +48,7 @@ class SimpleAdvisoryVulnerability(TypedDict): vulnerable_version_range: NotRequired[Optional[str]] -AdvisoryVulnerability = Union[ - SimpleAdvisoryVulnerability, "RepositoryAdvisoryVulnerability" -] +AdvisoryVulnerability = Union[SimpleAdvisoryVulnerability, "RepositoryAdvisoryVulnerability"] class RepositoryAdvisoryVulnerability(github.GithubObject.NonCompletableGithubObject): @@ -104,17 +102,11 @@ class RepositoryAdvisoryVulnerability(github.GithubObject.NonCompletableGithubOb attributes["package"], ) if "patched_versions" in attributes: # pragma no branch - self._patched_versions = self._makeStringAttribute( - attributes["patched_versions"] - ) + self._patched_versions = self._makeStringAttribute(attributes["patched_versions"]) if "vulnerable_functions" in attributes: # pragma no branch - self._vulnerable_functions = self._makeListOfStringsAttribute( - attributes["vulnerable_functions"] - ) + self._vulnerable_functions = self._makeListOfStringsAttribute(attributes["vulnerable_functions"]) if "vulnerable_version_range" in attributes: # pragma no branch - self._vulnerable_version_range = self._makeStringAttribute( - attributes["vulnerable_version_range"] - ) + self._vulnerable_version_range = self._makeStringAttribute(attributes["vulnerable_version_range"]) @classmethod def _validate_vulnerability(cls, vulnerability: AdvisoryVulnerability) -> None: @@ -128,13 +120,9 @@ class RepositoryAdvisoryVulnerability(github.GithubObject.NonCompletableGithubOb assert "name" in package, package assert isinstance(package["name"], (str, type(None))), package assert "patched_versions" in vulnerability, vulnerability - assert isinstance( - vulnerability["patched_versions"], (str, type(None)) - ), vulnerability + assert isinstance(vulnerability["patched_versions"], (str, type(None))), vulnerability assert "vulnerable_functions" in vulnerability, vulnerability - assert isinstance( - vulnerability["vulnerable_functions"], (list, type(None)) - ), vulnerability + assert isinstance(vulnerability["vulnerable_functions"], (list, type(None))), vulnerability assert "vulnerable_functions" in vulnerability, vulnerability assert ( all(isinstance(vf, str) for vf in vulnerability["vulnerable_functions"]) @@ -142,9 +130,7 @@ class RepositoryAdvisoryVulnerability(github.GithubObject.NonCompletableGithubOb else True ), vulnerability assert "vulnerable_version_range" in vulnerability, vulnerability - assert isinstance( - vulnerability["vulnerable_version_range"], (str, type(None)) - ), vulnerability + assert isinstance(vulnerability["vulnerable_version_range"], (str, type(None))), vulnerability else: assert ( @@ -157,9 +143,7 @@ class RepositoryAdvisoryVulnerability(github.GithubObject.NonCompletableGithubOb vulnerability: AdvisoryVulnerability, ) -> SimpleAdvisoryVulnerability: if isinstance(vulnerability, dict): - vulnerability_package: SimpleAdvisoryVulnerabilityPackage = vulnerability[ - "package" - ] + vulnerability_package: SimpleAdvisoryVulnerabilityPackage = vulnerability["package"] return { "package": { "ecosystem": vulnerability_package["ecosystem"], diff --git a/github/RepositoryAdvisoryVulnerabilityPackage.py b/github/RepositoryAdvisoryVulnerabilityPackage.py index bf8dd529..41ecc941 100644 --- a/github/RepositoryAdvisoryVulnerabilityPackage.py +++ b/github/RepositoryAdvisoryVulnerabilityPackage.py @@ -25,9 +25,7 @@ from typing import Optional import github.GithubObject -class RepositoryAdvisoryVulnerabilityPackage( - github.GithubObject.NonCompletableGithubObject -): +class RepositoryAdvisoryVulnerabilityPackage(github.GithubObject.NonCompletableGithubObject): """ This class represents an identifier for a package that is vulnerable to a parent SecurityAdvisory. The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories diff --git a/github/RepositoryPreferences.py b/github/RepositoryPreferences.py index ae01de82..93829df5 100644 --- a/github/RepositoryPreferences.py +++ b/github/RepositoryPreferences.py @@ -53,6 +53,4 @@ class RepositoryPreferences(NonCompletableGithubObject): if "preferences" in attributes: # pragma no branch self._preferences = self._makeDictAttribute(attributes["preferences"]) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) diff --git a/github/Requester.py b/github/Requester.py index 532f5c5d..e9e50b52 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -63,20 +63,7 @@ import urllib.parse from collections import defaultdict from datetime import datetime, timezone from io import IOBase -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Generic, - ItemsView, - List, - Optional, - Tuple, - Type, - TypeVar, - Union, -) +from typing import TYPE_CHECKING, Any, Callable, Dict, Generic, ItemsView, List, Optional, Tuple, Type, TypeVar, Union import requests import requests.adapters @@ -300,18 +287,14 @@ class Requester: """ if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests) new_frame = [requestHeader, None, None, None] - if ( - self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1 - ): # pragma no branch (Should be covered) + if self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1: # pragma no branch (Should be covered) self._frameBuffer.append(new_frame) else: self._frameBuffer[0] = new_frame # pragma no cover (Should be covered) self._frameCount = len(self._frameBuffer) - 1 - def DEBUG_ON_RESPONSE( - self, statusCode: int, responseHeader: Dict[str, Union[str, int]], data: str - ): + def DEBUG_ON_RESPONSE(self, statusCode: int, responseHeader: Dict[str, Union[str, int]], data: str): """ Update current frame with response Current frame index will be attached to responseHeader @@ -325,9 +308,7 @@ class Requester: responseHeader[self.DEBUG_HEADER_KEY] = self._frameCount def check_me(self, obj: "GithubObject"): - if ( - self.DEBUG_FLAG and self.ON_CHECK_ME is not None - ): # pragma no branch (Flag always set in tests) + if self.DEBUG_FLAG and self.ON_CHECK_ME is not None: # pragma no branch (Flag always set in tests) frame = None if self.DEBUG_HEADER_KEY in obj._headers: frame_index = obj._headers[self.DEBUG_HEADER_KEY] @@ -341,9 +322,7 @@ class Requester: ############################################################# _frameCount: int - __connectionClass: Union[ - Type[HTTPRequestsConnectionClass], Type[HTTPSRequestsConnectionClass] - ] + __connectionClass: Union[Type[HTTPRequestsConnectionClass], Type[HTTPSRequestsConnectionClass]] __hostname: str __authorizationHeader: Optional[str] __last_requests: Dict[str, float] @@ -452,11 +431,7 @@ class Requester: headers: Optional[Dict[str, str]] = None, input: Optional[Any] = None, ) -> Tuple[Dict[str, Any], Any]: - return self.__check( - *self.requestJson( - verb, url, parameters, headers, input, self.__customConnection(url) - ) - ) + return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url))) def requestMultipartAndCheck( self, @@ -466,11 +441,7 @@ class Requester: headers: Optional[Dict[str, Any]] = None, input: Optional[Dict[str, str]] = None, ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]: - return self.__check( - *self.requestMultipart( - verb, url, parameters, headers, input, self.__customConnection(url) - ) - ) + return self.__check(*self.requestMultipart(verb, url, parameters, headers, input, self.__customConnection(url))) def requestBlobAndCheck( self, @@ -479,15 +450,9 @@ class Requester: parameters: Optional[Dict[str, str]] = None, headers: Optional[Dict[str, str]] = None, input: Optional[str] = None, - cnx: Optional[ - Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] - ] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: - return self.__check( - *self.requestBlob( - verb, url, parameters, headers, input, self.__customConnection(url) - ) - ) + return self.__check(*self.requestBlob(verb, url, parameters, headers, input, self.__customConnection(url))) def __check( self, @@ -503,18 +468,13 @@ class Requester: def __customConnection( self, url: str ) -> Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]]: - cnx: Optional[ - Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] - ] = None + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None if not url.startswith("/"): o = urllib.parse.urlparse(url) if ( o.hostname != self.__hostname or (o.port and o.port != self.__port) - or ( - o.scheme != self.__scheme - and not (o.scheme == "https" and self.__scheme == "http") - ) + or (o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http")) ): # issue80 if o.scheme == "http": cnx = self.__httpConnectionClass( @@ -544,15 +504,9 @@ class Requester: exc = GithubException.GithubException if status == 401 and message == "bad credentials": exc = GithubException.BadCredentialsException - elif ( - status == 401 - and Consts.headerOTP in headers - and re.match(r".*required.*", headers[Consts.headerOTP]) - ): + elif status == 401 and Consts.headerOTP in headers and re.match(r".*required.*", headers[Consts.headerOTP]): exc = GithubException.TwoFactorException - elif status == 403 and message.startswith( - "missing or invalid user agent string" - ): + elif status == 403 and message.startswith("missing or invalid user agent string"): exc = GithubException.BadUserAgentException elif status == 403 and cls.isRateLimitError(message): exc = GithubException.RateLimitExceededException @@ -563,9 +517,7 @@ class Requester: @classmethod def isRateLimitError(cls, message: str) -> bool: - return cls.isPrimaryRateLimitError(message) or cls.isSecondaryRateLimitError( - message - ) + return cls.isPrimaryRateLimitError(message) or cls.isSecondaryRateLimitError(message) @classmethod def isPrimaryRateLimitError(cls, message: str) -> bool: @@ -607,9 +559,7 @@ class Requester: parameters: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, Any]] = None, input: Optional[Any] = None, - cnx: Optional[ - Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] - ] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, ) -> Tuple[int, Dict[str, Any], str]: def encode(input): return "application/json", json.dumps(input) @@ -623,9 +573,7 @@ class Requester: parameters: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, Any]] = None, input: Optional[Dict[str, str]] = None, - cnx: Optional[ - Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] - ] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, ) -> Tuple[int, Dict[str, Any], str]: def encode(input): boundary = "----------------------------3c3ba8b523b2" @@ -649,9 +597,7 @@ class Requester: parameters: Optional[Dict[str, str]] = None, headers: Optional[Dict[str, str]] = None, input: Optional[str] = None, - cnx: Optional[ - Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] - ] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, ) -> Tuple[int, Dict[str, Any], str]: if headers is None: headers = {} @@ -661,11 +607,7 @@ class Requester: mime_type = headers["Content-Type"] # type: ignore else: guessed_type = mimetypes.guess_type(local_path) - mime_type = ( - guessed_type[0] - if guessed_type[0] is not None - else Consts.defaultMediaType - ) + mime_type = guessed_type[0] if guessed_type[0] is not None else Consts.defaultMediaType f = open(local_path, "rb") return mime_type, f @@ -673,20 +615,14 @@ class Requester: headers["Content-Length"] = str(os.path.getsize(input)) return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) - def requestMemoryBlobAndCheck( - self, verb, url, parameters, headers, file_like, cnx=None - ): + def requestMemoryBlobAndCheck(self, verb, url, parameters, headers, file_like, cnx=None): # The expected signature of encode means that the argument is ignored. def encode(_): return headers["Content-Type"], file_like if not cnx: cnx = self.__customConnection(url) - return self.__check( - *self.__requestEncode( - cnx, verb, url, parameters, headers, file_like, encode - ) - ) + return self.__check(*self.__requestEncode(cnx, verb, url, parameters, headers, file_like, encode)) def __requestEncode( self, @@ -705,9 +641,7 @@ class Requester: requestHeaders = {} if self.__auth is not None: - requestHeaders[ - "Authorization" - ] = f"{self.__auth.token_type} {self.__auth.token}" + requestHeaders["Authorization"] = f"{self.__auth.token_type} {self.__auth.token}" requestHeaders["User-Agent"] = self.__userAgent url = self.__makeAbsoluteUrl(url) @@ -719,14 +653,9 @@ class Requester: self.NEW_DEBUG_FRAME(requestHeaders) - status, responseHeaders, output = self.__requestRaw( - cnx, verb, url, requestHeaders, encoded_input - ) + status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input) - if ( - Consts.headerRateRemaining in responseHeaders - and Consts.headerRateLimit in responseHeaders - ): + if Consts.headerRateRemaining in responseHeaders and Consts.headerRateLimit in responseHeaders: self.rate_limiting = ( int(responseHeaders[Consts.headerRateRemaining]), int(responseHeaders[Consts.headerRateLimit]), @@ -767,9 +696,7 @@ class Requester: if isinstance(input, IOBase): input.close() - self.__log( - verb, url, requestHeaders, input, status, responseHeaders, output - ) + self.__log(verb, url, requestHeaders, input, status, responseHeaders, output) if status == 202 and ( verb == "GET" or verb == "HEAD" @@ -792,21 +719,15 @@ class Requester: ) if o.path == url: port = ":" + str(self.__port) if self.__port is not None else "" - requested_location = ( - f"{self.__scheme}://{self.__hostname}{port}{url}" - ) + requested_location = f"{self.__scheme}://{self.__hostname}{port}{url}" raise RuntimeError( f"Requested {requested_location} but server redirected to {location}, " f"you may need to correct your Github server URL " f"via base_url: Github(base_url=...)" ) if self._logger.isEnabledFor(logging.INFO): - self._logger.info( - f"Following Github server redirection from {url} to {o.path}" - ) - return self.__requestRaw( - original_cnx, verb, o.path, requestHeaders, input - ) + self._logger.info(f"Following Github server redirection from {url} to {o.path}") + return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input) return status, responseHeaders, output finally: @@ -824,16 +745,8 @@ class Requester: last_request = max(requests) if requests else 0 last_write = max(writes) if writes else 0 - next_request = ( - (last_request + self.__seconds_between_requests) - if self.__seconds_between_requests - else 0 - ) - next_write = ( - (last_write + self.__seconds_between_writes) - if self.__seconds_between_writes - else 0 - ) + next_request = (last_request + self.__seconds_between_requests) if self.__seconds_between_requests else 0 + next_write = (last_write + self.__seconds_between_writes) if self.__seconds_between_writes else 0 next = next_request if verb == "GET" else max(next_request, next_write) defer = max(next - datetime.now(timezone.utc).timestamp(), 0) @@ -914,9 +827,7 @@ class Requester: headersForRequest = requestHeaders.copy() if "Authorization" in requestHeaders: if requestHeaders["Authorization"].startswith("Basic"): - headersForRequest[ - "Authorization" - ] = "Basic (login and password removed)" + headersForRequest["Authorization"] = "Basic (login and password removed)" elif requestHeaders["Authorization"].startswith("token"): headersForRequest["Authorization"] = "token (oauth token removed)" elif requestHeaders["Authorization"].startswith("Bearer"): diff --git a/github/RequiredPullRequestReviews.py b/github/RequiredPullRequestReviews.py index 885acccb..9ae61613 100644 --- a/github/RequiredPullRequestReviews.py +++ b/github/RequiredPullRequestReviews.py @@ -97,13 +97,9 @@ class RequiredPullRequestReviews(github.GithubObject.CompletableGithubObject): github.Team.Team, attributes["dismissal_restrictions"]["teams"] ) if "dismiss_stale_reviews" in attributes: # pragma no branch - self._dismiss_stale_reviews = self._makeBoolAttribute( - attributes["dismiss_stale_reviews"] - ) + self._dismiss_stale_reviews = self._makeBoolAttribute(attributes["dismiss_stale_reviews"]) if "require_code_owner_reviews" in attributes: # pragma no branch - self._require_code_owner_reviews = self._makeBoolAttribute( - attributes["require_code_owner_reviews"] - ) + self._require_code_owner_reviews = self._makeBoolAttribute(attributes["require_code_owner_reviews"]) if "required_approving_review_count" in attributes: # pragma no branch self._required_approving_review_count = self._makeIntAttribute( attributes["required_approving_review_count"] diff --git a/github/SourceImport.py b/github/SourceImport.py index 66d71391..8c26244a 100644 --- a/github/SourceImport.py +++ b/github/SourceImport.py @@ -168,23 +168,15 @@ class SourceImport(github.GithubObject.CompletableGithubObject): if "authors_url" in attributes: # pragma no branch self._authors_url = self._makeStringAttribute(attributes["authors_url"]) if "has_large_files" in attributes: # pragma no branch - self._has_large_files = self._makeBoolAttribute( - attributes["has_large_files"] - ) + self._has_large_files = self._makeBoolAttribute(attributes["has_large_files"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "large_files_count" in attributes: # pragma no branch - self._large_files_count = self._makeIntAttribute( - attributes["large_files_count"] - ) + self._large_files_count = self._makeIntAttribute(attributes["large_files_count"]) if "large_files_size" in attributes: # pragma no branch - self._large_files_size = self._makeIntAttribute( - attributes["large_files_size"] - ) + self._large_files_size = self._makeIntAttribute(attributes["large_files_size"]) if "repository_url" in attributes: # pragma no branch - self._repository_url = self._makeStringAttribute( - attributes["repository_url"] - ) + self._repository_url = self._makeStringAttribute(attributes["repository_url"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "status_text" in attributes: # pragma no branch diff --git a/github/Stargazer.py b/github/Stargazer.py index 94bf1917..eeee4b35 100644 --- a/github/Stargazer.py +++ b/github/Stargazer.py @@ -60,6 +60,4 @@ class Stargazer(NonCompletableGithubObject): if "starred_at" in attributes: self._starred_at = self._makeDatetimeAttribute(attributes["starred_at"]) if "user" in attributes: - self._user = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["user"] - ) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/StatsContributor.py b/github/StatsContributor.py index a5817f7e..4e537335 100755 --- a/github/StatsContributor.py +++ b/github/StatsContributor.py @@ -110,12 +110,8 @@ class StatsContributor(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - self._author = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["author"] - ) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "total" in attributes: # pragma no branch self._total = self._makeIntAttribute(attributes["total"]) if "weeks" in attributes: # pragma no branch - self._weeks = self._makeListOfClassesAttribute( - self.Week, attributes["weeks"] - ) + self._weeks = self._makeListOfClassesAttribute(self.Week, attributes["weeks"]) diff --git a/github/Tag.py b/github/Tag.py index 9fac78bf..2750f9a0 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -45,9 +45,7 @@ class Tag(NonCompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"name": self._name.value, "commit": self._commit.value} - ) + return self.get__repr__({"name": self._name.value, "commit": self._commit.value}) def _initAttributes(self) -> None: self._commit: Attribute[Commit] = NotSet @@ -73,9 +71,7 @@ class Tag(NonCompletableGithubObject): def _useAttributes(self, attributes) -> None: if "commit" in attributes: # pragma no branch - self._commit = self._makeClassAttribute( - github.Commit.Commit, attributes["commit"] - ) + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "tarball_url" in attributes: # pragma no branch diff --git a/github/Team.py b/github/Team.py index e71f3fd8..af71b63c 100644 --- a/github/Team.py +++ b/github/Team.py @@ -182,9 +182,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.url}/members/{member._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/members/{member._identity}") def add_membership(self, member, role=github.GithubObject.NotSet): """ @@ -214,17 +212,11 @@ class Team(github.GithubObject.CompletableGithubObject): :param member: string or :class:`github.NamedUser.NamedUser` :rtype: :class:`github.Membership.Membership` """ - assert isinstance(member, str) or isinstance( - member, github.NamedUser.NamedUser - ), member + assert isinstance(member, str) or isinstance(member, github.NamedUser.NamedUser), member if isinstance(member, github.NamedUser.NamedUser): member = member._identity - headers, data = self._requester.requestJsonAndCheck( - "GET", f"{self.url}/memberships/{member}" - ) - return github.Membership.Membership( - self._requester, headers, data, completed=True - ) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/memberships/{member}") + return github.Membership.Membership(self._requester, headers, data, completed=True) def add_to_repos(self, repo): """ @@ -233,9 +225,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(repo, github.Repository.Repository), repo - headers, data = self._requester.requestJsonAndCheck( - "PUT", f"{self.url}/repos/{repo._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/repos/{repo._identity}") def get_repo_permission(self, repo): """ @@ -243,9 +233,7 @@ class Team(github.GithubObject.CompletableGithubObject): :param repo: string or :class:`github.Repository.Repository` :rtype: None or :class:`github.Permissions.Permissions` """ - assert isinstance(repo, github.Repository.Repository) or isinstance( - repo, str - ), repo + assert isinstance(repo, github.Repository.Repository) or isinstance(repo, str), repo if isinstance(repo, github.Repository.Repository): repo = repo._identity try: @@ -254,9 +242,7 @@ class Team(github.GithubObject.CompletableGithubObject): f"{self.url}/repos/{repo}", headers={"Accept": Consts.teamRepositoryPermissions}, ) - return github.Permissions.Permissions( - self._requester, headers, data["permissions"], completed=True - ) + return github.Permissions.Permissions(self._requester, headers, data["permissions"], completed=True) except UnknownObjectException: return None @@ -288,9 +274,7 @@ class Team(github.GithubObject.CompletableGithubObject): :param permission: string :rtype: bool """ - assert isinstance(repo, github.Repository.Repository) or isinstance( - repo, str - ), repo + assert isinstance(repo, github.Repository.Repository) or isinstance(repo, str), repo assert isinstance(permission, str), permission repo_url_param = repo if isinstance(repo, github.Repository.Repository): @@ -328,15 +312,9 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(name, str), name - assert description is github.GithubObject.NotSet or isinstance( - description, str - ), description - assert permission is github.GithubObject.NotSet or isinstance( - permission, str - ), permission - assert privacy is github.GithubObject.NotSet or isinstance( - privacy, str - ), privacy + assert description is github.GithubObject.NotSet or isinstance(description, str), description + assert permission is github.GithubObject.NotSet or isinstance(permission, str), permission + assert privacy is github.GithubObject.NotSet or isinstance(privacy, str), privacy post_parameters = { "name": name, } @@ -346,9 +324,7 @@ class Team(github.GithubObject.CompletableGithubObject): post_parameters["permission"] = permission if privacy is not github.GithubObject.NotSet: post_parameters["privacy"] = privacy - headers, data = self._requester.requestJsonAndCheck( - "PATCH", self.url, input=post_parameters - ) + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) self._useAttributes(data) def get_teams(self): @@ -423,9 +399,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(member, github.NamedUser.NamedUser), member - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/members/{member._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/members/{member._identity}") return status == 204 def has_in_repos(self, repo): @@ -435,9 +409,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: bool """ assert isinstance(repo, github.Repository.Repository), repo - status, headers, data = self._requester.requestJson( - "GET", f"{self.url}/repos/{repo._identity}" - ) + status, headers, data = self._requester.requestJson("GET", f"{self.url}/repos/{repo._identity}") return status == 204 def remove_membership(self, member): @@ -447,9 +419,7 @@ class Team(github.GithubObject.CompletableGithubObject): :return: """ assert isinstance(member, github.NamedUser.NamedUser), member - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/memberships/{member._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/memberships/{member._identity}") def remove_from_members(self, member): """ @@ -461,9 +431,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/members/{member._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/members/{member._identity}") def remove_from_repos(self, repo): """ @@ -472,9 +440,7 @@ class Team(github.GithubObject.CompletableGithubObject): :rtype: None """ assert isinstance(repo, github.Repository.Repository), repo - headers, data = self._requester.requestJsonAndCheck( - "DELETE", f"{self.url}/repos/{repo._identity}" - ) + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/repos/{repo._identity}") @property def _identity(self): @@ -512,22 +478,16 @@ class Team(github.GithubObject.CompletableGithubObject): if "repos_count" in attributes: # pragma no branch self._repos_count = self._makeIntAttribute(attributes["repos_count"]) if "repositories_url" in attributes: # pragma no branch - self._repositories_url = self._makeStringAttribute( - attributes["repositories_url"] - ) + self._repositories_url = self._makeStringAttribute(attributes["repositories_url"]) if "slug" in attributes: # pragma no branch self._slug = self._makeStringAttribute(attributes["slug"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "organization" in attributes: # pragma no branch - self._organization = self._makeClassAttribute( - github.Organization.Organization, attributes["organization"] - ) + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) if "privacy" in attributes: # pragma no branch self._privacy = self._makeStringAttribute(attributes["privacy"]) if "parent" in attributes: # pragma no branch - self._parent = self._makeClassAttribute( - github.Team.Team, attributes["parent"] - ) + self._parent = self._makeClassAttribute(github.Team.Team, attributes["parent"]) if "html_url" in attributes: self._html_url = self._makeStringAttribute(attributes["html_url"]) diff --git a/github/Team.pyi b/github/Team.pyi index 5e9beaa7..b6d7d9d6 100644 --- a/github/Team.pyi +++ b/github/Team.pyi @@ -15,15 +15,11 @@ class Team(CompletableGithubObject): def _identity(self) -> int: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - def add_membership( - self, member: NamedUser, role: Union[str, _NotSetType] = ... - ) -> None: ... + def add_membership(self, member: NamedUser, role: Union[str, _NotSetType] = ...) -> None: ... def add_to_members(self, member: NamedUser) -> None: ... def get_team_membership(self, member: Union[str, NamedUser]) -> Membership: ... def add_to_repos(self, repo: Repository) -> None: ... - def get_repo_permission( - self, repo: Repository - ) -> Union[Permissions, _NotSetType]: ... + def get_repo_permission(self, repo: Repository) -> Union[Permissions, _NotSetType]: ... def update_team_repository(self, repo: Repository, permission: str) -> bool: ... def delete(self) -> None: ... @property @@ -37,9 +33,7 @@ class Team(CompletableGithubObject): ) -> None: ... def get_teams(self) -> PaginatedList[Team]: ... def get_discussions(self) -> PaginatedList[TeamDiscussion]: ... - def get_members( - self, role: Union[str, _NotSetType] = ... - ) -> PaginatedList[NamedUser]: ... + def get_members(self, role: Union[str, _NotSetType] = ...) -> PaginatedList[NamedUser]: ... def get_repos(self) -> PaginatedList[Repository]: ... def has_in_members(self, member: NamedUser) -> bool: ... def has_in_repos(self, repo: Repository) -> bool: ... diff --git a/github/TeamDiscussion.py b/github/TeamDiscussion.py index 3501351e..ecf0772e 100644 --- a/github/TeamDiscussion.py +++ b/github/TeamDiscussion.py @@ -31,9 +31,7 @@ class TeamDiscussion(github.GithubObject.CompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"number": self._number.value, "title": self._title.value} - ) + return self.get__repr__({"number": self._number.value, "title": self._title.value}) @property def author(self): @@ -192,9 +190,7 @@ class TeamDiscussion(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - self._author = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["author"] - ) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "body_html" in attributes: # pragma no branch @@ -210,9 +206,7 @@ class TeamDiscussion(github.GithubObject.CompletableGithubObject): if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "last_edited_at" in attributes: # pragma no branch - self._last_edited_at = self._makeDatetimeAttribute( - attributes["last_edited_at"] - ) + self._last_edited_at = self._makeDatetimeAttribute(attributes["last_edited_at"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "number" in attributes: # pragma no branch diff --git a/github/TimelineEvent.py b/github/TimelineEvent.py index f2687b99..97826884 100644 --- a/github/TimelineEvent.py +++ b/github/TimelineEvent.py @@ -88,10 +88,7 @@ class TimelineEvent(github.GithubObject.NonCompletableGithubObject): :type: :class:`github.TimelineEventSource.TimelineEventSource` """ # only available on `cross-referenced` events. - if ( - self.event == "cross-referenced" - and self._source is not github.GithubObject.NotSet - ): + if self.event == "cross-referenced" and self._source is not github.GithubObject.NotSet: return self._source.value return None @@ -109,10 +106,7 @@ class TimelineEvent(github.GithubObject.NonCompletableGithubObject): """ :type string """ - if ( - self.event == "commented" - and self._author_association is not github.GithubObject.NotSet - ): + if self.event == "commented" and self._author_association is not github.GithubObject.NotSet: return self._author_association.value return None @@ -138,9 +132,7 @@ class TimelineEvent(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch - self._actor = self._makeClassAttribute( - github.NamedUser.NamedUser, attributes["actor"] - ) + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch @@ -160,8 +152,6 @@ class TimelineEvent(github.GithubObject.NonCompletableGithubObject): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "author_association" in attributes: # pragma no branch - self._author_association = self._makeStringAttribute( - attributes["author_association"] - ) + self._author_association = self._makeStringAttribute(attributes["author_association"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/TimelineEventSource.py b/github/TimelineEventSource.py index e7574e6c..db31ead1 100644 --- a/github/TimelineEventSource.py +++ b/github/TimelineEventSource.py @@ -55,6 +55,4 @@ class TimelineEventSource(NonCompletableGithubObject): if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "issue" in attributes: # pragma no branch - self._issue = self._makeClassAttribute( - github.Issue.Issue, attributes["issue"] - ) + self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"]) diff --git a/github/Topic.py b/github/Topic.py index eb3c428f..c85d9d97 100644 --- a/github/Topic.py +++ b/github/Topic.py @@ -127,9 +127,7 @@ class Topic(github.GithubObject.NonCompletableGithubObject): if "display_name" in attributes: # pragma no branch self._display_name = self._makeStringAttribute(attributes["display_name"]) if "short_description" in attributes: # pragma no branch - self._short_description = self._makeStringAttribute( - attributes["short_description"] - ) + self._short_description = self._makeStringAttribute(attributes["short_description"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "created_by" in attributes: # pragma no branch diff --git a/github/Workflow.py b/github/Workflow.py index 615670a4..04cfb4cd 100644 --- a/github/Workflow.py +++ b/github/Workflow.py @@ -160,35 +160,21 @@ class Workflow(github.GithubObject.CompletableGithubObject): or isinstance(actor, str) ), actor assert ( - branch is github.GithubObject.NotSet - or isinstance(branch, github.Branch.Branch) - or isinstance(branch, str) + branch is github.GithubObject.NotSet or isinstance(branch, github.Branch.Branch) or isinstance(branch, str) ), branch assert event is github.GithubObject.NotSet or isinstance(event, str), event assert status is github.GithubObject.NotSet or isinstance(status, str), status - assert created is github.GithubObject.NotSet or isinstance( - created, str - ), created + assert created is github.GithubObject.NotSet or isinstance(created, str), created assert exclude_pull_requests is github.GithubObject.NotSet or isinstance( exclude_pull_requests, bool ), exclude_pull_requests - assert check_suite_id is github.GithubObject.NotSet or isinstance( - check_suite_id, int - ), check_suite_id - assert head_sha is github.GithubObject.NotSet or isinstance( - head_sha, str - ), head_sha + assert check_suite_id is github.GithubObject.NotSet or isinstance(check_suite_id, int), check_suite_id + assert head_sha is github.GithubObject.NotSet or isinstance(head_sha, str), head_sha url_parameters = dict() if actor is not github.GithubObject.NotSet: - url_parameters["actor"] = ( - actor._identity - if isinstance(actor, github.NamedUser.NamedUser) - else actor - ) + url_parameters["actor"] = actor._identity if isinstance(actor, github.NamedUser.NamedUser) else actor if branch is not github.GithubObject.NotSet: - url_parameters["branch"] = ( - branch.name if isinstance(branch, github.Branch.Branch) else branch - ) + url_parameters["branch"] = branch.name if isinstance(branch, github.Branch.Branch) else branch if event is not github.GithubObject.NotSet: url_parameters["event"] = event if status is not github.GithubObject.NotSet: diff --git a/github/WorkflowJob.py b/github/WorkflowJob.py index 5211900d..93a8c3e5 100644 --- a/github/WorkflowJob.py +++ b/github/WorkflowJob.py @@ -194,8 +194,6 @@ class WorkflowJob(github.GithubObject.CompletableGithubObject): if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "steps" in attributes: # pragma no branch - self._steps = self._makeListOfClassesAttribute( - github.WorkflowStep.WorkflowStep, attributes["steps"] - ) + self._steps = self._makeListOfClassesAttribute(github.WorkflowStep.WorkflowStep, attributes["steps"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/WorkflowRun.py b/github/WorkflowRun.py index 92fe8cef..5b076ce2 100644 --- a/github/WorkflowRun.py +++ b/github/WorkflowRun.py @@ -29,13 +29,7 @@ from typing import TYPE_CHECKING, NamedTuple import github.GitCommit import github.PullRequest import github.WorkflowJob -from github.GithubObject import ( - Attribute, - CompletableGithubObject, - NotSet, - Opt, - is_optional, -) +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_optional from github.PaginatedList import PaginatedList if TYPE_CHECKING: @@ -256,9 +250,7 @@ class WorkflowRun(CompletableGithubObject): :calls: `GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing `_ """ headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/timing") - return TimingData( - billable=data["billable"], run_duration_ms=data["run_duration_ms"] # type: ignore - ) + return TimingData(billable=data["billable"], run_duration_ms=data["run_duration_ms"]) # type: ignore def delete(self) -> bool: """ @@ -304,12 +296,10 @@ class WorkflowRun(CompletableGithubObject): if "event" in attributes: # pragma no branch self._event = self._makeStringAttribute(attributes["event"]) if "run_started_at" in attributes: # pragma no branch - assert attributes["run_started_at"] is None or isinstance( - attributes["run_started_at"], str - ), attributes["run_started_at"] - self._run_started_at = self._makeDatetimeAttribute( - attributes["run_started_at"] - ) + assert attributes["run_started_at"] is None or isinstance(attributes["run_started_at"], str), attributes[ + "run_started_at" + ] + self._run_started_at = self._makeDatetimeAttribute(attributes["run_started_at"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "conclusion" in attributes: # pragma no branch @@ -333,9 +323,7 @@ class WorkflowRun(CompletableGithubObject): if "logs_url" in attributes: # pragma no branch self._logs_url = self._makeStringAttribute(attributes["logs_url"]) if "check_suite_url" in attributes: # pragma no branch - self._check_suite_url = self._makeStringAttribute( - attributes["check_suite_url"] - ) + self._check_suite_url = self._makeStringAttribute(attributes["check_suite_url"]) if "artifacts_url" in attributes: # pragma no branch self._artifacts_url = self._makeStringAttribute(attributes["artifacts_url"]) if "cancel_url" in attributes: # pragma no branch @@ -345,13 +333,9 @@ class WorkflowRun(CompletableGithubObject): if "workflow_url" in attributes: # pragma no branch self._workflow_url = self._makeStringAttribute(attributes["workflow_url"]) if "head_commit" in attributes: # pragma no branch - self._head_commit = self._makeClassAttribute( - github.GitCommit.GitCommit, attributes["head_commit"] - ) + self._head_commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["head_commit"]) if "repository" in attributes: # pragma no branch - self._repository = self._makeClassAttribute( - github.Repository.Repository, attributes["repository"] - ) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "head_repository" in attributes: # pragma no branch self._head_repository = self._makeClassAttribute( github.Repository.Repository, attributes["head_repository"] diff --git a/github/WorkflowStep.py b/github/WorkflowStep.py index 8ae2e988..b5ad11c1 100644 --- a/github/WorkflowStep.py +++ b/github/WorkflowStep.py @@ -29,9 +29,7 @@ class WorkflowStep(github.GithubObject.CompletableGithubObject): """ def __repr__(self): - return self.get__repr__( - {"number": self._number.value, "name": self._name.value} - ) + return self.get__repr__({"number": self._number.value, "name": self._name.value}) @property def completed_at(self): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..96e69ccb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.black] +# https://github.com/psf/black +line-length = 120 +target-version = ['py37'] diff --git a/scripts/add_attribute.py b/scripts/add_attribute.py index 3c25bd56..f3b7671c 100644 --- a/scripts/add_attribute.py +++ b/scripts/add_attribute.py @@ -73,18 +73,12 @@ types = { "class": ( ":class:`" + attributeClassType + "`", None, - "self._makeClassAttribute(" - + attributeClassType - + ', attributes["' - + attributeName - + '"])', + "self._makeClassAttribute(" + attributeClassType + ', attributes["' + attributeName + '"])', attributeClassType, ), } -attributeDocType, attributeAssertType, attributeValue, attributeClassType = types[ - attributeType -] +attributeDocType, attributeAssertType, attributeValue, attributeClassType = types[attributeType] if attributeType == "class": # Wrap in quotes to avoid an explicit import requirement which can cause circular import errors attributeClassType = f"'{attributeClassType}'" @@ -114,21 +108,15 @@ while not added: elif line.startswith(" def "): attrName = line[8:-7] # Properties will be inserted after __repr__, but before any other function. - if attrName != "__repr__" and ( - attrName == "_identity" or attrName > attributeName or not isProperty - ): + if attrName != "__repr__" and (attrName == "_identity" or attrName > attributeName or not isProperty): if not isProperty: newLines.append(" @property") - newLines.append( - " def " + attributeName + "(self) -> " + attributeClassType + ":" - ) + newLines.append(" def " + attributeName + "(self) -> " + attributeClassType + ":") newLines.append(' """') newLines.append(" :type: " + attributeDocType) newLines.append(' """') if isCompletable: - newLines.append( - " self._completeIfNotSet(self._" + attributeName + ")" - ) + newLines.append(" self._completeIfNotSet(self._" + attributeName + ")") newLines.append(" return self._" + attributeName + ".value") newLines.append("") if isProperty: @@ -150,9 +138,7 @@ while not added: if line: attrName = line[14:-29] if not line or attrName > attributeName: - newLines.append( - " self._" + attributeName + " = github.GithubObject.NotSet" - ) + newLines.append(" self._" + attributeName + " = github.GithubObject.NotSet") added = True newLines.append(line) @@ -172,11 +158,7 @@ while not added: if line: attrName = line[12:-36] if not line or attrName > attributeName: - newLines.append( - ' if "' - + attributeName - + '" in attributes: # pragma no branch' - ) + newLines.append(' if "' + attributeName + '" in attributes: # pragma no branch') if attributeAssertType: newLines.append( ' assert attributes["' @@ -189,9 +171,7 @@ while not added: + attributeName + '"]' ) - newLines.append( - " self._" + attributeName + " = " + attributeValue - ) + newLines.append(" self._" + attributeName + " = " + attributeValue) added = True newLines.append(line) diff --git a/scripts/fix_headers.py b/scripts/fix_headers.py index 022bf13f..2dfaeab2 100755 --- a/scripts/fix_headers.py +++ b/scripts/fix_headers.py @@ -112,11 +112,7 @@ class PythonHeader: if len(bodyLines) > 0 and bodyLines[0] != "": newLines.append("") - if ( - "import " not in bodyLines[0] - and bodyLines[0] != '"""' - and not bodyLines[0].startswith("##########") - ): + if "import " not in bodyLines[0] and bodyLines[0] != '"""' and not bodyLines[0].startswith("##########"): newLines.append("") newLines += bodyLines diff --git a/tests/ApplicationOAuth.py b/tests/ApplicationOAuth.py index b0e7c414..4b069e8b 100644 --- a/tests/ApplicationOAuth.py +++ b/tests/ApplicationOAuth.py @@ -40,32 +40,15 @@ class ApplicationOAuth(Framework.TestCase): BASE_URL = "https://github.com/login/oauth/authorize" sample_uri = "https://myapp.com/some/path" sample_uri_encoded = "https%3A%2F%2Fmyapp.com%2Fsome%2Fpath" - self.assertEqual( - self.app.get_login_url(), f"{BASE_URL}?client_id={self.CLIENT_ID}" - ) - self.assertTrue( - f"redirect_uri={sample_uri_encoded}" - in self.app.get_login_url(redirect_uri=sample_uri) - ) - self.assertTrue( - f"client_id={self.CLIENT_ID}" - in self.app.get_login_url(redirect_uri=sample_uri) - ) - self.assertTrue( - "state=123abc" in self.app.get_login_url(state="123abc", login="user") - ) - self.assertTrue( - "login=user" in self.app.get_login_url(state="123abc", login="user") - ) - self.assertTrue( - f"client_id={self.CLIENT_ID}" - in self.app.get_login_url(state="123abc", login="user") - ) + self.assertEqual(self.app.get_login_url(), f"{BASE_URL}?client_id={self.CLIENT_ID}") + self.assertTrue(f"redirect_uri={sample_uri_encoded}" in self.app.get_login_url(redirect_uri=sample_uri)) + self.assertTrue(f"client_id={self.CLIENT_ID}" in self.app.get_login_url(redirect_uri=sample_uri)) + self.assertTrue("state=123abc" in self.app.get_login_url(state="123abc", login="user")) + self.assertTrue("login=user" in self.app.get_login_url(state="123abc", login="user")) + self.assertTrue(f"client_id={self.CLIENT_ID}" in self.app.get_login_url(state="123abc", login="user")) def testGetAccessToken(self): - access_token = self.app.get_access_token( - "oauth_code_removed", state="state_removed" - ) + access_token = self.app.get_access_token("oauth_code_removed", state="state_removed") # Test string representation self.assertEqual( str(access_token), @@ -83,12 +66,8 @@ class ApplicationOAuth(Framework.TestCase): def testGetAccessTokenWithExpiry(self): with mock.patch("github.AccessToken.datetime") as dt: - dt.now = mock.Mock( - return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc) - ) - access_token = self.app.get_access_token( - "oauth_code_removed", state="state_removed" - ) + dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc)) + access_token = self.app.get_access_token("oauth_code_removed", state="state_removed") # Test string representation self.assertEqual( str(access_token), @@ -111,14 +90,10 @@ class ApplicationOAuth(Framework.TestCase): ) def testRefreshAccessToken(self): - access_token = self.app.get_access_token( - "oauth_code_removed", state="state_removed" - ) + access_token = self.app.get_access_token("oauth_code_removed", state="state_removed") with mock.patch("github.AccessToken.datetime") as dt: - dt.now = mock.Mock( - return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc)) refreshed = self.app.refresh_access_token(access_token.refresh_token) self.assertNotEqual(refreshed.token, access_token.token) diff --git a/tests/AuthenticatedUser.py b/tests/AuthenticatedUser.py index 6da03f24..3b6fd993 100644 --- a/tests/AuthenticatedUser.py +++ b/tests/AuthenticatedUser.py @@ -327,9 +327,7 @@ class AuthenticatedUser(Framework.TestCase): self.assertTrue(self.user.has_in_subscriptions(gitflow)) def testGetAuthorizations(self): - self.assertListKeyEqual( - self.user.get_authorizations(), lambda a: a.id, [372294] - ) + self.assertListKeyEqual(self.user.get_authorizations(), lambda a: a.id, [372294]) def testCreateRepository(self): repo = self.user.create_repo(name="TestPyGithub") @@ -357,9 +355,7 @@ class AuthenticatedUser(Framework.TestCase): self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub") def testCreateRepositoryWithAutoInit(self): - repo = self.user.create_repo( - name="TestPyGithub", auto_init=True, gitignore_template="Python" - ) + repo = self.user.create_repo(name="TestPyGithub", auto_init=True, gitignore_template="Python") self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub") def testCreateAuthorizationWithoutArguments(self): @@ -391,9 +387,7 @@ class AuthenticatedUser(Framework.TestCase): self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") def testCreateGistWithoutDescription(self): - gist = self.user.create_gist( - True, {"foobar.txt": github.InputFileContent("File created by PyGithub")} - ) + gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}) self.assertEqual(gist.description, None) self.assertEqual(list(gist.files.keys()), ["foobar.txt"]) self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") @@ -414,9 +408,7 @@ class AuthenticatedUser(Framework.TestCase): def testGetOrganizationEvents(self): self.assertListKeyBegin( - self.user.get_organization_events( - self.g.get_organization("BeaverSoftware") - ), + self.user.get_organization_events(self.g.get_organization("BeaverSoftware")), lambda e: e.type, ["CreateEvent", "CreateEvent", "PushEvent", "PushEvent"], ) @@ -617,9 +609,7 @@ class AuthenticatedUser(Framework.TestCase): ) def testGetOrgs(self): - self.assertListKeyEqual( - self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"] - ) + self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"]) def testGetRepos(self): self.assertListKeyEqual( @@ -670,9 +660,7 @@ class AuthenticatedUser(Framework.TestCase): def testCreateRepoFromTemplate(self): template_repo = self.g.get_repo("actions/hello-world-docker-action") - repo = self.user.create_repo_from_template( - "hello-world-docker-action-new", template_repo - ) + repo = self.user.create_repo_from_template("hello-world-docker-action-new", template_repo) self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/hello-world-docker-action-new", @@ -712,19 +700,13 @@ class AuthenticatedUser(Framework.TestCase): repr(notification), 'Notification(subject=NotificationSubject(title="Feature/coveralls"), id="8406712")', ) - self.assertEqual( - repr(notification.subject), 'NotificationSubject(title="Feature/coveralls")' - ) + self.assertEqual(repr(notification.subject), 'NotificationSubject(title="Feature/coveralls")') def testGetNotifications(self): - self.assertListKeyEqual( - self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"] - ) + self.assertListKeyEqual(self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"]) def testGetNotificationsWithOtherArguments(self): - self.assertListKeyEqual( - self.user.get_notifications(all=True), lambda n: n.id, [] - ) + self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, []) def testMarkNotificationsAsRead(self): self.user.mark_notifications_as_read(datetime(2018, 10, 18, 18, 20, 0o1, 0)) @@ -761,19 +743,13 @@ class AuthenticatedUser(Framework.TestCase): invitation.url, "https://api.github.com/user/repository_invitations/17285388", ) - self.assertEqual( - invitation.html_url, "https://github.com/jacquev6/PyGithub/invitations" - ) + self.assertEqual(invitation.html_url, "https://github.com/jacquev6/PyGithub/invitations") self.assertEqual(invitation.repository.name, "PyGithub") self.assertEqual(invitation.invitee.login, "foobar-test1") self.assertEqual(invitation.inviter.login, "jacquev6") def testCreateMigration(self): - self.assertTrue( - isinstance( - self.user.create_migration(["sample-repo"]), github.Migration.Migration - ) - ) + self.assertTrue(isinstance(self.user.create_migration(["sample-repo"]), github.Migration.Migration)) def testGetMigrations(self): self.assertEqual(self.user.get_migrations().totalCount, 46) diff --git a/tests/Authentication.py b/tests/Authentication.py index 97c343aa..6a477851 100644 --- a/tests/Authentication.py +++ b/tests/Authentication.py @@ -117,15 +117,11 @@ class Authentication(Framework.BasicTestCase): # forward the clock so token expires with mock.patch("github.Auth.datetime") as dt: # just before expiry - dt.now = mock.Mock( - return_value=datetime(2024, 11, 25, 0, 59, 3, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2024, 11, 25, 0, 59, 3, tzinfo=timezone.utc)) self.assertFalse(installation_auth._is_expired) # just after expiry - dt.now = mock.Mock( - return_value=datetime(2024, 11, 25, 1, 0, 3, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2024, 11, 25, 1, 0, 3, tzinfo=timezone.utc)) self.assertTrue(installation_auth._is_expired) # expect refreshing the token @@ -149,9 +145,7 @@ class Authentication(Framework.BasicTestCase): g = github.Github() app = g.get_oauth_application(client_id, client_secret) with mock.patch("github.AccessToken.datetime") as dt: - dt.now = mock.Mock( - return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc)) token = app.refresh_access_token(refresh_token) self.assertEqual(token.token, "fresh access token") self.assertEqual(token.type, "bearer") @@ -170,9 +164,7 @@ class Authentication(Framework.BasicTestCase): auth = app.get_app_user_auth(token) with mock.patch("github.Auth.datetime") as dt: - dt.now = mock.Mock( - return_value=datetime(2023, 6, 7, 20, 0, 0, 123, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 20, 0, 0, 123, tzinfo=timezone.utc)) self.assertEqual(auth._is_expired, False) self.assertEqual(auth.token, "fresh access token") self.assertEqual(auth.token_type, "bearer") @@ -180,9 +172,7 @@ class Authentication(Framework.BasicTestCase): # expire auth token with mock.patch("github.Auth.datetime") as dt: - dt.now = mock.Mock( - return_value=datetime(2023, 6, 7, 20, 0, 1, 123, tzinfo=timezone.utc) - ) + dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 20, 0, 1, 123, tzinfo=timezone.utc)) self.assertEqual(auth._is_expired, True) self.assertEqual(auth.token, "another access token") self.assertEqual(auth._is_expired, False) @@ -206,14 +196,10 @@ class Authentication(Framework.BasicTestCase): algorithms=["RS256"], options={"verify_exp": False}, ) - self.assertDictEqual( - payload, {"iat": 1550055271, "exp": 1550055631, "iss": APP_ID} - ) + self.assertDictEqual(payload, {"iat": 1550055271, "exp": 1550055631, "iss": APP_ID}) def testCreateJWTWithExpiration(self): - auth = github.Auth.AppAuth( - APP_ID, PRIVATE_KEY, jwt_expiry=120, jwt_issued_at=-30 - ) + auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY, jwt_expiry=120, jwt_issued_at=-30) with mock.patch("github.Auth.time") as t: t.time = mock.Mock(return_value=1550055331.7435968) @@ -225,9 +211,7 @@ class Authentication(Framework.BasicTestCase): algorithms=["RS256"], options={"verify_exp": False}, ) - self.assertDictEqual( - payload, {"iat": 1550055301, "exp": 1550055391, "iss": APP_ID} - ) + self.assertDictEqual(payload, {"iat": 1550055301, "exp": 1550055391, "iss": APP_ID}) def testUserAgent(self): g = github.Github(user_agent="PyGithubTester") diff --git a/tests/Authorization.py b/tests/Authorization.py index 7f3adda5..1f893800 100644 --- a/tests/Authorization.py +++ b/tests/Authorization.py @@ -49,20 +49,14 @@ class Authorization(Framework.TestCase): self.assertEqual(self.authorization.note, None) self.assertEqual(self.authorization.note_url, None) self.assertEqual(self.authorization.scopes, []) - self.assertEqual( - self.authorization.token, "82459c4500086f8f0cc67d2936c17d1e27ad1c33" - ) + self.assertEqual(self.authorization.token, "82459c4500086f8f0cc67d2936c17d1e27ad1c33") self.assertEqual( self.authorization.updated_at, datetime(2012, 5, 22, 18, 3, 17, tzinfo=timezone.utc), ) - self.assertEqual( - self.authorization.url, "https://api.github.com/authorizations/372259" - ) + self.assertEqual(self.authorization.url, "https://api.github.com/authorizations/372259") self.assertEqual(repr(self.authorization), "Authorization(scopes=[])") - self.assertEqual( - repr(self.authorization.app), 'AuthorizationApplication(name="GitHub API")' - ) + self.assertEqual(repr(self.authorization.app), 'AuthorizationApplication(name="GitHub API")') def testEdit(self): self.authorization.edit() @@ -80,9 +74,7 @@ class Authorization(Framework.TestCase): note_url="http://vincent-jacques.net/PyGithub", ) self.assertEqual(self.authorization.note, "Note created by PyGithub") - self.assertEqual( - self.authorization.note_url, "http://vincent-jacques.net/PyGithub" - ) + self.assertEqual(self.authorization.note_url, "http://vincent-jacques.net/PyGithub") def testDelete(self): self.authorization.delete() diff --git a/tests/Autolink.py b/tests/Autolink.py index e363e3cb..dda2590c 100644 --- a/tests/Autolink.py +++ b/tests/Autolink.py @@ -27,19 +27,11 @@ class Autolink(Framework.TestCase): super().setUp() # When recording test, be sure to create a autolink for yourself on # Github and update it here. - links = [ - x - for x in self.g.get_user("theCapypara").get_repo("PyGithub").get_autolinks() - if x.id == 209614 - ] - self.assertEqual( - 1, len(links), "There must be exactly one autolink with the ID 209614." - ) + links = [x for x in self.g.get_user("theCapypara").get_repo("PyGithub").get_autolinks() if x.id == 209614] + self.assertEqual(1, len(links), "There must be exactly one autolink with the ID 209614.") self.link = links[0] def testAttributes(self): self.assertEqual(self.link.id, 209614) self.assertEqual(self.link.key_prefix, "DUMMY-") - self.assertEqual( - self.link.url_template, "https://github.com/PyGithub/PyGithub/issues/" - ) + self.assertEqual(self.link.url_template, "https://github.com/PyGithub/PyGithub/issues/") diff --git a/tests/BadAttributes.py b/tests/BadAttributes.py index fd101b0b..da04d56f 100755 --- a/tests/BadAttributes.py +++ b/tests/BadAttributes.py @@ -56,9 +56,7 @@ class BadAttributes(Framework.TestCase): user.created_at self.assertEqual(raisedexp.exception.actual_value, "foobar") self.assertEqual(raisedexp.exception.expected_type, str) - self.assertEqual( - raisedexp.exception.transformation_exception.__class__, ParserError - ) + self.assertEqual(raisedexp.exception.transformation_exception.__class__, ParserError) self.assertEqual( raisedexp.exception.transformation_exception.args, ("Unknown string format: %s", "foobar"), @@ -94,9 +92,7 @@ class BadAttributes(Framework.TestCase): self.assertEqual(raisedexp.exception.actual_value, 42) def testBadTransformedAttributeInList(self): - commit = self.g.get_repo("klmitch/turnstile", lazy=True).get_commit( - "38d9082a898d0822b5ccdfd78f3a536e2efa6c26" - ) + commit = self.g.get_repo("klmitch/turnstile", lazy=True).get_commit("38d9082a898d0822b5ccdfd78f3a536e2efa6c26") with self.assertRaises(github.BadAttributeException) as raisedexp: commit.files diff --git a/tests/Branch.py b/tests/Branch.py index 876d50fe..760a6651 100644 --- a/tests/Branch.py +++ b/tests/Branch.py @@ -39,23 +39,17 @@ class Branch(Framework.TestCase): self.repo = self.g.get_user().get_repo("PyGithub") self.branch = self.repo.get_branch("topic/RewriteWithGeneratedCode") self.protected_branch = self.repo.get_branch("integrations") - self.organization_branch = self.g.get_repo( - "PyGithub/PyGithub", lazy=True - ).get_branch("master") + self.organization_branch = self.g.get_repo("PyGithub/PyGithub", lazy=True).get_branch("master") def testAttributes(self): self.assertEqual(self.branch.name, "topic/RewriteWithGeneratedCode") - self.assertEqual( - self.branch.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" - ) + self.assertEqual(self.branch.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") self.assertEqual( self.branch.protection_url, "https://api.github.com/repos/jacquev6/PyGithub/branches/topic/RewriteWithGeneratedCode/protection", ) self.assertFalse(self.branch.protected) - self.assertEqual( - repr(self.branch), 'Branch(name="topic/RewriteWithGeneratedCode")' - ) + self.assertEqual(repr(self.branch), 'Branch(name="topic/RewriteWithGeneratedCode")') def testEditProtection(self): self.protected_branch.edit_protection( @@ -67,12 +61,8 @@ class Branch(Framework.TestCase): self.assertTrue(branch_protection.required_status_checks.strict) self.assertEqual(branch_protection.required_status_checks.contexts, []) self.assertTrue(branch_protection.enforce_admins) - self.assertFalse( - branch_protection.required_pull_request_reviews.dismiss_stale_reviews - ) - self.assertTrue( - branch_protection.required_pull_request_reviews.require_code_owner_reviews - ) + self.assertFalse(branch_protection.required_pull_request_reviews.dismiss_stale_reviews) + self.assertTrue(branch_protection.required_pull_request_reviews.require_code_owner_reviews) self.assertEqual( branch_protection.required_pull_request_reviews.required_approving_review_count, 2, @@ -87,33 +77,25 @@ class Branch(Framework.TestCase): { "documentation_url": "https://developer.github.com/v3/repos/branches/#update-branch-protection", "message": "Validation Failed", - "errors": [ - "Only organization repositories can have users and team restrictions" - ], + "errors": ["Only organization repositories can have users and team restrictions"], }, ) def testEditProtectionPushRestrictionsWithUserOwnedBranch(self): with self.assertRaises(github.GithubException) as raisedexp: - self.protected_branch.edit_protection( - user_push_restrictions=["jacquev6"], team_push_restrictions=[] - ) + self.protected_branch.edit_protection(user_push_restrictions=["jacquev6"], team_push_restrictions=[]) self.assertEqual(raisedexp.exception.status, 422) self.assertEqual( raisedexp.exception.data, { "documentation_url": "https://developer.github.com/v3/repos/branches/#update-branch-protection", "message": "Validation Failed", - "errors": [ - "Only organization repositories can have users and team restrictions" - ], + "errors": ["Only organization repositories can have users and team restrictions"], }, ) def testEditProtectionPushRestrictionsAndDismissalUser(self): - self.organization_branch.edit_protection( - dismissal_users=["jacquev6"], user_push_restrictions=["jacquev6"] - ) + self.organization_branch.edit_protection(dismissal_users=["jacquev6"], user_push_restrictions=["jacquev6"]) branch_protection = self.organization_branch.get_protection() self.assertListKeyEqual( branch_protection.required_pull_request_reviews.dismissal_users, @@ -130,9 +112,7 @@ class Branch(Framework.TestCase): lambda u: u.login, ["jacquev6"], ) - self.assertListKeyEqual( - branch_protection.get_team_push_restrictions(), lambda u: u.slug, [] - ) + self.assertListKeyEqual(branch_protection.get_team_push_restrictions(), lambda u: u.slug, []) def testRemoveProtection(self): self.assertTrue(self.protected_branch.protected) @@ -173,20 +153,14 @@ class Branch(Framework.TestCase): self.protected_branch.edit_required_pull_request_reviews( dismiss_stale_reviews=True, required_approving_review_count=2 ) - required_pull_request_reviews = ( - self.protected_branch.get_required_pull_request_reviews() - ) + required_pull_request_reviews = self.protected_branch.get_required_pull_request_reviews() self.assertTrue(required_pull_request_reviews.dismiss_stale_reviews) self.assertTrue(required_pull_request_reviews.require_code_owner_reviews) - self.assertEqual( - required_pull_request_reviews.required_approving_review_count, 2 - ) + self.assertEqual(required_pull_request_reviews.required_approving_review_count, 2) def testEditRequiredPullRequestReviewsWithTooLargeApprovingReviewCount(self): with self.assertRaises(github.GithubException) as raisedexp: - self.protected_branch.edit_required_pull_request_reviews( - required_approving_review_count=9 - ) + self.protected_branch.edit_required_pull_request_reviews(required_approving_review_count=9) self.assertEqual(raisedexp.exception.status, 422) self.assertEqual( raisedexp.exception.data, @@ -198,9 +172,7 @@ class Branch(Framework.TestCase): def testEditRequiredPullRequestReviewsWithUserBranchAndDismissalUsers(self): with self.assertRaises(github.GithubException) as raisedexp: - self.protected_branch.edit_required_pull_request_reviews( - dismissal_users=["jacquev6"] - ) + self.protected_branch.edit_required_pull_request_reviews(dismissal_users=["jacquev6"]) self.assertEqual(raisedexp.exception.status, 422) self.assertEqual( raisedexp.exception.data, @@ -212,14 +184,10 @@ class Branch(Framework.TestCase): def testRemoveRequiredPullRequestReviews(self): self.protected_branch.remove_required_pull_request_reviews() - required_pull_request_reviews = ( - self.protected_branch.get_required_pull_request_reviews() - ) + required_pull_request_reviews = self.protected_branch.get_required_pull_request_reviews() self.assertFalse(required_pull_request_reviews.dismiss_stale_reviews) self.assertFalse(required_pull_request_reviews.require_code_owner_reviews) - self.assertEqual( - required_pull_request_reviews.required_approving_review_count, 1 - ) + self.assertEqual(required_pull_request_reviews.required_approving_review_count, 1) def testAdminEnforcement(self): self.protected_branch.remove_admin_enforcement() diff --git a/tests/BranchProtection.py b/tests/BranchProtection.py index 65a75d21..e7a1860d 100644 --- a/tests/BranchProtection.py +++ b/tests/BranchProtection.py @@ -26,18 +26,11 @@ from . import Framework class BranchProtection(Framework.TestCase): def setUp(self): super().setUp() - self.branch_protection = ( - self.g.get_user() - .get_repo("PyGithub") - .get_branch("integrations") - .get_protection() - ) + self.branch_protection = self.g.get_user().get_repo("PyGithub").get_branch("integrations").get_protection() def testAttributes(self): self.assertTrue(self.branch_protection.required_status_checks.strict) - self.assertEqual( - self.branch_protection.required_status_checks.contexts, ["foo/bar"] - ) + self.assertEqual(self.branch_protection.required_status_checks.contexts, ["foo/bar"]) self.assertEqual( self.branch_protection.url, "https://api.github.com/repos/jacquev6/PyGithub/branches/integrations/protection", diff --git a/tests/CheckRun.py b/tests/CheckRun.py index ab86f333..358c7a2c 100644 --- a/tests/CheckRun.py +++ b/tests/CheckRun.py @@ -48,12 +48,8 @@ class CheckRun(Framework.TestCase): self.check_run.details_url, "https://github.com/PyGithub/PyGithub/runs/1039891953", ) - self.assertEqual( - self.check_run.external_id, "6b512fe7-587c-5ecc-c4a3-03b7358c152d" - ) - self.assertEqual( - self.check_run.head_sha, "6bc9ecc8c849df4e45e60c1e6a5df8876180a20a" - ) + self.assertEqual(self.check_run.external_id, "6b512fe7-587c-5ecc-c4a3-03b7358c152d") + self.assertEqual(self.check_run.head_sha, "6bc9ecc8c849df4e45e60c1e6a5df8876180a20a") self.assertEqual( self.check_run.html_url, "https://github.com/PyGithub/PyGithub/runs/1039891953", @@ -72,9 +68,7 @@ class CheckRun(Framework.TestCase): self.check_run.url, "https://api.github.com/repos/PyGithub/PyGithub/check-runs/1039891953", ) - self.assertEqual( - repr(self.check_run), 'CheckRun(id=1039891953, conclusion="success")' - ) + self.assertEqual(repr(self.check_run), 'CheckRun(id=1039891953, conclusion="success")') def testCheckRunOutputAttributes(self): check_run_output = self.repo.get_check_run(1039891917).output @@ -89,9 +83,7 @@ class CheckRun(Framework.TestCase): check_run_output.annotations_url, "https://api.github.com/repos/PyGithub/PyGithub/check-runs/1039891917/annotations", ) - self.assertEqual( - repr(check_run_output), 'CheckRunOutput(title="test (Python 3.6)")' - ) + self.assertEqual(repr(check_run_output), 'CheckRunOutput(title="test (Python 3.6)")') def testGetCheckRunsForRef(self): check_runs = self.commit.get_check_runs() @@ -345,6 +337,4 @@ class CheckRun(Framework.TestCase): self.assertEqual(check_run.status, "completed") annotation_list = check_run.get_annotations() self.assertEqual(annotation_list.totalCount, 2) - self.assertListEqual( - [annotation.start_line for annotation in annotation_list], [2, 4] - ) + self.assertListEqual([annotation.start_line for annotation in annotation_list], [2, 4]) diff --git a/tests/CheckSuite.py b/tests/CheckSuite.py index 4d7512b2..cc79246d 100644 --- a/tests/CheckSuite.py +++ b/tests/CheckSuite.py @@ -48,9 +48,7 @@ class CheckSuite(Framework.TestCase): "https://api.github.com/repos/wrecker/PySample/check-suites/1004503837/check-runs", ) self.assertEqual(cs.conclusion, "success") - self.assertEqual( - cs.created_at, datetime(2020, 8, 4, 5, 6, 54, tzinfo=timezone.utc) - ) + self.assertEqual(cs.created_at, datetime(2020, 8, 4, 5, 6, 54, tzinfo=timezone.utc)) self.assertEqual(cs.head_branch, "wrecker-patch-1") self.assertEqual(cs.head_commit.sha, "fd09d934bcce792176d6b79d6d0387e938b62b7a") self.assertEqual(cs.head_sha, "fd09d934bcce792176d6b79d6d0387e938b62b7a") @@ -59,13 +57,9 @@ class CheckSuite(Framework.TestCase): self.assertEqual(cs.id, self.check_suite_id) self.assertEqual(len(cs.pull_requests), 1) self.assertEqual(cs.pull_requests[0].id, 462527907) - self.assertEqual( - cs.repository.url, "https://api.github.com/repos/wrecker/PySample" - ) + self.assertEqual(cs.repository.url, "https://api.github.com/repos/wrecker/PySample") self.assertEqual(cs.status, "completed") - self.assertEqual( - cs.updated_at, datetime(2020, 8, 4, 5, 7, 40, tzinfo=timezone.utc) - ) + self.assertEqual(cs.updated_at, datetime(2020, 8, 4, 5, 7, 40, tzinfo=timezone.utc)) self.assertEqual( cs.url, "https://api.github.com/repos/wrecker/PySample/check-suites/1004503837", @@ -165,9 +159,7 @@ class CheckSuite(Framework.TestCase): if app["app_id"] == data[0]["app_id"]: setting = app["setting"] self.assertFalse(setting) - self.assertEqual( - repo_preferences.repository.full_name, "dhruvmanila/pygithub-testing" - ) + self.assertEqual(repo_preferences.repository.full_name, "dhruvmanila/pygithub-testing") data = [{"app_id": 85429, "setting": True}] repo_preferences = self.test_repo.update_check_suites_preferences(data) for app in repo_preferences.preferences["auto_trigger_checks"]: diff --git a/tests/Commit.py b/tests/Commit.py index beb3d488..fb91528d 100644 --- a/tests/Commit.py +++ b/tests/Commit.py @@ -33,11 +33,7 @@ from . import Framework class Commit(Framework.TestCase): def setUp(self): super().setUp() - self.commit = ( - self.g.get_user() - .get_repo("PyGithub") - .get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a") - ) + self.commit = self.g.get_user().get_repo("PyGithub").get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a") self.commit.author.login # to force lazy completion def testAttributes(self): @@ -55,22 +51,16 @@ class Commit(Framework.TestCase): ) self.assertEqual(self.commit.files[0].changes, 20) self.assertEqual(self.commit.files[0].deletions, 20) - self.assertEqual( - self.commit.files[0].filename, "github/GithubObjects/GitAuthor.py" - ) + self.assertEqual(self.commit.files[0].filename, "github/GithubObjects/GitAuthor.py") self.assertTrue(isinstance(self.commit.files[0].patch, str)) self.assertEqual( self.commit.files[0].raw_url, "https://github.com/jacquev6/PyGithub/raw/1292bf0e22c796e91cc3d6e24b544aece8c21f2a/github/GithubObjects/GitAuthor.py", ) - self.assertEqual( - self.commit.files[0].sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" - ) + self.assertEqual(self.commit.files[0].sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") self.assertEqual(self.commit.files[0].status, "modified") self.assertEqual(len(self.commit.parents), 1) - self.assertEqual( - self.commit.parents[0].sha, "b46ed0dfde5ad02d3b91eb54a41c5ed960710eae" - ) + self.assertEqual(self.commit.parents[0].sha, "b46ed0dfde5ad02d3b91eb54a41c5ed960710eae") self.assertEqual(self.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") self.assertEqual(self.commit.stats.deletions, 20) self.assertEqual(self.commit.stats.additions, 0) @@ -79,9 +69,7 @@ class Commit(Framework.TestCase): self.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a", ) - self.assertEqual( - self.commit.commit.tree.sha, "4c6bd50994f0f9823f898b1c6c964ad7d4fa11ab" - ) + self.assertEqual(self.commit.commit.tree.sha, "4c6bd50994f0f9823f898b1c6c964ad7d4fa11ab") self.assertEqual( repr(self.commit), 'Commit(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")', @@ -109,9 +97,7 @@ class Commit(Framework.TestCase): ) self.assertEqual(comment.id, 1362000) self.assertEqual(comment.line, 26) - self.assertEqual( - comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py" - ) + self.assertEqual(comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py") self.assertEqual(comment.position, None) def testCreateCommentOnFilePosition(self): @@ -122,9 +108,7 @@ class Commit(Framework.TestCase): ) self.assertEqual(comment.id, 1362001) self.assertEqual(comment.line, None) - self.assertEqual( - comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py" - ) + self.assertEqual(comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py") self.assertEqual(comment.position, 3) def testCreateStatusWithoutOptionalParameters(self): @@ -142,15 +126,9 @@ class Commit(Framework.TestCase): ) self.assertEqual(status.id, 277040) self.assertEqual(status.state, "success") - self.assertEqual( - status.target_url, "https://github.com/jacquev6/PyGithub/issues/67" - ) + self.assertEqual(status.target_url, "https://github.com/jacquev6/PyGithub/issues/67") self.assertEqual(status.description, "Status successfuly created by PyGithub") def testGetPulls(self): - commit = ( - self.g.get_user() - .get_repo("PyGithub") - .get_commit("e44d11d565c022496544dd6ed1f19a8d718c2b0c") - ) + commit = self.g.get_user().get_repo("PyGithub").get_commit("e44d11d565c022496544dd6ed1f19a8d718c2b0c") self.assertListKeyEqual(commit.get_pulls(), lambda c: c.number, [1431]) diff --git a/tests/CommitCombinedStatus.py b/tests/CommitCombinedStatus.py index 76ce7649..78582b16 100644 --- a/tests/CommitCombinedStatus.py +++ b/tests/CommitCombinedStatus.py @@ -46,9 +46,7 @@ class CommitCombinedStatus(Framework.TestCase): ) self.assertEqual(self.combined_status.statuses[1].id, 390603044) self.assertEqual(self.combined_status.statuses[2].state, "success") - self.assertEqual( - self.combined_status.statuses[3].description, "Build finished." - ) + self.assertEqual(self.combined_status.statuses[3].description, "Build finished.") self.assertEqual( self.combined_status.statuses[4].target_url, "https://build.testeng.edx.org/job/edx-platform-python-unittests-pr/10504/", @@ -61,9 +59,7 @@ class CommitCombinedStatus(Framework.TestCase): self.combined_status.statuses[3].updated_at, datetime(2015, 12, 14, 13, 23, 35, tzinfo=timezone.utc), ) - self.assertEqual( - self.combined_status.sha, "74e70119a23fa3ffb3db19d4590eccfebd72b659" - ) + self.assertEqual(self.combined_status.sha, "74e70119a23fa3ffb3db19d4590eccfebd72b659") self.assertEqual(self.combined_status.total_count, 6) self.assertEqual(self.combined_status.repository.id, 10391073) self.assertEqual(self.combined_status.repository.full_name, "edx/edx-platform") diff --git a/tests/CommitComment.py b/tests/CommitComment.py index 8a59e2ca..e46449c5 100644 --- a/tests/CommitComment.py +++ b/tests/CommitComment.py @@ -40,9 +40,7 @@ class CommitComment(Framework.TestCase): def testAttributes(self): self.assertEqual(self.comment.body, "Comment created by PyGithub") - self.assertEqual( - self.comment.commit_id, "6945921c529be14c3a8f566dd1e483674516d46d" - ) + self.assertEqual(self.comment.commit_id, "6945921c529be14c3a8f566dd1e483674516d46d") self.assertEqual( self.comment.created_at, datetime(2012, 5, 22, 18, 40, 18, tzinfo=timezone.utc), diff --git a/tests/CommitStatus.py b/tests/CommitStatus.py index e0e512a6..39d33f0b 100644 --- a/tests/CommitStatus.py +++ b/tests/CommitStatus.py @@ -37,10 +37,7 @@ class CommitStatus(Framework.TestCase): def setUp(self): super().setUp() self.statuses = list( - self.g.get_user() - .get_repo("PyGithub") - .get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a") - .get_statuses() + self.g.get_user().get_repo("PyGithub").get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a").get_statuses() ) def testAttributes(self): @@ -53,9 +50,7 @@ class CommitStatus(Framework.TestCase): datetime(2012, 9, 8, 11, 30, 56, tzinfo=timezone.utc), ) self.assertEqual(self.statuses[0].creator.login, "jacquev6") - self.assertEqual( - self.statuses[0].description, "Status successfuly created by PyGithub" - ) + self.assertEqual(self.statuses[0].description, "Status successfuly created by PyGithub") self.assertEqual(self.statuses[1].description, None) self.assertEqual(self.statuses[0].id, 277040) self.assertEqual(self.statuses[0].state, "success") diff --git a/tests/ConditionalRequestUpdate.py b/tests/ConditionalRequestUpdate.py index a29eefdc..4c89cf2b 100644 --- a/tests/ConditionalRequestUpdate.py +++ b/tests/ConditionalRequestUpdate.py @@ -34,9 +34,7 @@ class ConditionalRequestUpdate(Framework.TestCase): self.repo = self.g.get_repo("akfish/PyGithub", lazy=False) def testDidNotUpdate(self): - self.assertFalse( - self.repo.update(), msg="The repo is not changed. But update() != False" - ) + self.assertFalse(self.repo.update(), msg="The repo is not changed. But update() != False") def testDidUpdate(self): self.assertTrue( diff --git a/tests/Connection.py b/tests/Connection.py index a0869d3e..3b28e126 100644 --- a/tests/Connection.py +++ b/tests/Connection.py @@ -66,9 +66,7 @@ class RecordingMockConnection(Framework.RecordingConnection): ("replaying_connection_class", "protocol", "response_body", "expected_recording"), list(tuple(itertools.chain(*p)) for p in PARAMETERS), ) -def testRecordAndReplay( - replaying_connection_class, protocol, response_body, expected_recording -): +def testRecordAndReplay(replaying_connection_class, protocol, response_body, expected_recording): file = StringIO() host = "api.github.com" verb = "GET" @@ -84,9 +82,7 @@ def testRecordAndReplay( connection.getresponse.return_value = response # write mock response to buffer - recording_connection = RecordingMockConnection( - file, protocol, host, None, lambda *args, **kwds: connection - ) + recording_connection = RecordingMockConnection(file, protocol, host, None, lambda *args, **kwds: connection) recording_connection.request(verb, url, None, headers) recording_connection.getresponse() recording_connection.close() diff --git a/tests/Deployment.py b/tests/Deployment.py index 95adb555..32c4b519 100644 --- a/tests/Deployment.py +++ b/tests/Deployment.py @@ -29,9 +29,7 @@ from . import Framework class Deployment(Framework.TestCase): def setUp(self): super().setUp() - self.deployment = ( - self.g.get_user().get_repo("PyGithub").get_deployment(263877258) - ) + self.deployment = self.g.get_user().get_repo("PyGithub").get_deployment(263877258) def testAttributes(self): self.assertEqual(self.deployment.id, 263877258) @@ -39,12 +37,8 @@ class Deployment(Framework.TestCase): self.deployment.url, "https://api.github.com/repos/jacquev6/PyGithub/deployments/263877258", ) - self.assertEqual( - self.deployment.ref, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5" - ) - self.assertEqual( - self.deployment.sha, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5" - ) + self.assertEqual(self.deployment.ref, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5") + self.assertEqual(self.deployment.sha, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5") self.assertEqual(self.deployment.task, "deploy") self.assertEqual(self.deployment.payload, {"test": True}) self.assertEqual(self.deployment.original_environment, "test") diff --git a/tests/DeploymentStatus.py b/tests/DeploymentStatus.py index 7b01a72c..dcfc7bf4 100644 --- a/tests/DeploymentStatus.py +++ b/tests/DeploymentStatus.py @@ -29,9 +29,7 @@ from . import Framework class DeploymentStatus(Framework.TestCase): def setUp(self): super().setUp() - self.deployment = ( - self.g.get_user().get_repo("PyGithub").get_deployment(263877258) - ) + self.deployment = self.g.get_user().get_repo("PyGithub").get_deployment(263877258) self.status = self.deployment.get_status(388454671) def testAttributes(self): diff --git a/tests/Enterprise.py b/tests/Enterprise.py index fd3da302..87a64cb3 100644 --- a/tests/Enterprise.py +++ b/tests/Enterprise.py @@ -88,9 +88,7 @@ class Enterprise(Framework.BasicTestCase): self.assertEqual(raisedexp.exception.args[0], "Unknown URL scheme") def testLongUrl(self): - g = github.Github( - auth=self.login, base_url="http://my.enterprise.com/path/to/github" - ) + g = github.Github(auth=self.login, base_url="http://my.enterprise.com/path/to/github") repos = g.get_user().get_repos() self.assertListKeyEqual( repos, diff --git a/tests/Environment.py b/tests/Environment.py index d80c93a9..a648533d 100644 --- a/tests/Environment.py +++ b/tests/Environment.py @@ -62,9 +62,7 @@ class Environment(Framework.TestCase): datetime(2022, 4, 13, 15, 6, 32, tzinfo=timezone.utc), ) self.assertTrue(self.environment.deployment_branch_policy.protected_branches) - self.assertFalse( - self.environment.deployment_branch_policy.custom_branch_policies - ) + self.assertFalse(self.environment.deployment_branch_policy.custom_branch_policies) def testProtectionRules(self): protection_rules = self.environment.protection_rules @@ -86,17 +84,13 @@ class Environment(Framework.TestCase): self.assertEqual(len(reviewers), 2) self.assertEqual(reviewers[0].type, "User") self.assertIsInstance(reviewers[0].reviewer, github.NamedUser.NamedUser) - assert isinstance( - reviewers[0].reviewer, github.NamedUser.NamedUser - ) # Make type checker happy + assert isinstance(reviewers[0].reviewer, github.NamedUser.NamedUser) # Make type checker happy self.assertEqual(reviewers[0].reviewer.id, 19245) self.assertEqual(reviewers[0].reviewer.login, "alson") self.assertEqual(reviewers[0].reviewer.type, "User") self.assertEqual(reviewers[1].type, "Team") self.assertIsInstance(reviewers[1].reviewer, github.Team.Team) - assert isinstance( - reviewers[1].reviewer, github.Team.Team - ) # Make type checker happy + assert isinstance(reviewers[1].reviewer, github.Team.Team) # Make type checker happy self.assertEqual(reviewers[1].reviewer.id, 1) self.assertEqual(reviewers[1].reviewer.slug, "justice-league") self.assertEqual(reviewers[1].reviewer.url, "https://api.github.com/teams/1") @@ -138,11 +132,7 @@ class Environment(Framework.TestCase): environment = self.repo.create_environment( "test", wait_timer=42, - reviewers=[ - github.EnvironmentProtectionRuleReviewer.ReviewerParams( - type_="User", id_=19245 - ) - ], + reviewers=[github.EnvironmentProtectionRuleReviewer.ReviewerParams(type_="User", id_=19245)], deployment_branch_policy=github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams( protected_branches=True, custom_branch_policies=False ), @@ -170,9 +160,7 @@ class Environment(Framework.TestCase): self.assertEqual(environment.protection_rules[0].type, "required_reviewers") self.assertEqual(len(environment.protection_rules[0].reviewers), 1) self.assertEqual(environment.protection_rules[0].reviewers[0].type, "User") - self.assertEqual( - environment.protection_rules[0].reviewers[0].reviewer.id, 19245 - ) + self.assertEqual(environment.protection_rules[0].reviewers[0].reviewer.id, 19245) self.assertEqual(environment.protection_rules[1].type, "wait_timer") self.assertEqual(environment.protection_rules[1].wait_timer, 42) self.assertEqual(environment.protection_rules[2].type, "branch_policy") diff --git a/tests/Exceptions.py b/tests/Exceptions.py index 6c8ba471..ee9b9268 100644 --- a/tests/Exceptions.py +++ b/tests/Exceptions.py @@ -85,9 +85,7 @@ class Exceptions(Framework.TestCase): def testBadAuthentication(self): with self.assertRaises(github.GithubException) as raisedexp: - github.Github( - auth=github.Auth.Login("BadUser", "BadPassword") - ).get_user().login + github.Github(auth=github.Auth.Login("BadUser", "BadPassword")).get_user().login self.assertEqual(raisedexp.exception.status, 401) self.assertEqual(raisedexp.exception.data, {"message": "Bad credentials"}) self.assertEqual(str(raisedexp.exception), '401 {"message": "Bad credentials"}') @@ -105,23 +103,17 @@ class SpecificExceptions(Framework.TestCase): def testBadCredentials(self): self.assertRaises( github.BadCredentialsException, - lambda: github.Github(auth=github.Auth.Login("BadUser", "BadPassword")) - .get_user() - .login, + lambda: github.Github(auth=github.Auth.Login("BadUser", "BadPassword")).get_user().login, ) def test2FARequired(self): self.assertRaises( github.TwoFactorException, - lambda: github.Github(auth=github.Auth.Login("2fauser", "password")) - .get_user() - .login, + lambda: github.Github(auth=github.Auth.Login("2fauser", "password")).get_user().login, ) def testUnknownObject(self): - self.assertRaises( - github.UnknownObjectException, lambda: self.g.get_user().get_repo("Xxx") - ) + self.assertRaises(github.UnknownObjectException, lambda: self.g.get_user().get_repo("Xxx")) def testBadUserAgent(self): self.assertRaises( diff --git a/tests/ExposeAllAttributes.py b/tests/ExposeAllAttributes.py index 6a8022b5..2385c863 100644 --- a/tests/ExposeAllAttributes.py +++ b/tests/ExposeAllAttributes.py @@ -42,9 +42,7 @@ class ExposeAllAttributes(Framework.TestCase): gistComment = gist.get_comment(4565) gistFile = gist.files[".gitignore"] gistHistoryState = gist.history[0] - gitCommit = repository.get_git_commit( - "be37b8a7f3a68631c32672dcd84d9eba27438ee6" - ) + gitCommit = repository.get_git_commit("be37b8a7f3a68631c32672dcd84d9eba27438ee6") gitAuthor = gitCommit.author gitTree = repository.get_git_tree("6f7c2d8c66d78863f7b91792deaead619799a1ce") gitTreeElement = gitTree.tree[0] diff --git a/tests/Framework.py b/tests/Framework.py index 351a6199..fd700b13 100644 --- a/tests/Framework.py +++ b/tests/Framework.py @@ -180,9 +180,7 @@ class ReplayingConnection: self.__cnx = self._realConnection(host, port, *args, **kwds) def request(self, verb, url, input, headers): - full_url = Url( - scheme=self.__protocol, host=self.__host, port=self.__port, path=url - ) + full_url = Url(scheme=self.__protocol, host=self.__host, port=self.__port, path=url) httpretty.register_uri(verb, full_url.url, body=self.__request_callback) @@ -217,9 +215,7 @@ class ReplayingConnection: return (base, sorted(qs.split("&"))) def __request_callback(self, request, uri, response_headers): - self.__readNextRequest( - self.__cnx.verb, self.__cnx.url, self.__cnx.input, self.__cnx.headers - ) + self.__readNextRequest(self.__cnx.verb, self.__cnx.url, self.__cnx.input, self.__cnx.headers) status = int(readLine(self.__file)) self.response_headers = CaseInsensitiveDict(eval(readLine(self.__file))) @@ -281,12 +277,8 @@ class BasicTestCase(unittest.TestCase): self.recordMode ): # pragma no cover (Branch useful only when recording new tests, not used during automated tests) github.Requester.Requester.injectConnectionClasses( - lambda ignored, *args, **kwds: RecordingHttpConnection( - self.__openFile("w"), *args, **kwds - ), - lambda ignored, *args, **kwds: RecordingHttpsConnection( - self.__openFile("w"), *args, **kwds - ), + lambda ignored, *args, **kwds: RecordingHttpConnection(self.__openFile("w"), *args, **kwds), + lambda ignored, *args, **kwds: RecordingHttpsConnection(self.__openFile("w"), *args, **kwds), ) import GithubCredentials # type: ignore @@ -296,30 +288,18 @@ class BasicTestCase(unittest.TestCase): else None ) self.oauth_token = ( - github.Auth.Token(GithubCredentials.oauth_token) - if GithubCredentials.oauth_token - else None - ) - self.jwt = ( - github.Auth.AppAuthToken(GithubCredentials.jwt) - if GithubCredentials.jwt - else None + github.Auth.Token(GithubCredentials.oauth_token) if GithubCredentials.oauth_token else None ) + self.jwt = github.Auth.AppAuthToken(GithubCredentials.jwt) if GithubCredentials.jwt else None self.app_auth = ( - github.Auth.AppAuth( - GithubCredentials.app_id, GithubCredentials.app_private_key - ) + github.Auth.AppAuth(GithubCredentials.app_id, GithubCredentials.app_private_key) if GithubCredentials.app_id and GithubCredentials.app_private_key else None ) else: github.Requester.Requester.injectConnectionClasses( - lambda ignored, *args, **kwds: ReplayingHttpConnection( - self.__openFile("r"), *args, **kwds - ), - lambda ignored, *args, **kwds: ReplayingHttpsConnection( - self.__openFile("r"), *args, **kwds - ), + lambda ignored, *args, **kwds: ReplayingHttpConnection(self.__openFile("r"), *args, **kwds), + lambda ignored, *args, **kwds: ReplayingHttpsConnection(self.__openFile("r"), *args, **kwds), ) self.login = github.Auth.Login("login", "password") self.oauth_token = github.Auth.Token("oauth_token") @@ -339,14 +319,8 @@ class BasicTestCase(unittest.TestCase): self.assertWarnings(warning, expected) def assertWarnings(self, warning, *expecteds): - actual = [ - (type(message), type(message.message), message.message.args) - for message in warning.warnings - ] - expected = [ - (warnings.WarningMessage, DeprecationWarning, (expected,)) - for expected in expecteds - ] + actual = [(type(message), type(message.message), message.message.args) for message in warning.warnings] + expected = [(warnings.WarningMessage, DeprecationWarning, (expected,)) for expected in expecteds] self.assertSequenceEqual(actual, expected) @contextlib.contextmanager @@ -357,14 +331,8 @@ class BasicTestCase(unittest.TestCase): def __openFile(self, mode): for (_, _, functionName, _) in traceback.extract_stack(): - if ( - functionName.startswith("test") - or functionName == "setUp" - or functionName == "tearDown" - ): - if ( - functionName != "test" - ): # because in class Hook(Framework.TestCase), method testTest calls Hook.test + if functionName.startswith("test") or functionName == "setUp" or functionName == "tearDown": + if functionName != "test": # because in class Hook(Framework.TestCase), method testTest calls Hook.test fileName = os.path.join( self.replayDataFolder, f"{self.__class__.__name__}.{functionName}.txt", diff --git a/tests/Gist.py b/tests/Gist.py index 3bc83d5e..30b40bf2 100644 --- a/tests/Gist.py +++ b/tests/Gist.py @@ -68,9 +68,7 @@ class Gist(Framework.TestCase): ) self.assertEqual(gist.history[0].user, None) self.assertEqual(gist.history[0].owner.login, "jacquev6") - self.assertEqual( - gist.history[0].version, "c464aecd7fea16684e935607eeea7ae4f8caa0e2" - ) + self.assertEqual(gist.history[0].version, "c464aecd7fea16684e935607eeea7ae4f8caa0e2") self.assertEqual(gist.html_url, "https://gist.github.com/6296732") self.assertEqual(gist.id, "6296732") self.assertTrue(gist.public) @@ -86,9 +84,7 @@ class Gist(Framework.TestCase): self.assertEqual(gist.html_url, "https://gist.github.com/6296732") self.assertEqual(gist.url, "https://api.github.com/gists/6296732") self.assertEqual(repr(gist), 'Gist(id="6296732")') - self.assertEqual( - repr(gist.files["GithubAPI.lua"]), 'GistFile(filename="GithubAPI.lua")' - ) + self.assertEqual(repr(gist.files["GithubAPI.lua"]), 'GistFile(filename="GithubAPI.lua")') def testEditWithoutParameters(self): gist = self.g.get_gist("2729810") @@ -121,13 +117,7 @@ class Gist(Framework.TestCase): def testRenameFile(self): gist = self.g.get_gist("5339374") self.assertEqual(list(gist.files.keys()), ["bar.txt"]) - gist.edit( - files={ - "bar.txt": github.InputFileContent( - gist.files["bar.txt"].content, new_name="baz.txt" - ) - } - ) + gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")}) self.assertEqual(list(gist.files.keys()), ["baz.txt"]) def testCreateComment(self): diff --git a/tests/GistComment.py b/tests/GistComment.py index 671d2b6a..270cc851 100644 --- a/tests/GistComment.py +++ b/tests/GistComment.py @@ -47,9 +47,7 @@ class GistComment(Framework.TestCase): self.comment.updated_at, datetime(2012, 5, 19, 7, 7, 57, tzinfo=timezone.utc), ) - self.assertEqual( - self.comment.url, "https://api.github.com/gists/2729810/comments/323629" - ) + self.assertEqual(self.comment.url, "https://api.github.com/gists/2729810/comments/323629") self.assertEqual(self.comment.user.login, "jacquev6") self.assertEqual( repr(self.comment), diff --git a/tests/GitBlob.py b/tests/GitBlob.py index 881378fa..48b6d42a 100644 --- a/tests/GitBlob.py +++ b/tests/GitBlob.py @@ -33,11 +33,7 @@ from . import Framework class GitBlob(Framework.TestCase): def setUp(self): super().setUp() - self.blob = ( - self.g.get_user() - .get_repo("PyGithub") - .get_git_blob("53bce9fa919b4544e67275089b3ec5b44be20667") - ) + self.blob = self.g.get_user().get_repo("PyGithub").get_git_blob("53bce9fa919b4544e67275089b3ec5b44be20667") def testAttributes(self): self.assertTrue( diff --git a/tests/GitCommit.py b/tests/GitCommit.py index e8eedfe5..a868a86c 100644 --- a/tests/GitCommit.py +++ b/tests/GitCommit.py @@ -35,11 +35,7 @@ from . import Framework class GitCommit(Framework.TestCase): def setUp(self): super().setUp() - self.commit = ( - self.g.get_user() - .get_repo("PyGithub") - .get_git_commit("4303c5b90e2216d927155e9609436ccb8984c495") - ) + self.commit = self.g.get_user().get_repo("PyGithub").get_git_commit("4303c5b90e2216d927155e9609436ccb8984c495") def testAttributes(self): self.assertEqual(self.commit.author.name, "Vincent Jacques") @@ -56,16 +52,10 @@ class GitCommit(Framework.TestCase): ) self.assertEqual(self.commit.message, "Merge branch 'develop'\n") self.assertEqual(len(self.commit.parents), 2) - self.assertEqual( - self.commit.parents[0].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d" - ) - self.assertEqual( - self.commit.parents[1].sha, "2a7e80e6421c5d4d201d60619068dea6bae612cb" - ) + self.assertEqual(self.commit.parents[0].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d") + self.assertEqual(self.commit.parents[1].sha, "2a7e80e6421c5d4d201d60619068dea6bae612cb") self.assertEqual(self.commit.sha, "4303c5b90e2216d927155e9609436ccb8984c495") - self.assertEqual( - self.commit.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad" - ) + self.assertEqual(self.commit.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad") self.assertEqual( self.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495", diff --git a/tests/GitRef.py b/tests/GitRef.py index 726d9cab..7b21fba9 100644 --- a/tests/GitRef.py +++ b/tests/GitRef.py @@ -32,16 +32,10 @@ from . import Framework class GitRef(Framework.TestCase): def setUp(self): super().setUp() - self.ref = ( - self.g.get_user() - .get_repo("PyGithub") - .get_git_ref("heads/BranchCreatedByPyGithub") - ) + self.ref = self.g.get_user().get_repo("PyGithub").get_git_ref("heads/BranchCreatedByPyGithub") def testAttributes(self): - self.assertEqual( - self.ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" - ) + self.assertEqual(self.ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") self.assertEqual(self.ref.object.type, "commit") self.assertEqual( self.ref.object.url, @@ -53,9 +47,7 @@ class GitRef(Framework.TestCase): "https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub", ) - self.assertEqual( - repr(self.ref), 'GitRef(ref="refs/heads/BranchCreatedByPyGithub")' - ) + self.assertEqual(repr(self.ref), 'GitRef(ref="refs/heads/BranchCreatedByPyGithub")') self.assertEqual( repr(self.ref.object), 'GitObject(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")', diff --git a/tests/GitRelease.py b/tests/GitRelease.py index c855eda9..9ce3a5c1 100644 --- a/tests/GitRelease.py +++ b/tests/GitRelease.py @@ -129,9 +129,7 @@ class GitRelease(Framework.TestCase): self.assertFalse(release.prerelease) self.assertEqual( release.url, - "https://api.github.com/repos/{}/{}/releases/{}".format( - user, repo_name, release_id - ), + f"https://api.github.com/repos/{user}/{repo_name}/releases/{release_id}", ) self.assertEqual(release.author._rawData["login"], user) self.assertEqual(release.author.login, user) @@ -145,15 +143,11 @@ class GitRelease(Framework.TestCase): self.assertEqual(release.published_at, publish_date) self.assertEqual( release.tarball_url, - "https://api.github.com/repos/{}/{}/tarball/{}".format( - user, repo_name, tag - ), + f"https://api.github.com/repos/{user}/{repo_name}/tarball/{tag}", ) self.assertEqual( release.zipball_url, - "https://api.github.com/repos/{}/{}/zipball/{}".format( - user, repo_name, tag - ), + f"https://api.github.com/repos/{user}/{repo_name}/zipball/{tag}", ) self.assertEqual(repr(release), 'GitRelease(title="Test")') self.assertEqual(len(release.assets), 1) @@ -204,17 +198,13 @@ class GitRelease(Framework.TestCase): release = self.new_release self.assertEqual(release.id, self.new_release_id) - release.upload_asset( - self.artifact_path, "unit test artifact", "application/zip" - ) + release.upload_asset(self.artifact_path, "unit test artifact", "application/zip") self.tearDownNewRelease() def testUploadAssetWithName(self): self.setUpNewRelease() release = self.new_release - r = release.upload_asset( - self.artifact_path, name="foobar.zip", content_type="application/zip" - ) + r = release.upload_asset(self.artifact_path, name="foobar.zip", content_type="application/zip") self.assertEqual(r.name, "foobar.zip") self.tearDownNewRelease() @@ -228,9 +218,7 @@ class GitRelease(Framework.TestCase): self.assertEqual(release.author._rawData["login"], user) self.assertEqual( release.html_url, - "https://github.com/{}/{}/releases/tag/{}".format( - user, repo_name, self.new_tag - ), + f"https://github.com/{user}/{repo_name}/releases/tag/{self.new_tag}", ) self.tearDownNewRelease() diff --git a/tests/GitTag.py b/tests/GitTag.py index 6771446e..07a46fbb 100644 --- a/tests/GitTag.py +++ b/tests/GitTag.py @@ -35,17 +35,11 @@ from . import Framework class GitTag(Framework.TestCase): def setUp(self): super().setUp() - self.tag = ( - self.g.get_user() - .get_repo("PyGithub") - .get_git_tag("f5f37322407b02a80de4526ad88d5f188977bc3c") - ) + self.tag = self.g.get_user().get_repo("PyGithub").get_git_tag("f5f37322407b02a80de4526ad88d5f188977bc3c") def testAttributes(self): self.assertEqual(self.tag.message, "Version 0.6\n") - self.assertEqual( - self.tag.object.sha, "4303c5b90e2216d927155e9609436ccb8984c495" - ) + self.assertEqual(self.tag.object.sha, "4303c5b90e2216d927155e9609436ccb8984c495") self.assertEqual(self.tag.object.type, "commit") self.assertEqual( self.tag.object.url, diff --git a/tests/GitTree.py b/tests/GitTree.py index 69718f2e..966d09a3 100644 --- a/tests/GitTree.py +++ b/tests/GitTree.py @@ -33,20 +33,14 @@ from . import Framework class GitTree(Framework.TestCase): def setUp(self): super().setUp() - self.tree = ( - self.g.get_user() - .get_repo("PyGithub") - .get_git_tree("f492784d8ca837779650d1fb406a1a3587a764ad") - ) + self.tree = self.g.get_user().get_repo("PyGithub").get_git_tree("f492784d8ca837779650d1fb406a1a3587a764ad") def testAttributes(self): self.assertEqual(self.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad") self.assertEqual(len(self.tree.tree), 11) self.assertEqual(self.tree.tree[0].mode, "100644") self.assertEqual(self.tree.tree[0].path, ".gitignore") - self.assertEqual( - self.tree.tree[0].sha, "8a9af1462c3f4e3358315c2d2e6ef1e7334c59dd" - ) + self.assertEqual(self.tree.tree[0].sha, "8a9af1462c3f4e3358315c2d2e6ef1e7334c59dd") self.assertEqual(self.tree.tree[0].size, 53) self.assertEqual(self.tree.tree[0].type, "blob") self.assertEqual( @@ -55,9 +49,7 @@ class GitTree(Framework.TestCase): ) self.assertEqual(self.tree.tree[6].mode, "040000") self.assertEqual(self.tree.tree[6].path, "ReplayDataForIntegrationTest") - self.assertEqual( - self.tree.tree[6].sha, "60b4602b2c2070246c5df078fb7a5150b45815eb" - ) + self.assertEqual(self.tree.tree[6].sha, "60b4602b2c2070246c5df078fb7a5150b45815eb") self.assertEqual(self.tree.tree[6].size, None) self.assertEqual(self.tree.tree[6].type, "tree") self.assertEqual( diff --git a/tests/GithubApp.py b/tests/GithubApp.py index 9ab0ddf8..20617c99 100644 --- a/tests/GithubApp.py +++ b/tests/GithubApp.py @@ -35,12 +35,8 @@ class GithubApp(Framework.TestCase): def testGetPublicApp(self): app = self.g.get_app(slug=self.app_slug) - self.assertEqual( - app.created_at, datetime(2018, 7, 30, 9, 30, 17, tzinfo=timezone.utc) - ) - self.assertEqual( - app.description, "Automate your workflow from idea to production" - ) + self.assertEqual(app.created_at, datetime(2018, 7, 30, 9, 30, 17, tzinfo=timezone.utc)) + self.assertEqual(app.description, "Automate your workflow from idea to production") self.assertListEqual( app.events, [ @@ -100,9 +96,7 @@ class GithubApp(Framework.TestCase): }, ) self.assertEqual(app.slug, "github-actions") - self.assertEqual( - app.updated_at, datetime(2019, 12, 10, 19, 4, 12, tzinfo=timezone.utc) - ) + self.assertEqual(app.updated_at, datetime(2019, 12, 10, 19, 4, 12, tzinfo=timezone.utc)) self.assertEqual(app.url, "/apps/github-actions") def testGetAuthenticatedApp(self): @@ -120,9 +114,7 @@ class GithubApp(Framework.TestCase): "please use github.GithubIntegration(auth=github.Auth.AppAuth(...)).get_app() instead", ) - self.assertEqual( - app.created_at, datetime(2020, 8, 1, 17, 23, 46, tzinfo=timezone.utc) - ) + self.assertEqual(app.created_at, datetime(2020, 8, 1, 17, 23, 46, tzinfo=timezone.utc)) self.assertEqual(app.description, "Sample App to test PyGithub") self.assertListEqual( app.events, @@ -149,7 +141,5 @@ class GithubApp(Framework.TestCase): }, ) self.assertEqual(app.slug, "pygithubtest") - self.assertEqual( - app.updated_at, datetime(2020, 8, 1, 17, 44, 31, tzinfo=timezone.utc) - ) + self.assertEqual(app.updated_at, datetime(2020, 8, 1, 17, 44, 31, tzinfo=timezone.utc)) self.assertEqual(app.url, "/apps/pygithubtest") diff --git a/tests/GithubIntegration.py b/tests/GithubIntegration.py index f205fd95..ddec1c1e 100644 --- a/tests/GithubIntegration.py +++ b/tests/GithubIntegration.py @@ -47,9 +47,7 @@ class GithubIntegration(Framework.BasicTestCase): def testDeprecatedAppAuth(self): # Replay data copied from testGetInstallations to test authentication only with self.assertWarns(DeprecationWarning) as warning: - github_integration = github.GithubIntegration( - integration_id=APP_ID, private_key=PRIVATE_KEY - ) + github_integration = github.GithubIntegration(integration_id=APP_ID, private_key=PRIVATE_KEY) installations = github_integration.get_installations() self.assertEqual(len(list(installations)), 2) self.assertWarning( @@ -92,9 +90,7 @@ class GithubIntegration(Framework.BasicTestCase): def testGetGithubForInstallation(self): # with verify=False, urllib3.connectionpool rightly may issue an InsecureRequestWarning # we ignore InsecureRequestWarning from urllib3.connectionpool - with self.ignoreWarning( - category=InsecureRequestWarning, module="urllib3.connectionpool" - ): + with self.ignoreWarning(category=InsecureRequestWarning, module="urllib3.connectionpool"): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) github_integration = github.GithubIntegration( auth=auth, @@ -110,18 +106,10 @@ class GithubIntegration(Framework.BasicTestCase): g = github_integration.get_github_for_installation(36541767) self.assertIsInstance(g._Github__requester.auth, AppInstallationAuth) - self.assertEqual( - g._Github__requester._Requester__base_url, "https://api.github.com" - ) - self.assertEqual( - g._Github__requester._Requester__timeout, Consts.DEFAULT_TIMEOUT + 10 - ) - self.assertEqual( - g._Github__requester._Requester__userAgent, "PyGithub/Python-Test" - ) - self.assertEqual( - g._Github__requester.per_page, Consts.DEFAULT_PER_PAGE + 10 - ) + self.assertEqual(g._Github__requester._Requester__base_url, "https://api.github.com") + self.assertEqual(g._Github__requester._Requester__timeout, Consts.DEFAULT_TIMEOUT + 10) + self.assertEqual(g._Github__requester._Requester__userAgent, "PyGithub/Python-Test") + self.assertEqual(g._Github__requester.per_page, Consts.DEFAULT_PER_PAGE + 10) self.assertEqual(g._Github__requester._Requester__verify, False) self.assertEqual(g._Github__requester._Requester__retry, 3) self.assertEqual(g._Github__requester._Requester__pool_size, 10) @@ -134,9 +122,7 @@ class GithubIntegration(Framework.BasicTestCase): github_integration = github.GithubIntegration(auth=auth) # Get repo installation access token - repo_installation_authorization = github_integration.get_access_token( - self.repo_installation_id - ) + repo_installation_authorization = github_integration.get_access_token(self.repo_installation_id) self.assertEqual( repo_installation_authorization.token, "ghs_1llwuELtXN5HDOB99XhpcTXdJxbOuF0ZlSmj", @@ -145,14 +131,10 @@ class GithubIntegration(Framework.BasicTestCase): repo_installation_authorization.permissions, {"issues": "read", "metadata": "read"}, ) - self.assertEqual( - repo_installation_authorization.repository_selection, "selected" - ) + self.assertEqual(repo_installation_authorization.repository_selection, "selected") # Get org installation access token - org_installation_authorization = github_integration.get_access_token( - self.org_installation_id - ) + org_installation_authorization = github_integration.get_access_token(self.org_installation_id) self.assertEqual( org_installation_authorization.token, "ghs_V0xygF8yACXSDz5FM65QWV1BT2vtxw0cbgPw", @@ -163,17 +145,11 @@ class GithubIntegration(Framework.BasicTestCase): "metadata": "read", "organization_administration": "read", } - self.assertDictEqual( - org_installation_authorization.permissions, org_permissions - ) - self.assertEqual( - org_installation_authorization.repository_selection, "selected" - ) + self.assertDictEqual(org_installation_authorization.permissions, org_permissions) + self.assertEqual(org_installation_authorization.repository_selection, "selected") # Get user installation access token - user_installation_authorization = github_integration.get_access_token( - self.user_installation_id - ) + user_installation_authorization = github_integration.get_access_token(self.user_installation_id) self.assertEqual( user_installation_authorization.token, "ghs_1llwuELtXN5HDOB99XhpcTXdJxbOuF0ZlSmj", @@ -182,9 +158,7 @@ class GithubIntegration(Framework.BasicTestCase): user_installation_authorization.permissions, {"issues": "read", "metadata": "read"}, ) - self.assertEqual( - user_installation_authorization.repository_selection, "selected" - ) + self.assertEqual(user_installation_authorization.repository_selection, "selected") def testGetUserInstallation(self): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) @@ -203,18 +177,14 @@ class GithubIntegration(Framework.BasicTestCase): def testGetRepoInstallation(self): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) github_integration = github.GithubIntegration(auth=auth) - installation = github_integration.get_repo_installation( - owner="ammarmallik", repo="test-runner" - ) + installation = github_integration.get_repo_installation(owner="ammarmallik", repo="test-runner") self.assertEqual(installation.id, self.repo_installation_id) def testGetAppInstallation(self): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) github_integration = github.GithubIntegration(auth=auth) - installation = github_integration.get_app_installation( - installation_id=self.org_installation_id - ) + installation = github_integration.get_app_installation(installation_id=self.org_installation_id) self.assertEqual(installation.id, self.org_installation_id) @@ -254,9 +224,7 @@ class GithubIntegration(Framework.BasicTestCase): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) github_integration = github.GithubIntegration(auth=auth) with self.assertRaises(github.GithubException) as raisedexp: - github_integration.get_access_token( - self.repo_installation_id, permissions={"test-permissions": "read"} - ) + github_integration.get_access_token(self.repo_installation_id, permissions={"test-permissions": "read"}) self.assertEqual(raisedexp.exception.status, 422) @@ -264,9 +232,7 @@ class GithubIntegration(Framework.BasicTestCase): auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY) github_integration = github.GithubIntegration(auth=auth) with self.assertRaises(github.GithubException) as raisedexp: - github_integration.get_access_token( - self.repo_installation_id, permissions="invalid_data" - ) + github_integration.get_access_token(self.repo_installation_id, permissions="invalid_data") self.assertEqual(raisedexp.exception.status, 400) diff --git a/tests/GithubObject.py b/tests/GithubObject.py index 7da4357f..87a47003 100644 --- a/tests/GithubObject.py +++ b/tests/GithubObject.py @@ -104,9 +104,7 @@ class GithubObject(unittest.TestCase): actual = gho.GithubObject._makeTimestampAttribute(1611405296) self.assertEqual(gho._ValuedAttribute, type(actual)) - self.assertEqual( - datetime(2021, 1, 23, 12, 34, 56, tzinfo=timezone.utc), actual.value - ) + self.assertEqual(datetime(2021, 1, 23, 12, 34, 56, tzinfo=timezone.utc), actual.value) def testMakeTimetsampAttributeBadValues(self): for value in ["1611405296", 1234.567]: diff --git a/tests/GithubRetry.py b/tests/GithubRetry.py index 98e639b3..b08d8618 100644 --- a/tests/GithubRetry.py +++ b/tests/GithubRetry.py @@ -81,14 +81,10 @@ class GithubRetry(unittest.TestCase): self.assertEqual(expected_total, retry.total) self.assertEqual( - expected_backoff - if expected_retry_backoff is None - else expected_retry_backoff, + expected_backoff if expected_retry_backoff is None else expected_retry_backoff, retry.get_backoff_time(), ) - self.assertEqual( - orig_retry.secondary_rate_wait, retry.secondary_rate_wait - ) + self.assertEqual(orig_retry.secondary_rate_wait, retry.secondary_rate_wait) # fmt: off log.assert_has_calls( @@ -124,11 +120,7 @@ class GithubRetry(unittest.TestCase): @contextlib.contextmanager def mock_retry_now(self, now): - if ( - sys.version_info[0] > 3 - or sys.version_info[0] == 3 - and sys.version_info[1] >= 11 - ): + if sys.version_info[0] > 3 or sys.version_info[0] == 3 and sys.version_info[1] >= 11: attr = "github.GithubRetry.GithubRetry._GithubRetry__datetime" else: attr = "github.GithubRetry._GithubRetry__datetime" @@ -162,9 +154,7 @@ class GithubRetry(unittest.TestCase): # test 2 seconds after reset, no backoff expected with self.mock_retry_now(1644768014): - retry = test_increment( - retry, response(), expected_total=0, expected_backoff=0 - ) + retry = test_increment(retry, response(), expected_total=0, expected_backoff=0) test_increment(retry, response(), expect_retry_error=True) def test_primary_rate_error_with_reset_and_exponential_backoff(self): @@ -267,9 +257,7 @@ class GithubRetry(unittest.TestCase): # test 2 seconds after reset, still expect secondary wait seconds of 60 with self.mock_retry_now(1644768014): - retry = test_increment( - retry, response(), expected_total=0, expected_backoff=60 - ) + retry = test_increment(retry, response(), expected_total=0, expected_backoff=60) test_increment(retry, response(), expect_retry_error=True) def test_secondary_rate_error_with_reset_and_exponential_backoff(self): @@ -370,9 +358,7 @@ class GithubRetry(unittest.TestCase): def test_403_with_retry_after(self): retry = github.GithubRetry(total=3) - response = urllib3.response.HTTPResponse( - status=403, headers={"Retry-After": "123"} - ) + response = urllib3.response.HTTPResponse(status=403, headers={"Retry-After": "123"}) self.do_test_default_behaviour(retry, response) def test_403_with_non_retryable_error(self): @@ -381,9 +367,7 @@ class GithubRetry(unittest.TestCase): retry.increment( "TEST", "URL", - self.response_func( - '{"message":"Missing or invalid User Agent string."}' - )(), + self.response_func('{"message":"Missing or invalid User Agent string."}')(), ) def test_misc_response(self): @@ -408,9 +392,7 @@ class GithubRetry(unittest.TestCase): self.assertEqual({}, exp.exception.headers) self.assertIsInstance(exp.exception.__cause__, RuntimeError) - self.assertEqual( - ("Failed to inspect response message",), exp.exception.__cause__.args - ) + self.assertEqual(("Failed to inspect response message",), exp.exception.__cause__.args) self.assertIsInstance(exp.exception.__cause__.__cause__, ValueError) self.assertEqual( @@ -418,6 +400,4 @@ class GithubRetry(unittest.TestCase): exp.exception.__cause__.__cause__.args, ) - log.assert_called_once_with( - logging.INFO, "Request TEST URL failed with 403: NOT GOOD" - ) + log.assert_called_once_with(logging.INFO, "Request TEST URL failed with 403: NOT GOOD") diff --git a/tests/Github_.py b/tests/Github_.py index 45eaef6e..a28e4818 100644 --- a/tests/Github_.py +++ b/tests/Github_.py @@ -179,9 +179,7 @@ class Github(Framework.TestCase): def testGetEmojis(self): emojis = self.g.get_emojis() first = emojis.get("+1") - self.assertEqual( - first, "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5" - ) + self.assertEqual(first, "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5") def testGetHook(self): hook = self.g.get_hook("activecollab") @@ -220,12 +218,8 @@ class Github(Framework.TestCase): self.assertIsInstance(delivery.request, github.HookDelivery.HookDeliveryRequest) self.assertEqual(delivery.request.headers, {"content-type": "application/json"}) self.assertEqual(delivery.request.payload, {"action": "opened"}) - self.assertIsInstance( - delivery.response, github.HookDelivery.HookDeliveryResponse - ) - self.assertEqual( - delivery.response.headers, {"content-type": "text/html;charset=utf-8"} - ) + self.assertIsInstance(delivery.response, github.HookDelivery.HookDeliveryResponse) + self.assertEqual(delivery.response.headers, {"content-type": "text/html;charset=utf-8"}) self.assertEqual(delivery.response.payload, "ok") def testGetHookDeliveries(self): @@ -474,9 +468,7 @@ class Github(Framework.TestCase): ) def testGetUsersSince(self): - self.assertListKeyBegin( - self.g.get_users(since=1000), lambda u: u.login, ["sbecker"] - ) + self.assertListKeyBegin(self.g.get_users(since=1000), lambda u: u.login, ["sbecker"]) def testGetOrganizations(self): self.assertListKeyBegin( diff --git a/tests/Hook.py b/tests/Hook.py index 9912364a..c9ed1745 100644 --- a/tests/Hook.py +++ b/tests/Hook.py @@ -54,9 +54,7 @@ class Hook(Framework.TestCase): self.hook.updated_at, datetime(2012, 5, 29, 18, 49, 47, tzinfo=timezone.utc), ) - self.assertEqual( - self.hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993" - ) + self.assertEqual(self.hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993") self.assertEqual( self.hook.test_url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993/tests", diff --git a/tests/Installation.py b/tests/Installation.py index 7529011b..c32c41fb 100644 --- a/tests/Installation.py +++ b/tests/Installation.py @@ -44,16 +44,12 @@ class Installation(Framework.BasicTestCase): repos = list(installation.get_repos()) self.assertEqual(len(repos), 2) - self.assertListEqual( - [repo.full_name for repo in repos], ["EnricoMi/sandbox", "EnricoMi/python"] - ) + self.assertListEqual([repo.full_name for repo in repos], ["EnricoMi/sandbox", "EnricoMi/python"]) def testGetGithubForInstallation(self): # with verify=False, urllib3.connectionpool rightly may issue an InsecureRequestWarning # we ignore InsecureRequestWarning from urllib3.connectionpool - with self.ignoreWarning( - category=InsecureRequestWarning, module="urllib3.connectionpool" - ): + with self.ignoreWarning(category=InsecureRequestWarning, module="urllib3.connectionpool"): self.auth = AppAuth(319953, GithubIntegration.PRIVATE_KEY) self.integration = github.GithubIntegration( auth=self.auth, @@ -71,18 +67,10 @@ class Installation(Framework.BasicTestCase): g = installation.get_github_for_installation() self.assertIsInstance(g._Github__requester.auth, AppInstallationAuth) - self.assertEqual( - g._Github__requester._Requester__base_url, "https://api.github.com" - ) - self.assertEqual( - g._Github__requester._Requester__timeout, Consts.DEFAULT_TIMEOUT + 10 - ) - self.assertEqual( - g._Github__requester._Requester__userAgent, "PyGithub/Python-Test" - ) - self.assertEqual( - g._Github__requester.per_page, Consts.DEFAULT_PER_PAGE + 10 - ) + self.assertEqual(g._Github__requester._Requester__base_url, "https://api.github.com") + self.assertEqual(g._Github__requester._Requester__timeout, Consts.DEFAULT_TIMEOUT + 10) + self.assertEqual(g._Github__requester._Requester__userAgent, "PyGithub/Python-Test") + self.assertEqual(g._Github__requester.per_page, Consts.DEFAULT_PER_PAGE + 10) self.assertEqual(g._Github__requester._Requester__verify, False) self.assertEqual(g._Github__requester._Requester__retry, 3) self.assertEqual(g._Github__requester._Requester__pool_size, 10) diff --git a/tests/Issue.py b/tests/Issue.py index bf2b749e..1707c02c 100644 --- a/tests/Issue.py +++ b/tests/Issue.py @@ -45,9 +45,7 @@ class Issue(Framework.TestCase): def testAttributes(self): self.assertEqual(self.issue.assignee.login, "jacquev6") - self.assertListKeyEqual( - self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"] - ) + self.assertListKeyEqual(self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"]) self.assertEqual(self.issue.body, "Body edited by PyGithub") self.assertEqual( self.issue.closed_at, @@ -67,9 +65,7 @@ class Issue(Framework.TestCase): self.issue.events_url, "https://github.com/jacquev6/PyGithub/issues/28/events", ) - self.assertEqual( - self.issue.html_url, "https://github.com/jacquev6/PyGithub/issues/28" - ) + self.assertEqual(self.issue.html_url, "https://github.com/jacquev6/PyGithub/issues/28") self.assertEqual(self.issue.id, 4653757) self.assertListKeyEqual( self.issue.labels, @@ -92,16 +88,12 @@ class Issue(Framework.TestCase): self.issue.updated_at, datetime(2012, 5, 26, 14, 59, 33, tzinfo=timezone.utc), ) - self.assertEqual( - self.issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/28" - ) + self.assertEqual(self.issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/28") self.assertFalse(self.issue.locked) self.assertIsNone(self.issue.active_lock_reason) self.assertEqual(self.issue.user.login, "jacquev6") self.assertEqual(self.issue.repository.name, "PyGithub") - self.assertEqual( - repr(self.issue), 'Issue(title="Issue created by PyGithub", number=28)' - ) + self.assertEqual(repr(self.issue), 'Issue(title="Issue created by PyGithub", number=28)') def testEditWithoutParameters(self): self.issue.edit() @@ -119,9 +111,7 @@ class Issue(Framework.TestCase): ["jacquev6", "stuglaser"], ) self.assertEqual(self.issue.assignee.login, "jacquev6") - self.assertListKeyEqual( - self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"] - ) + self.assertListKeyEqual(self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"]) self.assertEqual(self.issue.body, "Body edited by PyGithub") self.assertEqual(self.issue.state, "open") self.assertEqual(self.issue.title, "Title edited by PyGithub") @@ -158,23 +148,17 @@ class Issue(Framework.TestCase): self.assertEqual(comment.id, 5808311) def testGetComments(self): - self.assertListKeyEqual( - self.issue.get_comments(), lambda c: c.user.login, ["jacquev6", "roskakori"] - ) + self.assertListKeyEqual(self.issue.get_comments(), lambda c: c.user.login, ["jacquev6", "roskakori"]) def testGetCommentsSince(self): self.assertListKeyEqual( - self.issue.get_comments( - datetime(2012, 5, 26, 13, 59, 33, tzinfo=timezone.utc) - ), + self.issue.get_comments(datetime(2012, 5, 26, 13, 59, 33, tzinfo=timezone.utc)), lambda c: c.user.login, ["jacquev6", "roskakori"], ) def testGetEvents(self): - self.assertListKeyEqual( - self.issue.get_events(), lambda e: e.id, [15819975, 15820048] - ) + self.assertListKeyEqual(self.issue.get_events(), lambda e: e.id, [15819975, 15820048]) def testGetLabels(self): self.assertListKeyEqual( @@ -186,9 +170,7 @@ class Issue(Framework.TestCase): def testAddAndRemoveAssignees(self): user1 = "jayfk" user2 = self.g.get_user("jzelinskie") - self.assertListKeyEqual( - self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"] - ) + self.assertListKeyEqual(self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"]) self.issue.add_to_assignees(user1, user2) self.assertListKeyEqual( self.issue.assignees, @@ -196,9 +178,7 @@ class Issue(Framework.TestCase): ["jacquev6", "stuglaser", "jayfk", "jzelinskie"], ) self.issue.remove_from_assignees(user1, user2) - self.assertListKeyEqual( - self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"] - ) + self.assertListKeyEqual(self.issue.assignees, lambda a: a.login, ["jacquev6", "stuglaser"]) def testAddAndRemoveLabels(self): bug = self.repo.get_label("Bug") @@ -215,9 +195,7 @@ class Issue(Framework.TestCase): ["Project management", "Question"], ) self.issue.remove_from_labels(question) - self.assertListKeyEqual( - self.issue.get_labels(), lambda l: l.name, ["Project management"] - ) + self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management"]) self.issue.add_to_labels(bug, question) self.assertListKeyEqual( self.issue.get_labels(), @@ -240,9 +218,7 @@ class Issue(Framework.TestCase): ["Project management", "Question"], ) self.issue.remove_from_labels(question) - self.assertListKeyEqual( - self.issue.get_labels(), lambda l: l.name, ["Project management"] - ) + self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management"]) self.issue.add_to_labels(bug, question) self.assertListKeyEqual( self.issue.get_labels(), @@ -261,9 +237,7 @@ class Issue(Framework.TestCase): self.issue.delete_labels() self.assertListKeyEqual(self.issue.get_labels(), None, []) self.issue.set_labels(bug, question) - self.assertListKeyEqual( - self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"] - ) + self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"]) def testDeleteAndSetLabelsWithStringArguments(self): bug = "Bug" @@ -276,9 +250,7 @@ class Issue(Framework.TestCase): self.issue.delete_labels() self.assertListKeyEqual(self.issue.get_labels(), None, []) self.issue.set_labels(bug, question) - self.assertListKeyEqual( - self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"] - ) + self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"]) def testGetReactions(self): reactions = self.issue.get_reactions() @@ -331,9 +303,7 @@ class Issue(Framework.TestCase): self.assertIsNotNone(event.source) self.assertEqual(event.source.type, "issue") self.assertEqual(event.source.issue.number, 857) - self.assertEqual( - repr(event.source), 'TimelineEventSource(type="issue")' - ) + self.assertEqual(repr(event.source), 'TimelineEventSource(type="issue")') else: self.assertIsNotNone(event.id) self.assertIsNotNone(event.node_id) diff --git a/tests/Issue134.py b/tests/Issue134.py index 8a36f9b9..e45497ba 100644 --- a/tests/Issue134.py +++ b/tests/Issue134.py @@ -29,9 +29,7 @@ import github from . import Framework -class Issue134( - Framework.BasicTestCase -): # https://github.com/jacquev6/PyGithub/pull/134 +class Issue134(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/pull/134 def testGetAuthorizationsFailsWhenAutenticatedThroughOAuth(self): g = github.Github(auth=self.oauth_token) with self.assertRaises(github.GithubException) as raisedexp: diff --git a/tests/Issue140.py b/tests/Issue140.py index e5433f43..722b1c49 100644 --- a/tests/Issue140.py +++ b/tests/Issue140.py @@ -55,8 +55,6 @@ class Issue140(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issu def testGetDirContentsWithRef(self): self.assertEqual( - len( - self.repo.get_contents("js", "8c7f9c66a7d12f47f50618ef420868fe836d0c33") - ), + len(self.repo.get_contents("js", "8c7f9c66a7d12f47f50618ef420868fe836d0c33")), 15, ) diff --git a/tests/Issue494.py b/tests/Issue494.py index 10535107..38bb7d75 100644 --- a/tests/Issue494.py +++ b/tests/Issue494.py @@ -32,7 +32,6 @@ class Issue494(Framework.TestCase): def testRepr(self): expected = ( - 'PullRequest(title="Change SetHostnameCustomizer to check if ' - '/etc/sysconfig/network exist…", number=465)' + 'PullRequest(title="Change SetHostnameCustomizer to check if ' '/etc/sysconfig/network exist…", number=465)' ) self.assertEqual(self.pull.__repr__(), expected) diff --git a/tests/Issue80.py b/tests/Issue80.py index f625df62..3f2dcb7f 100644 --- a/tests/Issue80.py +++ b/tests/Issue80.py @@ -30,17 +30,11 @@ import github from . import Framework -class Issue80( - Framework.BasicTestCase -): # https://github.com/jacquev6/PyGithub/issues/80 +class Issue80(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/issues/80 def testIgnoreHttpsFromGithubEnterprise(self): - g = github.Github( - auth=self.login, base_url="http://my.enterprise.com/some/prefix" - ) # http here + g = github.Github(auth=self.login, base_url="http://my.enterprise.com/some/prefix") # http here org = g.get_organization("BeaverSoftware") - self.assertEqual( - org.url, "https://my.enterprise.com/some/prefix/orgs/BeaverSoftware" - ) # https returned + self.assertEqual(org.url, "https://my.enterprise.com/some/prefix/orgs/BeaverSoftware") # https returned self.assertListKeyEqual( org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"] ) # But still http in second request based on org.url @@ -51,9 +45,7 @@ class Issue80( base_url="http://my.enterprise.com:1234/some/prefix", ) # http here org = g.get_organization("BeaverSoftware") - self.assertEqual( - org.url, "https://my.enterprise.com:1234/some/prefix/orgs/BeaverSoftware" - ) # https returned + self.assertEqual(org.url, "https://my.enterprise.com:1234/some/prefix/orgs/BeaverSoftware") # https returned self.assertListKeyEqual( org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"] ) # But still http in second request based on org.url diff --git a/tests/Issue87.py b/tests/Issue87.py index d78e755d..37416295 100644 --- a/tests/Issue87.py +++ b/tests/Issue87.py @@ -34,9 +34,7 @@ class Issue87(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issue self.repo = self.g.get_user().get_repo("PyGithub") def testCreateIssueWithPercentInTitle(self): - issue = self.repo.create_issue( - "Issue with percent % in title created by PyGithub" - ) + issue = self.repo.create_issue("Issue with percent % in title created by PyGithub") self.assertEqual(issue.number, 99) def testCreateIssueWithPercentInBody(self): @@ -44,13 +42,9 @@ class Issue87(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issue self.assertEqual(issue.number, 98) def testCreateIssueWithEscapedPercentInTitle(self): - issue = self.repo.create_issue( - "Issue with escaped percent %25 in title created by PyGithub" - ) + issue = self.repo.create_issue("Issue with escaped percent %25 in title created by PyGithub") self.assertEqual(issue.number, 97) def testCreateIssueWithEscapedPercentInBody(self): - issue = self.repo.create_issue( - "Issue created by PyGithub", "Escaped percent %25 in body" - ) + issue = self.repo.create_issue("Issue created by PyGithub", "Escaped percent %25 in body") self.assertEqual(issue.number, 96) diff --git a/tests/Issue945.py b/tests/Issue945.py index 59f812b6..a9fa8e5b 100644 --- a/tests/Issue945.py +++ b/tests/Issue945.py @@ -32,22 +32,12 @@ class Issue945(Framework.TestCase): # https://github.com/PyGithub/PyGithub/issu def testReservedPaginatedListAttributePreservation(self): r1 = self.list.reversed - self.assertEqual( - self.list._PaginatedList__contentClass, r1._PaginatedList__contentClass - ) - self.assertEqual( - self.list._PaginatedList__requester, r1._PaginatedList__requester - ) - self.assertEqual( - self.list._PaginatedList__firstUrl, r1._PaginatedList__firstUrl - ) - self.assertEqual( - self.list._PaginatedList__firstParams, r1._PaginatedList__firstParams - ) + self.assertEqual(self.list._PaginatedList__contentClass, r1._PaginatedList__contentClass) + self.assertEqual(self.list._PaginatedList__requester, r1._PaginatedList__requester) + self.assertEqual(self.list._PaginatedList__firstUrl, r1._PaginatedList__firstUrl) + self.assertEqual(self.list._PaginatedList__firstParams, r1._PaginatedList__firstParams) self.assertEqual(self.list._PaginatedList__headers, r1._PaginatedList__headers) - self.assertEqual( - self.list._PaginatedList__list_item, r1._PaginatedList__list_item - ) + self.assertEqual(self.list._PaginatedList__list_item, r1._PaginatedList__list_item) self.assertTrue(self.list_with_headers._PaginatedList__headers is not None) r2 = self.list_with_headers.reversed @@ -59,16 +49,12 @@ class Issue945(Framework.TestCase): # https://github.com/PyGithub/PyGithub/issu self.list_with_headers._PaginatedList__requester, r2._PaginatedList__requester, ) - self.assertEqual( - self.list_with_headers._PaginatedList__firstUrl, r2._PaginatedList__firstUrl - ) + self.assertEqual(self.list_with_headers._PaginatedList__firstUrl, r2._PaginatedList__firstUrl) self.assertEqual( self.list_with_headers._PaginatedList__firstParams, r2._PaginatedList__firstParams, ) - self.assertEqual( - self.list_with_headers._PaginatedList__headers, r2._PaginatedList__headers - ) + self.assertEqual(self.list_with_headers._PaginatedList__headers, r2._PaginatedList__headers) self.assertEqual( self.list_with_headers._PaginatedList__list_item, r2._PaginatedList__list_item, diff --git a/tests/IssueComment.py b/tests/IssueComment.py index 5af024e7..ebe4e758 100644 --- a/tests/IssueComment.py +++ b/tests/IssueComment.py @@ -36,9 +36,7 @@ from . import Framework class IssueComment(Framework.TestCase): def setUp(self): super().setUp() - self.comment = ( - self.g.get_user().get_repo("PyGithub").get_issue(28).get_comment(5808311) - ) + self.comment = self.g.get_user().get_repo("PyGithub").get_issue(28).get_comment(5808311) def testAttributes(self): self.assertEqual(self.comment.body, "Comment created by PyGithub") diff --git a/tests/IssueEvent.py b/tests/IssueEvent.py index de299d59..0a8c67c6 100644 --- a/tests/IssueEvent.py +++ b/tests/IssueEvent.py @@ -86,9 +86,7 @@ class IssueEvent(Framework.TestCase): self.event_subscribed.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/16347479", ) - self.assertEqual( - self.event_subscribed.node_id, "MDE1OlN1YnNjcmliZWRFdmVudDE2MzQ3NDc5" - ) + self.assertEqual(self.event_subscribed.node_id, "MDE1OlN1YnNjcmliZWRFdmVudDE2MzQ3NDc5") self.assertEqual(self.event_subscribed.commit_url, None) self.assertEqual(self.event_subscribed.label, None) self.assertEqual(self.event_subscribed.assignee, None) @@ -115,9 +113,7 @@ class IssueEvent(Framework.TestCase): self.event_assigned.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/16347480", ) - self.assertEqual( - self.event_assigned.node_id, "MDEzOkFzc2lnbmVkRXZlbnQxNjM0NzQ4MA==" - ) + self.assertEqual(self.event_assigned.node_id, "MDEzOkFzc2lnbmVkRXZlbnQxNjM0NzQ4MA==") self.assertEqual(self.event_assigned.commit_url, None) self.assertEqual(self.event_assigned.label, None) self.assertEqual(self.event_assigned.assignee.login, "jacquev6") @@ -132,9 +128,7 @@ class IssueEvent(Framework.TestCase): def testEvent_referenced_Attributes(self): self.assertEqual(self.event_referenced.actor.login, "jacquev6") - self.assertEqual( - self.event_referenced.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433" - ) + self.assertEqual(self.event_referenced.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433") self.assertEqual( self.event_referenced.created_at, datetime(2012, 5, 27, 7, 29, 25, tzinfo=timezone.utc), @@ -146,9 +140,7 @@ class IssueEvent(Framework.TestCase): self.event_referenced.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/16348656", ) - self.assertEqual( - self.event_referenced.node_id, "MDE1OlJlZmVyZW5jZWRFdmVudDE2MzQ4NjU2" - ) + self.assertEqual(self.event_referenced.node_id, "MDE1OlJlZmVyZW5jZWRFdmVudDE2MzQ4NjU2") self.assertEqual( self.event_referenced.commit_url, "https://api.github.com/repos/PyGithub/PyGithub/commits/ed866fc43833802ab553e5ff8581c81bb00dd433", @@ -232,9 +224,7 @@ class IssueEvent(Framework.TestCase): self.event_mentioned.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1009034767", ) - self.assertEqual( - self.event_mentioned.node_id, "MDE0Ok1lbnRpb25lZEV2ZW50MTAwOTAzNDc2Nw==" - ) + self.assertEqual(self.event_mentioned.node_id, "MDE0Ok1lbnRpb25lZEV2ZW50MTAwOTAzNDc2Nw==") self.assertEqual(self.event_mentioned.commit_url, None) self.assertEqual(self.event_mentioned.label, None) self.assertEqual(self.event_mentioned.assignee, None) @@ -249,9 +239,7 @@ class IssueEvent(Framework.TestCase): def testEvent_merged_Attributes(self): self.assertEqual(self.event_merged.actor.login, "jzelinskie") - self.assertEqual( - self.event_merged.commit_id, "2525515b094d7425f7018eb5b66171e21c5fbc10" - ) + self.assertEqual(self.event_merged.commit_id, "2525515b094d7425f7018eb5b66171e21c5fbc10") self.assertEqual( self.event_merged.created_at, datetime(2017, 3, 25, 16, 52, 49, tzinfo=timezone.utc), @@ -263,9 +251,7 @@ class IssueEvent(Framework.TestCase): self.event_merged.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1015402964", ) - self.assertEqual( - self.event_merged.node_id, "MDExOk1lcmdlZEV2ZW50MTAxNTQwMjk2NA==" - ) + self.assertEqual(self.event_merged.node_id, "MDExOk1lcmdlZEV2ZW50MTAxNTQwMjk2NA==") self.assertEqual( self.event_merged.commit_url, "https://api.github.com/repos/PyGithub/PyGithub/commits/2525515b094d7425f7018eb5b66171e21c5fbc10", @@ -303,12 +289,8 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_review_requested.label, None) self.assertEqual(self.event_review_requested.assignee, None) self.assertEqual(self.event_review_requested.assigner, None) - self.assertEqual( - self.event_review_requested.review_requester.login, "jzelinskie" - ) - self.assertEqual( - self.event_review_requested.requested_reviewer.login, "jzelinskie" - ) + self.assertEqual(self.event_review_requested.review_requester.login, "jzelinskie") + self.assertEqual(self.event_review_requested.requested_reviewer.login, "jzelinskie") self.assertEqual(self.event_review_requested.milestone, None) self.assertEqual(self.event_review_requested.rename, None) self.assertEqual(self.event_review_requested.dismissed_review, None) @@ -329,9 +311,7 @@ class IssueEvent(Framework.TestCase): self.event_reopened.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1782463023", ) - self.assertEqual( - self.event_reopened.node_id, "MDEzOlJlb3BlbmVkRXZlbnQxNzgyNDYzMDIz" - ) + self.assertEqual(self.event_reopened.node_id, "MDEzOlJlb3BlbmVkRXZlbnQxNzgyNDYzMDIz") self.assertEqual(self.event_reopened.commit_url, None) self.assertEqual(self.event_reopened.label, None) self.assertEqual(self.event_reopened.assignee, None) @@ -358,9 +338,7 @@ class IssueEvent(Framework.TestCase): self.event_unassigned.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1782463379", ) - self.assertEqual( - self.event_unassigned.node_id, "MDE1OlVuYXNzaWduZWRFdmVudDE3ODI0NjMzNzk=" - ) + self.assertEqual(self.event_unassigned.node_id, "MDE1OlVuYXNzaWduZWRFdmVudDE3ODI0NjMzNzk=") self.assertEqual(self.event_unassigned.commit_url, None) self.assertEqual(self.event_unassigned.label, None) self.assertEqual(self.event_unassigned.actor.login, "sfdye") @@ -387,9 +365,7 @@ class IssueEvent(Framework.TestCase): self.event_unlabeled.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1782463917", ) - self.assertEqual( - self.event_unlabeled.node_id, "MDE0OlVubGFiZWxlZEV2ZW50MTc4MjQ2MzkxNw==" - ) + self.assertEqual(self.event_unlabeled.node_id, "MDE0OlVubGFiZWxlZEV2ZW50MTc4MjQ2MzkxNw==") self.assertEqual(self.event_unlabeled.commit_url, None) self.assertEqual(self.event_unlabeled.label.name, "improvement") self.assertEqual(self.event_unlabeled.assignee, None) @@ -416,9 +392,7 @@ class IssueEvent(Framework.TestCase): self.event_renamed.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1782472556", ) - self.assertEqual( - self.event_renamed.node_id, "MDE3OlJlbmFtZWRUaXRsZUV2ZW50MTc4MjQ3MjU1Ng==" - ) + self.assertEqual(self.event_renamed.node_id, "MDE3OlJlbmFtZWRUaXRsZUV2ZW50MTc4MjQ3MjU1Ng==") self.assertEqual(self.event_renamed.commit_url, None) self.assertEqual(self.event_renamed.label, None) self.assertEqual(self.event_renamed.assignee, None) @@ -525,9 +499,7 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_head_ref_deleted.rename, None) self.assertEqual(self.event_head_ref_restored.dismissed_review, None) self.assertEqual(self.event_head_ref_deleted.lock_reason, None) - self.assertEqual( - repr(self.event_head_ref_restored), "IssueEvent(id=1782917299)" - ) + self.assertEqual(repr(self.event_head_ref_restored), "IssueEvent(id=1782917299)") def testEvent_milestoned_Attributes(self): self.assertEqual(self.event_milestoned.actor.login, "sfdye") @@ -543,9 +515,7 @@ class IssueEvent(Framework.TestCase): self.event_milestoned.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1783596418", ) - self.assertEqual( - self.event_milestoned.node_id, "MDE1Ok1pbGVzdG9uZWRFdmVudDE3ODM1OTY0MTg=" - ) + self.assertEqual(self.event_milestoned.node_id, "MDE1Ok1pbGVzdG9uZWRFdmVudDE3ODM1OTY0MTg=") self.assertEqual(self.event_milestoned.commit_url, None) self.assertEqual(self.event_milestoned.label, None) self.assertEqual(self.event_milestoned.assignee, None) @@ -602,9 +572,7 @@ class IssueEvent(Framework.TestCase): self.event_locked.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1783596743", ) - self.assertEqual( - self.event_locked.node_id, "MDExOkxvY2tlZEV2ZW50MTc4MzU5Njc0Mw==" - ) + self.assertEqual(self.event_locked.node_id, "MDExOkxvY2tlZEV2ZW50MTc4MzU5Njc0Mw==") self.assertEqual(self.event_locked.commit_url, None) self.assertEqual(self.event_locked.label, None) self.assertEqual(self.event_locked.assignee, None) @@ -631,9 +599,7 @@ class IssueEvent(Framework.TestCase): self.event_unlocked.url, "https://api.github.com/repos/PyGithub/PyGithub/issues/events/1783596818", ) - self.assertEqual( - self.event_unlocked.node_id, "MDEzOlVubG9ja2VkRXZlbnQxNzgzNTk2ODE4" - ) + self.assertEqual(self.event_unlocked.node_id, "MDEzOlVubG9ja2VkRXZlbnQxNzgzNTk2ODE4") self.assertEqual(self.event_unlocked.commit_url, None) self.assertEqual(self.event_unlocked.label, None) self.assertEqual(self.event_unlocked.assignee, None) @@ -690,9 +656,7 @@ class IssueEvent(Framework.TestCase): self.event_review_request_removed.created_at, datetime(2018, 8, 11, 12, 32, 59, tzinfo=timezone.utc), ) - self.assertEqual( - self.event_review_request_removed.event, "review_request_removed" - ) + self.assertEqual(self.event_review_request_removed.event, "review_request_removed") self.assertEqual(self.event_review_request_removed.id, 1783779835) self.assertEqual(self.event_review_request_removed.issue.number, 857) self.assertEqual( @@ -707,19 +671,13 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_review_request_removed.label, None) self.assertEqual(self.event_review_request_removed.assignee, None) self.assertEqual(self.event_review_request_removed.assigner, None) - self.assertEqual( - self.event_review_request_removed.review_requester.login, "sfdye" - ) - self.assertEqual( - self.event_review_request_removed.requested_reviewer.login, "jasonwhite" - ) + self.assertEqual(self.event_review_request_removed.review_requester.login, "sfdye") + self.assertEqual(self.event_review_request_removed.requested_reviewer.login, "jasonwhite") self.assertEqual(self.event_review_request_removed.milestone, None) self.assertEqual(self.event_review_request_removed.rename, None) self.assertEqual(self.event_review_request_removed.dismissed_review, None) self.assertEqual(self.event_review_request_removed.lock_reason, None) - self.assertEqual( - repr(self.event_review_request_removed), "IssueEvent(id=1783779835)" - ) + self.assertEqual(repr(self.event_review_request_removed), "IssueEvent(id=1783779835)") def testEvent_marked_as_duplicate_Attributes(self): self.assertEqual(self.event_marked_as_duplicate.actor.login, "sfdye") @@ -749,9 +707,7 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_marked_as_duplicate.rename, None) self.assertEqual(self.event_marked_as_duplicate.dismissed_review, None) self.assertEqual(self.event_marked_as_duplicate.lock_reason, None) - self.assertEqual( - repr(self.event_marked_as_duplicate), "IssueEvent(id=1783779725)" - ) + self.assertEqual(repr(self.event_marked_as_duplicate), "IssueEvent(id=1783779725)") def testEvent_unmarked_as_duplicate_Attributes(self): self.assertEqual(self.event_unmarked_as_duplicate.actor.login, "sfdye") @@ -760,9 +716,7 @@ class IssueEvent(Framework.TestCase): self.event_unmarked_as_duplicate.created_at, datetime(2018, 8, 15, 2, 57, 46, tzinfo=timezone.utc), ) - self.assertEqual( - self.event_unmarked_as_duplicate.event, "unmarked_as_duplicate" - ) + self.assertEqual(self.event_unmarked_as_duplicate.event, "unmarked_as_duplicate") self.assertEqual(self.event_unmarked_as_duplicate.id, 1789228962) self.assertEqual(self.event_unmarked_as_duplicate.issue.number, 857) self.assertEqual( @@ -783,9 +737,7 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_unmarked_as_duplicate.rename, None) self.assertEqual(self.event_unmarked_as_duplicate.dismissed_review, None) self.assertEqual(self.event_unmarked_as_duplicate.lock_reason, None) - self.assertEqual( - repr(self.event_unmarked_as_duplicate), "IssueEvent(id=1789228962)" - ) + self.assertEqual(repr(self.event_unmarked_as_duplicate), "IssueEvent(id=1789228962)") def testEvent_added_to_project_Attributes(self): self.assertEqual(self.event_added_to_project.actor.login, "sfdye") @@ -824,9 +776,7 @@ class IssueEvent(Framework.TestCase): self.event_moved_columns_in_project.created_at, datetime(2018, 8, 16, 8, 13, 55, tzinfo=timezone.utc), ) - self.assertEqual( - self.event_moved_columns_in_project.event, "moved_columns_in_project" - ) + self.assertEqual(self.event_moved_columns_in_project.event, "moved_columns_in_project") self.assertEqual(self.event_moved_columns_in_project.id, 1791767766) self.assertEqual(self.event_moved_columns_in_project.issue.number, 857) self.assertEqual( @@ -847,9 +797,7 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_moved_columns_in_project.rename, None) self.assertEqual(self.event_moved_columns_in_project.dismissed_review, None) self.assertEqual(self.event_moved_columns_in_project.lock_reason, None) - self.assertEqual( - repr(self.event_moved_columns_in_project), "IssueEvent(id=1791767766)" - ) + self.assertEqual(repr(self.event_moved_columns_in_project), "IssueEvent(id=1791767766)") def testEvent_removed_from_project_Attributes(self): self.assertEqual(self.event_removed_from_project.actor.login, "sfdye") @@ -879,9 +827,7 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_removed_from_project.rename, None) self.assertEqual(self.event_removed_from_project.dismissed_review, None) self.assertEqual(self.event_removed_from_project.lock_reason, None) - self.assertEqual( - repr(self.event_removed_from_project), "IssueEvent(id=1791768212)" - ) + self.assertEqual(repr(self.event_removed_from_project), "IssueEvent(id=1791768212)") def testEvent_converted_note_to_issue_Attributes(self): self.assertEqual(self.event_converted_note_to_issue.actor.login, "sfdye") @@ -890,9 +836,7 @@ class IssueEvent(Framework.TestCase): self.event_converted_note_to_issue.created_at, datetime(2018, 8, 16, 8, 14, 34, tzinfo=timezone.utc), ) - self.assertEqual( - self.event_converted_note_to_issue.event, "converted_note_to_issue" - ) + self.assertEqual(self.event_converted_note_to_issue.event, "converted_note_to_issue") self.assertEqual(self.event_converted_note_to_issue.id, 1791769149) self.assertEqual(self.event_converted_note_to_issue.issue.number, 866) self.assertEqual( @@ -913,6 +857,4 @@ class IssueEvent(Framework.TestCase): self.assertEqual(self.event_converted_note_to_issue.rename, None) self.assertEqual(self.event_converted_note_to_issue.dismissed_review, None) self.assertEqual(self.event_converted_note_to_issue.lock_reason, None) - self.assertEqual( - repr(self.event_converted_note_to_issue), "IssueEvent(id=1791769149)" - ) + self.assertEqual(repr(self.event_converted_note_to_issue), "IssueEvent(id=1791769149)") diff --git a/tests/Label.py b/tests/Label.py index 10065544..5e0e7a55 100644 --- a/tests/Label.py +++ b/tests/Label.py @@ -39,15 +39,11 @@ class Label(Framework.TestCase): self.assertEqual(self.label.color, "e10c02") self.assertEqual(self.label.name, "Bug") self.assertIsNone(self.label.description) - self.assertEqual( - self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug" - ) + self.assertEqual(self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug") self.assertEqual(repr(self.label), 'Label(name="Bug")') def testEdit(self): - self.label.edit( - "LabelEditedByPyGithub", "0000ff", "Description of LabelEditedByPyGithub" - ) + self.label.edit("LabelEditedByPyGithub", "0000ff", "Description of LabelEditedByPyGithub") self.assertEqual(self.label.color, "0000ff") self.assertEqual(self.label.description, "Description of LabelEditedByPyGithub") self.assertEqual(self.label.name, "LabelEditedByPyGithub") diff --git a/tests/License.py b/tests/License.py index 57a956c6..7f27e461 100644 --- a/tests/License.py +++ b/tests/License.py @@ -47,9 +47,7 @@ class License(Framework.TestCase): self.assertEqual(self.license.conditions, ["include-copyright"]) self.assertEqual(self.license.limitations, ["liability", "warranty"]) self.assertEqual(self.license.url, "https://api.github.com/licenses/mit") - self.assertEqual( - self.license.html_url, "http://choosealicense.com/licenses/mit/" - ) + self.assertEqual(self.license.html_url, "http://choosealicense.com/licenses/mit/") self.assertEqual( self.license.implementation, """Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.""", diff --git a/tests/Logging_.py b/tests/Logging_.py index d21c143a..149739c5 100644 --- a/tests/Logging_.py +++ b/tests/Logging_.py @@ -86,9 +86,7 @@ class Logging(Framework.BasicTestCase): self.assertEqual(self.logger.output, output) def testLoggingWithBasicAuthentication(self): - self.assertEqual( - github.Github(auth=self.login).get_user().name, "Vincent Jacques" - ) + self.assertEqual(github.Github(auth=self.login).get_user().name, "Vincent Jacques") url = "https://api.github.com/user" requestHeaders = { "Authorization": "Basic (login and password removed)", @@ -115,9 +113,7 @@ class Logging(Framework.BasicTestCase): self.assertLogging("GET", url, requestHeaders, responseHeaders, output) def testLoggingWithOAuthAuthentication(self): - self.assertEqual( - github.Github(auth=self.oauth_token).get_user().name, "Vincent Jacques" - ) + self.assertEqual(github.Github(auth=self.oauth_token).get_user().name, "Vincent Jacques") url = "https://api.github.com/user" requestHeaders = { "Authorization": "token (oauth token removed)", @@ -172,9 +168,7 @@ class Logging(Framework.BasicTestCase): def testLoggingWithBaseUrl(self): # ReplayData forged, not recorded self.assertEqual( - github.Github(base_url="http://my.enterprise.com/my/prefix") - .get_user("jacquev6") - .name, + github.Github(base_url="http://my.enterprise.com/my/prefix").get_user("jacquev6").name, "Vincent Jacques", ) url = "http://my.enterprise.com/my/prefix/users/jacquev6" diff --git a/tests/Migration.py b/tests/Migration.py index cd343081..82f85aa2 100644 --- a/tests/Migration.py +++ b/tests/Migration.py @@ -69,9 +69,7 @@ class Migration(Framework.TestCase): self.assertEqual(self.migration.exclude_attachments, False) self.assertEqual(len(self.migration.repositories), 1) self.assertEqual(self.migration.repositories[0].name, "sample-repo") - self.assertEqual( - self.migration.url, "https://api.github.com/user/migrations/25320" - ) + self.assertEqual(self.migration.url, "https://api.github.com/user/migrations/25320") self.assertEqual( self.migration.created_at, datetime(2018, 9, 14, 1, 35, 35, tzinfo=tzoffset(None, 19800)), @@ -86,9 +84,7 @@ class Migration(Framework.TestCase): ) def testGetArchiveUrlWhenNotExported(self): - self.assertRaises( - github.UnknownObjectException, lambda: self.migration.get_archive_url() - ) + self.assertRaises(github.UnknownObjectException, lambda: self.migration.get_archive_url()) def testGetStatus(self): self.assertEqual(self.migration.get_status(), "exported") @@ -103,9 +99,7 @@ class Migration(Framework.TestCase): self.assertEqual(self.migration.delete(), None) def testGetArchiveUrlWhenDeleted(self): - self.assertRaises( - github.UnknownObjectException, lambda: self.migration.get_archive_url() - ) + self.assertRaises(github.UnknownObjectException, lambda: self.migration.get_archive_url()) def testUnlockRepo(self): self.assertEqual(self.migration.unlock_repo("sample-repo"), None) diff --git a/tests/Milestone.py b/tests/Milestone.py index 3c9820db..7a85a973 100644 --- a/tests/Milestone.py +++ b/tests/Milestone.py @@ -57,9 +57,7 @@ class Milestone(Framework.TestCase): "https://api.github.com/repos/jacquev6/PyGithub/milestones/1", ) self.assertEqual(self.milestone.creator.login, "jacquev6") - self.assertEqual( - repr(self.milestone), 'Milestone(title="Version 0.4", number=1)' - ) + self.assertEqual(repr(self.milestone), 'Milestone(title="Version 0.4", number=1)') def testEditWithMinimalParameters(self): self.milestone.edit("Title edited by PyGithub") diff --git a/tests/NamedUser.py b/tests/NamedUser.py index ae24dd17..eb0c4e88 100644 --- a/tests/NamedUser.py +++ b/tests/NamedUser.py @@ -196,9 +196,7 @@ class NamedUser(Framework.TestCase): self.assertTrue(self.user.has_in_following(nvie)) def testGetOrgs(self): - self.assertListKeyEqual( - self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"] - ) + self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"]) def testGetOrganizationMembership(self): o = self.user.get_orgs() @@ -215,9 +213,7 @@ class NamedUser(Framework.TestCase): "https://api.github.com/orgs/BeaverSoftware/memberships/jacquev6", ) self.assertEqual(membership.organization.login, "BeaverSoftware") - self.assertEqual( - membership.organization_url, "https://api.github.com/orgs/BeaverSoftware" - ) + self.assertEqual(membership.organization_url, "https://api.github.com/orgs/BeaverSoftware") def testGetOrganizationMembershipNotMember(self): from github import UnknownObjectException diff --git a/tests/Organization.py b/tests/Organization.py index d5a27d6f..c81be1d1 100644 --- a/tests/Organization.py +++ b/tests/Organization.py @@ -47,9 +47,7 @@ class Organization(Framework.TestCase): self.org = self.g.get_organization("BeaverSoftware") def testAttributes(self): - self.assertEqual( - self.org.avatar_url, "https://avatars1.githubusercontent.com/u/1?v=4" - ) + self.assertEqual(self.org.avatar_url, "https://avatars1.githubusercontent.com/u/1?v=4") self.assertEqual(self.org.billing_email, "foo@example.com") self.assertEqual(self.org.blog, "http://www.example.com") self.assertEqual(self.org.collaborators, 9) @@ -67,14 +65,10 @@ class Organization(Framework.TestCase): self.assertEqual(self.org.gravatar_id, None) self.assertTrue(self.org.has_organization_projects) self.assertTrue(self.org.has_repository_projects) - self.assertEqual( - self.org.hooks_url, "https://api.github.com/orgs/BeaverSoftware/hooks" - ) + self.assertEqual(self.org.hooks_url, "https://api.github.com/orgs/BeaverSoftware/hooks") self.assertEqual(self.org.html_url, "https://github.com/BeaverSoftware") self.assertEqual(self.org.id, 1) - self.assertEqual( - self.org.issues_url, "https://api.github.com/orgs/BeaverSoftware/issues" - ) + self.assertEqual(self.org.issues_url, "https://api.github.com/orgs/BeaverSoftware/issues") self.assertEqual(self.org.location, "Paris, France") self.assertEqual(self.org.login, "BeaverSoftware") self.assertFalse(self.org.members_can_create_repositories) @@ -139,12 +133,8 @@ class Organization(Framework.TestCase): self.assertEqual(hook.name, "mobile") def testEditHookWithAllParameters(self): - hook = self.org.create_hook( - "web", {"url": "http://foobar.com"}, ["fork"], False - ) - hook = self.org.edit_hook( - hook.id, "mobile", {"url": "http://barfoo.com"}, ["spoon"], True - ) + hook = self.org.create_hook("web", {"url": "http://foobar.com"}, ["fork"], False) + hook = self.org.edit_hook(hook.id, "mobile", {"url": "http://barfoo.com"}, ["spoon"], True) self.assertEqual(hook.name, "mobile") self.assertEqual(hook.events, ["spoon"]) self.assertEqual(hook.active, True) @@ -178,9 +168,7 @@ class Organization(Framework.TestCase): self.assertFalse(self.org.has_in_public_members(lyloa)) def testGetPublicMembers(self): - self.assertListKeyEqual( - self.org.get_public_members(), lambda u: u.login, ["jacquev6"] - ) + self.assertListKeyEqual(self.org.get_public_members(), lambda u: u.login, ["jacquev6"]) def testGetHook(self): hook = self.org.get_hook(257993) @@ -209,12 +197,8 @@ class Organization(Framework.TestCase): self.assertIsInstance(delivery.request, github.HookDelivery.HookDeliveryRequest) self.assertEqual(delivery.request.headers, {"content-type": "application/json"}) self.assertEqual(delivery.request.payload, {"action": "opened"}) - self.assertIsInstance( - delivery.response, github.HookDelivery.HookDeliveryResponse - ) - self.assertEqual( - delivery.response.headers, {"content-type": "text/html;charset=utf-8"} - ) + self.assertIsInstance(delivery.response, github.HookDelivery.HookDeliveryResponse) + self.assertEqual(delivery.response.headers, {"content-type": "text/html;charset=utf-8"}) self.assertEqual(delivery.response.payload, "ok") def testGetHookDeliveries(self): @@ -240,9 +224,7 @@ class Organization(Framework.TestCase): self.assertListKeyEqual(self.org.get_issues(), lambda i: i.id, []) def testGetIssuesWithAllArguments(self): - requestedByUser = ( - self.g.get_user().get_repo("PyGithub").get_label("Requested by user") - ) + requestedByUser = self.g.get_user().get_repo("PyGithub").get_label("Requested by user") issues = self.org.get_issues( "assigned", "closed", @@ -254,21 +236,15 @@ class Organization(Framework.TestCase): self.assertListKeyEqual(issues, lambda i: i.id, []) def testGetMembers(self): - self.assertListKeyEqual( - self.org.get_members(), lambda u: u.login, ["cjuniet", "jacquev6", "Lyloa"] - ) + self.assertListKeyEqual(self.org.get_members(), lambda u: u.login, ["cjuniet", "jacquev6", "Lyloa"]) def testGetOutsideCollaborators(self): - self.assertListKeyEqual( - self.org.get_outside_collaborators(), lambda u: u.login, ["octocat"] - ) + self.assertListKeyEqual(self.org.get_outside_collaborators(), lambda u: u.login, ["octocat"]) def testOutsideCollaborators(self): octocat = self.g.get_user("octocat") self.org.convert_to_outside_collaborator(octocat) - self.assertListKeyEqual( - self.org.get_outside_collaborators(), lambda u: u.login, ["octocat"] - ) + self.assertListKeyEqual(self.org.get_outside_collaborators(), lambda u: u.login, ["octocat"]) self.org.remove_outside_collaborator(octocat) self.assertEqual(list(self.org.get_outside_collaborators()), []) @@ -280,9 +256,7 @@ class Organization(Framework.TestCase): def testGetRepos(self): repos = self.org.get_repos() - self.assertListKeyEqual( - repos, lambda r: r.name, ["FatherBeaver", "TestPyGithub"] - ) + self.assertListKeyEqual(repos, lambda r: r.name, ["FatherBeaver", "TestPyGithub"]) self.assertListKeyEqual(repos, lambda r: r.has_pages, [True, False]) self.assertListKeyEqual(repos, lambda r: r.has_wiki, [True, True]) @@ -339,9 +313,7 @@ class Organization(Framework.TestCase): ) def testGetTeams(self): - self.assertListKeyEqual( - self.org.get_teams(), lambda t: t.name, ["Members", "Owners"] - ) + self.assertListKeyEqual(self.org.get_teams(), lambda t: t.name, ["Members", "Owners"]) def testGetTeamBySlug(self): team = self.org.get_team_by_slug("Members") @@ -352,17 +324,13 @@ class Organization(Framework.TestCase): self.assertEqual(hook.id, 257967) def testCreateHookWithAllParameters(self): - hook = self.org.create_hook( - "web", {"url": "http://foobar.com"}, ["fork"], False - ) + hook = self.org.create_hook("web", {"url": "http://foobar.com"}, ["fork"], False) self.assertTrue(hook.active) self.assertEqual(hook.id, 257993) def testCreateRepoWithMinimalArguments(self): repo = self.org.create_repo(name="TestPyGithub") - self.assertEqual( - repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub" - ) + self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub") self.assertTrue(repo.has_wiki) self.assertTrue(repo.has_pages) @@ -385,38 +353,28 @@ class Organization(Framework.TestCase): allow_rebase_merge=True, delete_branch_on_merge=False, ) - self.assertEqual( - repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub2" - ) + self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub2") self.assertTrue(repo.allow_update_branch) self.assertFalse(repo.has_wiki) self.assertFalse(repo.has_pages) def testCreateRepositoryWithAutoInit(self): - repo = self.org.create_repo( - name="TestPyGithub", auto_init=True, gitignore_template="Python" - ) - self.assertEqual( - repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub" - ) + repo = self.org.create_repo(name="TestPyGithub", auto_init=True, gitignore_template="Python") + self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub") self.assertTrue(repo.has_pages) self.assertTrue(repo.has_wiki) def testCreateFork(self): pygithub = self.g.get_user("jacquev6").get_repo("PyGithub") repo = self.org.create_fork(pygithub) - self.assertEqual( - repo.url, "https://api.github.com/repos/BeaverSoftware/PyGithub" - ) + self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/PyGithub") self.assertFalse(repo.has_wiki) self.assertFalse(repo.has_pages) def testCreateRepoFromTemplate(self): template_repo = self.g.get_repo("actions/hello-world-docker-action") - repo = self.org.create_repo_from_template( - "hello-world-docker-action-new", template_repo - ) + repo = self.org.create_repo_from_template("hello-world-docker-action-new", template_repo) self.assertEqual( repo.url, "https://api.github.com/repos/BeaverSoftware/hello-world-docker-action-new", @@ -448,9 +406,7 @@ class Organization(Framework.TestCase): # encrypt returns a non-deterministic value, we need to mock it so the replay data matches repos = [self.org.get_repo("TestPyGithub"), self.org.get_repo("FatherBeaver")] encrypt.return_value = "M+5Fm/BqTfB90h3nC7F3BoZuu3nXs+/KtpXwxm9gG211tbRo0F5UiN0OIfYT83CKcx9oKES9Va4E96/b" - self.assertTrue( - self.org.create_secret("secret-name", "secret-value", "selected", repos) - ) + self.assertTrue(self.org.create_secret("secret-name", "secret-value", "selected", repos)) def testDeleteSecret(self): self.assertTrue(self.org.delete_secret("secret-name")) @@ -475,9 +431,7 @@ class Organization(Framework.TestCase): def testInviteUserWithRoleAndTeam(self): team = self.org.create_team("Team created by PyGithub") - self.org.invite_user( - email="foo@example.com", role="billing_manager", teams=[team] - ) + self.org.invite_user(email="foo@example.com", role="billing_manager", teams=[team]) def testInviteUserAsNonOwner(self): with self.assertRaises(github.GithubException) as raisedexp: @@ -493,11 +447,7 @@ class Organization(Framework.TestCase): def testCreateMigration(self): self.org = self.g.get_organization("sample-test-organisation") - self.assertTrue( - isinstance( - self.org.create_migration(["sample-repo"]), github.Migration.Migration - ) - ) + self.assertTrue(isinstance(self.org.create_migration(["sample-repo"]), github.Migration.Migration)) def testGetMigrations(self): self.org = self.g.get_organization("sample-test-organisation") diff --git a/tests/Organization2072.py b/tests/Organization2072.py index 0c42fcfa..14e45f81 100644 --- a/tests/Organization2072.py +++ b/tests/Organization2072.py @@ -29,12 +29,8 @@ class Organization2072(Framework.TestCase): self.org = self.g.get_organization("TestOrganization2072") def testCancelInvitation(self): - self.assertFalse( - any([i for i in self.org.invitations() if i.email == "foo@bar.org"]) - ) + self.assertFalse(any([i for i in self.org.invitations() if i.email == "foo@bar.org"])) self.org.invite_user(email="foo@bar.org") - self.assertTrue( - any([i for i in self.org.invitations() if i.email == "foo@bar.org"]) - ) + self.assertTrue(any([i for i in self.org.invitations() if i.email == "foo@bar.org"])) invitation = [i for i in self.org.invitations() if i.email == "foo@bar.org"][0] self.assertTrue(self.org.cancel_invitation(invitation)) diff --git a/tests/PaginatedList.py b/tests/PaginatedList.py index 9a7bf7f1..e21b377a 100644 --- a/tests/PaginatedList.py +++ b/tests/PaginatedList.py @@ -181,12 +181,8 @@ class PaginatedList(Framework.TestCase): lambda i: i.id, [4772349, 4700182, 4604661, 4554058, 4507492], ) - self.assertListKeyEqual( - self.list[10:13], lambda i: i.id, [4539985, 4507572, 4507492] - ) - self.assertListKeyEqual( - self.list[5:13:3], lambda i: i.id, [4608132, 4557803, 4507572] - ) + self.assertListKeyEqual(self.list[10:13], lambda i: i.id, [4539985, 4507572, 4507492]) + self.assertListKeyEqual(self.list[5:13:3], lambda i: i.id, [4608132, 4557803, 4507572]) def testSliceIndexingUntilFourthPage(self): self.assertListKeyEqual( diff --git a/tests/Project.py b/tests/Project.py index 489e0846..cbdc1cdc 100644 --- a/tests/Project.py +++ b/tests/Project.py @@ -56,22 +56,14 @@ class Project(Framework.TestCase): def testProjectAttributes(self): pid = 1682941 proj = self.g.get_project(pid) - self.assertEqual( - proj.owner_url, "https://api.github.com/repos/bbi-yggy/PyGithub" - ) + self.assertEqual(proj.owner_url, "https://api.github.com/repos/bbi-yggy/PyGithub") self.assertEqual(proj.url, "https://api.github.com/projects/1682941") - self.assertEqual( - proj.html_url, "https://github.com/bbi-yggy/PyGithub/projects/1" - ) - self.assertEqual( - proj.columns_url, "https://api.github.com/projects/1682941/columns" - ) + self.assertEqual(proj.html_url, "https://github.com/bbi-yggy/PyGithub/projects/1") + self.assertEqual(proj.columns_url, "https://api.github.com/projects/1682941/columns") self.assertEqual(proj.id, pid) self.assertEqual(proj.node_id, "MDc6UHJvamVjdDE2ODI5NDE=") self.assertEqual(proj.name, "TestProject") - self.assertEqual( - proj.body, "To be used for testing project access API for PyGithub." - ) + self.assertEqual(proj.body, "To be used for testing project access API for PyGithub.") self.assertEqual(proj.number, 1) self.assertEqual(proj.state, "open") self.assertEqual(proj.creator, self.repo.owner) @@ -87,9 +79,7 @@ class Project(Framework.TestCase): self.assertEqual(col.name, "To Do") self.assertEqual(col.url, "https://api.github.com/projects/columns/3138830") self.assertEqual(col.project_url, "https://api.github.com/projects/1682941") - self.assertEqual( - col.cards_url, "https://api.github.com/projects/columns/3138830/cards" - ) + self.assertEqual(col.cards_url, "https://api.github.com/projects/columns/3138830/cards") self.assertEqual(col.created_at.year, 2018) self.assertTrue(col.updated_at >= col.created_at) self.assertEqual(repr(col), 'ProjectColumn(name="To Do")') @@ -99,15 +89,9 @@ class Project(Framework.TestCase): proj = self.g.get_project(1682941) col = proj.get_columns()[1] card = col.get_cards()[0] - self.assertEqual( - card.url, "https://api.github.com/projects/columns/cards/11780055" - ) - self.assertEqual( - card.column_url, "https://api.github.com/projects/columns/3138831" - ) - self.assertEqual( - card.content_url, "https://api.github.com/repos/bbi-yggy/PyGithub/issues/1" - ) + self.assertEqual(card.url, "https://api.github.com/projects/columns/cards/11780055") + self.assertEqual(card.column_url, "https://api.github.com/projects/columns/3138831") + self.assertEqual(card.content_url, "https://api.github.com/repos/bbi-yggy/PyGithub/issues/1") self.assertEqual(card.id, 11780055) self.assertEqual(card.node_id, "MDExOlByb2plY3RDYXJkMTE3ODAwNTU=") self.assertEqual(card.note, None) # No notes for cards with content. @@ -125,9 +109,7 @@ class Project(Framework.TestCase): pull_card = cards[0] pull = pull_card.get_content("PullRequest") self.assertIsInstance(pull, github.PullRequest.PullRequest) - self.assertEqual( - pull.title, "Work in progress on support for GitHub projects API." - ) + self.assertEqual(pull.title, "Work in progress on support for GitHub projects API.") self.assertRaises(ValueError, pull_card.get_content, "foo") issue_card = cards[1] @@ -166,18 +148,14 @@ class Project(Framework.TestCase): self.assertEqual(cards, expectedCards) def testCreateColumn(self): - project = self.repo.create_project( - "Project created by PyGithub", "Project Body" - ) + project = self.repo.create_project("Project created by PyGithub", "Project Body") column = project.create_column( "Project Column created by PyGithub", ) self.assertEqual(column.id, 3999333) def testCreateCardWithNote(self): - project = self.repo.create_project( - "Project created by PyGithub", "Project Body" - ) + project = self.repo.create_project("Project created by PyGithub", "Project Body") column = project.create_column( "Project Column created by PyGithub", ) @@ -185,9 +163,7 @@ class Project(Framework.TestCase): self.assertEqual(card1.id, 16039019) def testCreateCardFromIssue(self): - project = self.repo.create_project( - "Project created by PyGithub", "Project Body" - ) + project = self.repo.create_project("Project created by PyGithub", "Project Body") column = project.create_column( "Project Column created by PyGithub", ) diff --git a/tests/ProjectColumn.py b/tests/ProjectColumn.py index f3bb0507..3973389a 100644 --- a/tests/ProjectColumn.py +++ b/tests/ProjectColumn.py @@ -36,9 +36,7 @@ class ProjectColumn(Framework.TestCase): self.get_project_column.cards_url, "https://api.github.com/projects/columns/8700460/cards", ) - self.assertEqual( - self.get_project_column.node_id, "MDEzOlByb2plY3RDb2x1bW44NzAwNDYw" - ) + self.assertEqual(self.get_project_column.node_id, "MDEzOlByb2plY3RDb2x1bW44NzAwNDYw") self.assertEqual( self.get_project_column.project_url, "https://api.github.com/projects/4294766", diff --git a/tests/PublicKey.py b/tests/PublicKey.py index 332d0ad4..3362017d 100644 --- a/tests/PublicKey.py +++ b/tests/PublicKey.py @@ -33,9 +33,7 @@ from . import Framework class PublicKey(Framework.TestCase): def testAttributes(self): self.public_key = self.g.get_user().get_repo("PyGithub").get_public_key() - self.assertEqual( - self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=" - ) + self.assertEqual(self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=") self.assertEqual(self.public_key.key_id, "568250167242549743") self.assertEqual( repr(self.public_key), @@ -44,9 +42,7 @@ class PublicKey(Framework.TestCase): def testAttributes_with_int_key_id(self): self.public_key = self.g.get_user().get_repo("PyGithub").get_public_key() - self.assertEqual( - self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=" - ) + self.assertEqual(self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=") self.assertEqual(self.public_key.key_id, 568250167242549743) self.assertEqual( repr(self.public_key), diff --git a/tests/PullRequest.py b/tests/PullRequest.py index 91f9133b..c6c2a909 100644 --- a/tests/PullRequest.py +++ b/tests/PullRequest.py @@ -85,9 +85,7 @@ class PullRequest(Framework.TestCase): self.assertEqual(self.pull.additions, 511) self.assertEqual(self.pull.assignee.login, "jacquev6") self.assertListKeyEqual(self.pull.assignees, lambda a: a.login, ["jacquev6"]) - self.assertEqual( - self.pull.base.label, "PyGithub:topic/RewriteWithGeneratedCode" - ) + self.assertEqual(self.pull.base.label, "PyGithub:topic/RewriteWithGeneratedCode") self.assertEqual(self.pull.base.sha, "ed866fc43833802ab553e5ff8581c81bb00dd433") self.assertEqual(self.pull.base.user.login, "PyGithub") self.assertEqual(self.pull.base.ref, "topic/RewriteWithGeneratedCode") @@ -105,13 +103,9 @@ class PullRequest(Framework.TestCase): datetime(2012, 5, 27, 9, 25, 36, tzinfo=timezone.utc), ) self.assertEqual(self.pull.deletions, 384) - self.assertEqual( - self.pull.diff_url, "https://github.com/PyGithub/PyGithub/pull/31.diff" - ) + self.assertEqual(self.pull.diff_url, "https://github.com/PyGithub/PyGithub/pull/31.diff") self.assertEqual(self.pull.head.ref, "master") - self.assertEqual( - self.pull.html_url, "https://github.com/PyGithub/PyGithub/pull/31" - ) + self.assertEqual(self.pull.html_url, "https://github.com/PyGithub/PyGithub/pull/31") self.assertEqual(self.pull.id, 1436215) self.assertEqual( self.pull.issue_url, @@ -127,9 +121,7 @@ class PullRequest(Framework.TestCase): ) self.assertEqual(self.pull.merged_by.login, "jacquev6") self.assertEqual(self.pull.number, 31) - self.assertEqual( - self.pull.patch_url, "https://github.com/PyGithub/PyGithub/pull/31.patch" - ) + self.assertEqual(self.pull.patch_url, "https://github.com/PyGithub/PyGithub/pull/31.patch") self.assertEqual(self.pull.review_comments, 2) self.assertEqual(self.pull.state, "closed") self.assertEqual(self.pull.title, "Title edited by PyGithub") @@ -137,9 +129,7 @@ class PullRequest(Framework.TestCase): self.pull.updated_at, datetime(2018, 6, 25, 12, 54, 43, tzinfo=timezone.utc), ) - self.assertEqual( - self.pull.url, "https://api.github.com/repos/PyGithub/PyGithub/pulls/31" - ) + self.assertEqual(self.pull.url, "https://api.github.com/repos/PyGithub/PyGithub/pulls/31") self.assertEqual(self.pull.user.login, "jacquev6") self.assertEqual(self.pull.draft, False) self.assertEqual(self.pull.maintainer_can_modify, False) @@ -155,9 +145,7 @@ class PullRequest(Framework.TestCase): def testCreateComment(self): commit = self.repo.get_commit("8a4f306d4b223682dd19410d4a9150636ebe4206") - comment = self.pull.create_comment( - "Comment created by PyGithub", commit, "src/github/Issue.py", 5 - ) + comment = self.pull.create_comment("Comment created by PyGithub", commit, "src/github/Issue.py", 5) self.assertEqual(comment.id, 886298) def testCreateReviewCommentInReplyTo(self): @@ -204,9 +192,7 @@ class PullRequest(Framework.TestCase): as_suggestion=True, ) self.assertEqual(comment.id, 886298) - self.assertEqual( - comment.body, "```suggestion\nComment created by PyGithub\n```" - ) + self.assertEqual(comment.body, "```suggestion\nComment created by PyGithub\n```") def testCreateMultilineReviewCommentChoosingSide(self): commit = self.repo.get_commit("8a4f306d4b223682dd19410d4a9150636ebe4206") @@ -231,9 +217,7 @@ class PullRequest(Framework.TestCase): self.assertEqual(comment.id, 8387331) def testGetIssueComments(self): - self.assertListKeyEqual( - self.pull.get_issue_comments(), lambda c: c.id, [8387331] - ) + self.assertListKeyEqual(self.pull.get_issue_comments(), lambda c: c.id, [8387331]) def testGetIssueComment(self): comment = self.pull.get_issue_comment(8387331) @@ -248,26 +232,18 @@ class PullRequest(Framework.TestCase): def testGetReviewComments(self): epoch = datetime(1970, 1, 1, 0, 0) - comments = self.pull.get_review_comments( - sort="updated", direction="desc", since=epoch - ) + comments = self.pull.get_review_comments(sort="updated", direction="desc", since=epoch) self.assertListKeyEqual(comments, lambda c: c.id, [197784357, 1580134]) def testReviewRequests(self): - self.pull.create_review_request( - reviewers="sfdye", team_reviewers="pygithub-owners" - ) + self.pull.create_review_request(reviewers="sfdye", team_reviewers="pygithub-owners") review_requests = self.pull.get_review_requests() self.assertListKeyEqual(review_requests[0], lambda c: c.login, ["sfdye"]) - self.assertListKeyEqual( - review_requests[1], lambda c: c.slug, ["pygithub-owners"] - ) + self.assertListKeyEqual(review_requests[1], lambda c: c.slug, ["pygithub-owners"]) self.pull.delete_review_request(reviewers="sfdye") review_requests = self.pull.get_review_requests() self.assertEqual(list(review_requests[0]), []) - self.assertListKeyEqual( - review_requests[1], lambda c: c.slug, ["pygithub-owners"] - ) + self.assertListKeyEqual(review_requests[1], lambda c: c.slug, ["pygithub-owners"]) def testEditWithoutArguments(self): self.pull.edit() @@ -351,9 +327,7 @@ class PullRequest(Framework.TestCase): ) def testGetLabels(self): - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) def testAddAndRemoveLabels(self): wip = self.repo.get_label("wip") @@ -364,13 +338,9 @@ class PullRequest(Framework.TestCase): ["wip", "refactoring", "improvement"], ) self.pull.remove_from_labels(wip) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"]) self.pull.remove_from_labels(refactoring) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["improvement"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["improvement"]) self.pull.add_to_labels(wip, refactoring) self.assertListKeyEqual( self.pull.get_labels(), @@ -387,13 +357,9 @@ class PullRequest(Framework.TestCase): ["wip", "refactoring", "improvement"], ) self.pull.remove_from_labels(wip) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"]) self.pull.remove_from_labels(refactoring) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["improvement"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["improvement"]) self.pull.add_to_labels(wip, refactoring) self.assertListKeyEqual( self.pull.get_labels(), @@ -412,9 +378,7 @@ class PullRequest(Framework.TestCase): self.pull.delete_labels() self.assertListKeyEqual(self.pull.get_labels(), None, []) self.pull.set_labels(wip, refactoring) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) def testDeleteAndSetLabelsWithStringArguments(self): wip = "wip" @@ -427,9 +391,7 @@ class PullRequest(Framework.TestCase): self.pull.delete_labels() self.assertListKeyEqual(self.pull.get_labels(), None, []) self.pull.set_labels(wip, refactoring) - self.assertListKeyEqual( - self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"] - ) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) def testMerge(self): self.assertFalse(self.pull.is_merged()) @@ -459,13 +421,9 @@ class PullRequest(Framework.TestCase): ) self.assertEqual(self.pull.url, url) self.pull.remove_from_assignees(user1, user2) - self.assertListKeyEqual( - self.pull.assignees, lambda a: a.login, ["jacquev6", "stuglaser"] - ) + self.assertListKeyEqual(self.pull.assignees, lambda a: a.login, ["jacquev6", "stuglaser"]) self.assertEqual(self.pull.url, url) def testUpdateBranch(self): - self.assertTrue( - self.pull.update_branch("addaebea821105cf6600441f05ff2b413ab21a36") - ) + self.assertTrue(self.pull.update_branch("addaebea821105cf6600441f05ff2b413ab21a36")) self.assertTrue(self.pull.update_branch()) diff --git a/tests/PullRequest1168.py b/tests/PullRequest1168.py index 35705005..dad95810 100644 --- a/tests/PullRequest1168.py +++ b/tests/PullRequest1168.py @@ -26,9 +26,7 @@ from . import Framework class PullRequest1168(Framework.TestCase): def setUp(self): super().setUp() - self.notifications = self.g.get_repo("PyGithub/PyGithub").get_notifications( - all=True - ) + self.notifications = self.g.get_repo("PyGithub/PyGithub").get_notifications(all=True) def testGetPullRequest(self): p = self.notifications[0].get_pull_request() diff --git a/tests/PullRequest1375.py b/tests/PullRequest1375.py index 21a69836..9afc3262 100644 --- a/tests/PullRequest1375.py +++ b/tests/PullRequest1375.py @@ -34,9 +34,7 @@ class PullRequest1375(Framework.TestCase): second_reply_body = "Second comment reply created by PyGithub" first_reply = self.pr.create_review_comment_reply(comment_id, first_reply_body) - second_reply = self.pr.create_review_comment_reply( - first_reply.id, second_reply_body - ) + second_reply = self.pr.create_review_comment_reply(first_reply.id, second_reply_body) # ensure both first and second reply have `in_reply_to_id` attr set to top comment self.assertEqual(first_reply.in_reply_to_id, comment_id) diff --git a/tests/PullRequest2408.py b/tests/PullRequest2408.py index b90fa72c..c57d1703 100644 --- a/tests/PullRequest2408.py +++ b/tests/PullRequest2408.py @@ -29,9 +29,7 @@ class PullRequest2408(Framework.TestCase): self.repo = self.g.get_repo("ReDASers/Phishing-Detection") def test_get_workflow_runs(self): - runs = self.repo.get_workflow_runs( - head_sha="7aab33f4294ba5141f17bed0aeb1a929f7afc155" - ) + runs = self.repo.get_workflow_runs(head_sha="7aab33f4294ba5141f17bed0aeb1a929f7afc155") self.assertEqual(720994709, runs[0].id) runs = self.repo.get_workflow_runs(exclude_pull_requests=True) diff --git a/tests/PullRequestComment.py b/tests/PullRequestComment.py index 98a6dcbb..3165784a 100644 --- a/tests/PullRequestComment.py +++ b/tests/PullRequestComment.py @@ -36,23 +36,17 @@ from . import Framework class PullRequestComment(Framework.TestCase): def setUp(self): super().setUp() - self.comment = ( - self.g.get_user().get_repo("PyGithub").get_pull(31).get_comment(886298) - ) + self.comment = self.g.get_user().get_repo("PyGithub").get_pull(31).get_comment(886298) def testAttributes(self): self.assertEqual(self.comment.body, "Comment created by PyGithub") - self.assertEqual( - self.comment.commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" - ) + self.assertEqual(self.comment.commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206") self.assertEqual( self.comment.created_at, datetime(2012, 5, 27, 9, 40, 12, tzinfo=timezone.utc), ) self.assertEqual(self.comment.id, 886298) - self.assertEqual( - self.comment.original_commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" - ) + self.assertEqual(self.comment.original_commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206") self.assertEqual(self.comment.original_position, 5) self.assertEqual(self.comment.path, "src/github/Issue.py") self.assertEqual(self.comment.position, 5) diff --git a/tests/PullRequestReview.py b/tests/PullRequestReview.py index 30bbf3d6..7f7c469f 100644 --- a/tests/PullRequestReview.py +++ b/tests/PullRequestReview.py @@ -60,9 +60,7 @@ class PullRequestReview(Framework.TestCase): self.assertEqual(self.pullreview.id, 28482091) self.assertEqual(self.pullreview.user.login, "jzelinskie") self.assertEqual(self.pullreview.body, "") - self.assertEqual( - self.pullreview.commit_id, "7a0fcb27b7cd6c346fc3f76216ccb6e0f4ca3bcc" - ) + self.assertEqual(self.pullreview.commit_id, "7a0fcb27b7cd6c346fc3f76216ccb6e0f4ca3bcc") self.assertEqual(self.pullreview.state, "APPROVED") self.assertEqual( self.pullreview.html_url, diff --git a/tests/RateLimiting.py b/tests/RateLimiting.py index 96feda3e..2eb65244 100644 --- a/tests/RateLimiting.py +++ b/tests/RateLimiting.py @@ -55,6 +55,4 @@ class RateLimiting(Framework.TestCase): self.assertEqual(rateLimit.core.limit, 5000) self.assertEqual(rateLimit.core.remaining, 4904) self.assertEqual(rateLimit.core.used, 96) - self.assertEqual( - rateLimit.core.reset, datetime(2023, 5, 15, 23, 57, 21, tzinfo=timezone.utc) - ) + self.assertEqual(rateLimit.core.reset, datetime(2023, 5, 15, 23, 57, 21, tzinfo=timezone.utc)) diff --git a/tests/RawData.py b/tests/RawData.py index 963231b1..f961d8c4 100644 --- a/tests/RawData.py +++ b/tests/RawData.py @@ -95,8 +95,6 @@ class RawData(Framework.TestCase): self.assertEqual(plan.raw_data, RawData.planRawData) def testCreateObjectFromRawData(self): - user = self.g.create_from_raw_data( - github.NamedUser.NamedUser, RawData.jacquev6RawData - ) + user = self.g.create_from_raw_data(github.NamedUser.NamedUser, RawData.jacquev6RawData) self.assertEqual(user._CompletableGithubObject__completed, True) self.assertEqual(user.name, "Vincent Jacques") diff --git a/tests/Reaction.py b/tests/Reaction.py index 70811221..85bb81d5 100644 --- a/tests/Reaction.py +++ b/tests/Reaction.py @@ -29,12 +29,7 @@ from . import Framework class Reaction(Framework.TestCase): def setUp(self): super().setUp() - self.reactions = ( - self.g.get_user("PyGithub") - .get_repo("PyGithub") - .get_issue(28) - .get_reactions() - ) + self.reactions = self.g.get_user("PyGithub").get_repo("PyGithub").get_issue(28).get_reactions() def testAttributes(self): self.assertEqual(self.reactions[0].content, "+1") diff --git a/tests/Repository.py b/tests/Repository.py index 0b2cc9e1..37caac22 100644 --- a/tests/Repository.py +++ b/tests/Repository.py @@ -62,16 +62,12 @@ class Repository(Framework.TestCase): self.repo = self.user.get_repo("PyGithub") def testAttributes(self): - self.assertEqual( - self.repo.clone_url, "https://github.com/jacquev6/PyGithub.git" - ) + self.assertEqual(self.repo.clone_url, "https://github.com/jacquev6/PyGithub.git") self.assertEqual( self.repo.created_at, datetime(2012, 2, 25, 12, 53, 47, tzinfo=timezone.utc), ) - self.assertEqual( - self.repo.description, "Python library implementing the full Github API v3" - ) + self.assertEqual(self.repo.description, "Python library implementing the full Github API v3") self.assertFalse(self.repo.fork) self.assertEqual(self.repo.forks, 3) self.assertEqual(self.repo.full_name, "jacquev6/PyGithub") @@ -115,9 +111,7 @@ class Repository(Framework.TestCase): self.repo.updated_at, datetime(2012, 5, 27, 6, 55, 28, tzinfo=timezone.utc), ) - self.assertEqual( - self.repo.url, "https://api.github.com/repos/jacquev6/PyGithub" - ) + self.assertEqual(self.repo.url, "https://api.github.com/repos/jacquev6/PyGithub") self.assertEqual(self.repo.watchers, 15) self.assertEqual(repr(self.repo), 'Repository(full_name="jacquev6/PyGithub")') self.assertTrue(self.repo.permissions.admin) @@ -150,9 +144,7 @@ class Repository(Framework.TestCase): ) self.assertEqual(self.repo.description, "Description edited by PyGithub") self.repo.edit("PyGithub", "Python library implementing the full Github API v3") - self.assertEqual( - self.repo.description, "Python library implementing the full Github API v3" - ) + self.assertEqual(self.repo.description, "Python library implementing the full Github API v3") self.assertFalse(self.repo.archived) self.assertTrue(self.repo.allow_update_branch) self.assertTrue(self.repo.has_issues) @@ -254,9 +246,7 @@ class Repository(Framework.TestCase): self.assertEqual(hook.id, 257967) def testCreateHookWithAllParameters(self): - hook = self.repo.create_hook( - "web", {"url": "http://foobar.com"}, ["fork"], False - ) + hook = self.repo.create_hook("web", {"url": "http://foobar.com"}, ["fork"], False) self.assertTrue(hook.active) # WTF self.assertEqual(hook.id, 257993) @@ -271,9 +261,7 @@ class Repository(Framework.TestCase): ) def testCreateAutolink(self): - key = self.repo.create_autolink( - "DUMMY-", "https://github.com/PyGithub/PyGithub/issues/" - ) + key = self.repo.create_autolink("DUMMY-", "https://github.com/PyGithub/PyGithub/issues/") self.assertEqual(key.id, 209614) def testCreateGitBlob(self): @@ -282,18 +270,12 @@ class Repository(Framework.TestCase): def testCreateGitTree(self): tree = self.repo.create_git_tree( - [ - github.InputGitTreeElement( - "Foobar.txt", "100644", "blob", content="File created by PyGithub" - ) - ] + [github.InputGitTreeElement("Foobar.txt", "100644", "blob", content="File created by PyGithub")] ) self.assertEqual(tree.sha, "41cf8c178c636a018d537cb20daae09391efd70b") def testCreateGitTreeWithBaseTree(self): - base_tree = self.repo.get_git_tree( - "41cf8c178c636a018d537cb20daae09391efd70b", recursive=False - ) + base_tree = self.repo.get_git_tree("41cf8c178c636a018d537cb20daae09391efd70b", recursive=False) tree = self.repo.create_git_tree( [ github.InputGitTreeElement( @@ -344,9 +326,7 @@ class Repository(Framework.TestCase): self.repo.get_git_commit("12d427464f8d91c8e981043a86ba8a2a9e7319ea"), ] tree = self.repo.get_git_tree("fae707821159639589bf94f3fb0a7154ec5d441b") - commit = self.repo.create_git_commit( - "Commit created by PyGithub", tree, parents - ) + commit = self.repo.create_git_commit("Commit created by PyGithub", tree, parents) self.assertEqual(commit.sha, "6adf9ea25ff8a8f2a42bcb1c09e42526339037cd") def testCreateGitCommitWithAllArguments(self): @@ -355,12 +335,8 @@ class Repository(Framework.TestCase): "Commit created by PyGithub", tree, [], - github.InputGitAuthor( - "John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00" - ), - github.InputGitAuthor( - "John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00" - ), + github.InputGitAuthor("John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00"), + github.InputGitAuthor("John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00"), ) self.assertEqual(commit.sha, "526946197ae9da59c6507cacd13ad6f1cfb686ea") @@ -391,11 +367,7 @@ class Repository(Framework.TestCase): self.assertEqual(release.body, "This release is also created by PyGithub") self.assertEqual(release.draft, False) self.assertEqual(release.prerelease, True) - tag = [ - tag - for tag in self.repo.get_tags() - if tag.name == "vX.Y.Z-by-PyGithub-acctest2" - ].pop() + tag = [tag for tag in self.repo.get_tags() if tag.name == "vX.Y.Z-by-PyGithub-acctest2"].pop() self.assertEqual(tag.commit.sha, "da9a285fd8b782461e56cba39ae8d2fa41ca7cdc") def testCreateGitTag(self): @@ -413,9 +385,7 @@ class Repository(Framework.TestCase): "Tag also created by PyGithub", "526946197ae9da59c6507cacd13ad6f1cfb686ea", "commit", - github.InputGitAuthor( - "John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00" - ), + github.InputGitAuthor("John Doe", "j.doe@vincent-jacques.net", "2008-07-09T16:13:30+12:00"), ) self.assertEqual(tag.sha, "f0e99a8335fbc84c53366c4a681118468f266625") @@ -428,9 +398,7 @@ class Repository(Framework.TestCase): def testCreateSourceImport(self): import_repo = self.g.get_user("brix4dayz").get_repo("source-import-test") - source_import = import_repo.create_source_import( - "mercurial", "https://bitbucket.org/hfuss/source-import-test" - ) + source_import = import_repo.create_source_import("mercurial", "https://bitbucket.org/hfuss/source-import-test") self.assertEqual(source_import.authors_count, 0) self.assertEqual( source_import.authors_url, @@ -451,9 +419,7 @@ class Repository(Framework.TestCase): "https://api.github.com/repos/brix4dayz/source-import-test/import", ) self.assertEqual(source_import.vcs, "mercurial") - self.assertEqual( - source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test" - ) + self.assertEqual(source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") def testCreateRepositoryDispatch(self): with_payload = self.repo.create_repository_dispatch("type", {"foo": "bar"}) @@ -506,9 +472,7 @@ class Repository(Framework.TestCase): ")", ) self.assertEqual(instance.ref, "refs/heads/master") - self.assertEqual( - instance.analysis_key, ".github/workflows/codeql-analysis.yml:analyze" - ) + self.assertEqual(instance.analysis_key, ".github/workflows/codeql-analysis.yml:analyze") self.assertEqual(instance.environment, "{language:python}") self.assertEqual(instance.state, "open") self.assertListEqual(instance.classifications, ["stupid typo"]) @@ -527,26 +491,20 @@ class Repository(Framework.TestCase): "end_line=10, end_column=48" ")", ) - self.assertEqual( - location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt" - ) + self.assertEqual(location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt") self.assertEqual(location.start_line, 10) self.assertEqual(location.start_column, 2) self.assertEqual(location.end_line, 10) self.assertEqual(location.end_column, 48) rule = codescan_alert.rule - self.assertEqual( - repr(rule), 'CodeScanRule(name="py/rule-name", id="py/rule-id")' - ) + self.assertEqual(repr(rule), 'CodeScanRule(name="py/rule-name", id="py/rule-id")') self.assertEqual(rule.id, "py/rule-id") self.assertEqual(rule.name, "py/rule-name") self.assertEqual(rule.security_severity_level, "high") self.assertEqual(rule.severity, "warning") self.assertEqual(rule.description, "Bad practice") tool = codescan_alert.tool - self.assertEqual( - repr(tool), 'CodeScanTool(version="2.5.7", name="CodeQL", guid=None)' - ) + self.assertEqual(repr(tool), 'CodeScanTool(version="2.5.7", name="CodeQL", guid=None)') self.assertEqual(tool.guid, None) self.assertEqual(tool.name, "CodeQL") self.assertEqual(tool.version, "2.5.7") @@ -562,9 +520,7 @@ class Repository(Framework.TestCase): self.assertDictEqual(instance.message, {"text": "instances[0].message"}) self.assertEqual(instance.commit_sha, "instances[0].commit_sha") location = instance.location - self.assertEqual( - location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt" - ) + self.assertEqual(location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt") self.assertEqual(location.start_line, 10) self.assertEqual(location.start_column, 2) self.assertEqual(location.end_line, 10) @@ -579,9 +535,7 @@ class Repository(Framework.TestCase): self.assertDictEqual(instance.message, {"text": "instances[1].message"}) self.assertEqual(instance.commit_sha, "instances[1].commit_sha") location = instance.location - self.assertEqual( - location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt" - ) + self.assertEqual(location.path, "tests/ReplayData/Repository.testCodeScanAlerts.txt") self.assertEqual(location.start_line, 20) self.assertEqual(location.start_column, 17) self.assertEqual(location.end_line, 20) @@ -665,9 +619,7 @@ class Repository(Framework.TestCase): "setup.py", ], ) - self.assertEqual( - comparison.base_commit.sha, "4303c5b90e2216d927155e9609436ccb8984c495" - ) + self.assertEqual(comparison.base_commit.sha, "4303c5b90e2216d927155e9609436ccb8984c495") self.assertListKeyEqual( comparison.commits, lambda c: c.sha, @@ -774,9 +726,7 @@ class Repository(Framework.TestCase): def testGetCommitsWithArguments(self): self.assertListKeyEqual( - self.repo.get_commits( - "topic/RewriteWithGeneratedCode", "codegen/GenerateCode.py" - ), + self.repo.get_commits("topic/RewriteWithGeneratedCode", "codegen/GenerateCode.py"), lambda c: c.sha, [ "de386d5dc9cf103c90c4128eeca0e6abdd382065", @@ -884,14 +834,10 @@ class Repository(Framework.TestCase): ) def testGetForks(self): - self.assertListKeyEqual( - self.repo.get_forks(), lambda r: r.owner.login, ["abersager"] - ) + self.assertListKeyEqual(self.repo.get_forks(), lambda r: r.owner.login, ["abersager"]) def testCreateFork(self): - self.assertEqual( - self.repo.create_fork("prtg-dev").full_name, "prtg-dev/PyGithub" - ) + self.assertEqual(self.repo.create_fork("prtg-dev").full_name, "prtg-dev/PyGithub") def testCreateForkOrg(self): c = self.g.get_organization("prtg-dev") @@ -961,12 +907,8 @@ class Repository(Framework.TestCase): self.assertIsInstance(delivery.request, github.HookDelivery.HookDeliveryRequest) self.assertEqual(delivery.request.headers, {"content-type": "application/json"}) self.assertEqual(delivery.request.payload, {"action": "opened"}) - self.assertIsInstance( - delivery.response, github.HookDelivery.HookDeliveryResponse - ) - self.assertEqual( - delivery.response.headers, {"content-type": "text/html;charset=utf-8"} - ) + self.assertIsInstance(delivery.response, github.HookDelivery.HookDeliveryResponse) + self.assertEqual(delivery.response.headers, {"content-type": "text/html;charset=utf-8"}) self.assertEqual(delivery.response.payload, "ok") def testGetHookDeliveries(self): @@ -1022,12 +964,8 @@ class Repository(Framework.TestCase): lambda i: i.id, [3624472, 3620132, 3619658, 3561926], ) - self.assertListKeyEqual( - self.repo.get_issues(labels=[bug]), lambda i: i.id, [4780155] - ) - self.assertListKeyEqual( - self.repo.get_issues(labels=[bug.name]), lambda i: i.id, [4780155] - ) + self.assertListKeyEqual(self.repo.get_issues(labels=[bug]), lambda i: i.id, [4780155]) + self.assertListKeyEqual(self.repo.get_issues(labels=[bug.name]), lambda i: i.id, [4780155]) self.assertListKeyEqual( self.repo.get_issues(assignee=user, sort="comments", direction="asc"), lambda i: i.id, @@ -1049,15 +987,11 @@ class Repository(Framework.TestCase): ], ) self.assertListKeyEqual( - self.repo.get_issues( - since=datetime(2012, 5, 28, 23, 0, 0, tzinfo=timezone.utc) - ), + self.repo.get_issues(since=datetime(2012, 5, 28, 23, 0, 0, tzinfo=timezone.utc)), lambda i: i.id, [4793216, 4793162, 4793106, 3624556, 3619973, 3527266], ) - self.assertListKeyEqual( - self.repo.get_issues(mentioned=otherUser), lambda i: i.id, [4793162] - ) + self.assertListKeyEqual(self.repo.get_issues(mentioned=otherUser), lambda i: i.id, [4793162]) def testGetIssuesWithWildcards(self): self.assertListKeyEqual( @@ -1089,14 +1023,10 @@ class Repository(Framework.TestCase): 3527231, ], ) - self.assertListKeyEqual( - self.repo.get_issues(assignee="none"), lambda i: i.id, [3619973] - ) + self.assertListKeyEqual(self.repo.get_issues(assignee="none"), lambda i: i.id, [3619973]) def testGetKeys(self): - self.assertListKeyEqual( - self.repo.get_keys(), lambda k: k.title, ["Key added through PyGithub"] - ) + self.assertListKeyEqual(self.repo.get_keys(), lambda k: k.title, ["Key added through PyGithub"]) def testGetLabels(self): self.assertListKeyEqual( @@ -1174,9 +1104,7 @@ class Repository(Framework.TestCase): def testGetWorkflows(self): workflows = self.g.get_repo("PyGithub/PyGithub").get_workflows() - self.assertListKeyEqual( - workflows, lambda w: w.name, ["check", "Publish to PyPI"] - ) + self.assertListKeyEqual(workflows, lambda w: w.name, ["check", "Publish to PyPI"]) def testGetWorkflowRuns(self): self.assertListKeyEqual( @@ -1212,9 +1140,7 @@ class Repository(Framework.TestCase): ) self.assertEqual(source_import.use_lfs, "undecided") self.assertEqual(source_import.vcs, "mercurial") - self.assertEqual( - source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test" - ) + self.assertEqual(source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") def testGetStargazers(self): self.assertListKeyEqual( @@ -1356,25 +1282,19 @@ class Repository(Framework.TestCase): self.assertEqual(pull.id, 1436215) def testCreateProject(self): - project = self.repo.create_project( - "Project created by PyGithub", "Body of the project" - ) + project = self.repo.create_project("Project created by PyGithub", "Body of the project") self.assertEqual(project.id, 2013820) def testCreatePullFromIssue(self): issue = self.repo.get_issue(32) - pull = self.repo.create_pull( - issue, "topic/RewriteWithGeneratedCode", "BeaverSoftware:master" - ) + pull = self.repo.create_pull(issue, "topic/RewriteWithGeneratedCode", "BeaverSoftware:master") self.assertEqual(pull.id, 1436310) def testGetPulls(self): self.assertListKeyEqual(self.repo.get_pulls(), lambda p: p.id, [1436310]) def testGetPullsWithArguments(self): - self.assertListKeyEqual( - self.repo.get_pulls("closed"), lambda p: p.id, [1448168, 1436310, 1436215] - ) + self.assertListKeyEqual(self.repo.get_pulls("closed"), lambda p: p.id, [1448168, 1436310, 1436215]) def testGetAutolinks(self): self.assertListKeyEqual( @@ -1405,9 +1325,7 @@ class Repository(Framework.TestCase): ) self.assertEqual(issues[0].user.login, "kukuts") self.assertEqual(issues[0].user.url, "/users/kukuts") - self.assertListKeyEqual( - issues[0].labels, lambda l: l.name, ["Functionalities", "RequestedByUser"] - ) + self.assertListKeyEqual(issues[0].labels, lambda l: l.name, ["Functionalities", "RequestedByUser"]) self.assertEqual(issues[0].state, "open") def testMarkNotificationsAsRead(self): @@ -1421,17 +1339,13 @@ class Repository(Framework.TestCase): self.assertFalse(self.repo.has_in_assignees(lyloa)) self.repo.add_to_collaborators(lyloa) self.assertTrue(self.repo.has_in_assignees(lyloa)) - self.assertListKeyEqual( - self.repo.get_assignees(), lambda u: u.login, ["jacquev6", "Lyloa"] - ) + self.assertListKeyEqual(self.repo.get_assignees(), lambda u: u.login, ["jacquev6", "Lyloa"]) self.repo.remove_from_collaborators(lyloa) self.assertFalse(self.repo.has_in_assignees(lyloa)) def testGetContents(self): self.assertEqual(len(self.repo.get_readme().content), 10212) - self.assertEqual( - len(self.repo.get_contents("doc/ReferenceOfClasses.md").content), 38121 - ) + self.assertEqual(len(self.repo.get_contents("doc/ReferenceOfClasses.md").content), 38121) def testGetContentsDir(self): contents = self.repo.get_contents("") @@ -1445,11 +1359,7 @@ class Repository(Framework.TestCase): def testGetContentsWithRef(self): self.assertEqual( - len( - self.repo.get_readme( - ref="refs/heads/topic/ExperimentOnDocumentation" - ).content - ), + len(self.repo.get_readme(ref="refs/heads/topic/ExperimentOnDocumentation").content), 6747, ) self.assertEqual( @@ -1483,9 +1393,7 @@ class Repository(Framework.TestCase): def testCreateFile(self): newFile = "doc/testCreateUpdateDeleteFile.md" content = b"Hello world" - author = github.InputGitAuthor( - "Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00" - ) + author = github.InputGitAuthor("Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00") self.assertEqual(repr(author), 'InputGitAuthor(name="Enix Yu")') self.repo.create_file( path=newFile, @@ -1506,12 +1414,8 @@ class Repository(Framework.TestCase): content=content, sha=sha, branch="master", - committer=github.InputGitAuthor( - "Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00" - ), - author=github.InputGitAuthor( - "Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00" - ), + committer=github.InputGitAuthor("Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00"), + author=github.InputGitAuthor("Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00"), ) def testDeleteFile(self): @@ -1555,20 +1459,14 @@ class Repository(Framework.TestCase): def testMergeWithoutMessage(self): commit = self.repo.merge("branchForBase", "branchForHead") - self.assertEqual( - commit.commit.message, "Merge branchForHead into branchForBase" - ) + self.assertEqual(commit.commit.message, "Merge branchForHead into branchForBase") def testMergeWithMessage(self): - commit = self.repo.merge( - "branchForBase", "branchForHead", "Commit message created by PyGithub" - ) + commit = self.repo.merge("branchForBase", "branchForHead", "Commit message created by PyGithub") self.assertEqual(commit.commit.message, "Commit message created by PyGithub") def testMergeWithNothingToDo(self): - commit = self.repo.merge( - "branchForBase", "branchForHead", "Commit message created by PyGithub" - ) + commit = self.repo.merge("branchForBase", "branchForHead", "Commit message created by PyGithub") self.assertEqual(commit, None) def testMergeWithConflict(self): @@ -1718,9 +1616,7 @@ class Repository(Framework.TestCase): ) def testGetPullsComments(self): - self.assertListKeyEqual( - self.repo.get_pulls_comments(), lambda c: c.id, [1580134] - ) + self.assertListKeyEqual(self.repo.get_pulls_comments(), lambda c: c.id, [1580134]) self.assertListKeyEqual( self.repo.get_pulls_comments(sort="created", direction="asc"), lambda c: c.id, @@ -1737,13 +1633,9 @@ class Repository(Framework.TestCase): def testBadSubscribePubSubHubbub(self): with self.assertRaises(github.GithubException) as raisedexp: - self.repo.subscribe_to_hub( - "non-existing-event", "http://requestb.in/1bc1sc61" - ) + self.repo.subscribe_to_hub("non-existing-event", "http://requestb.in/1bc1sc61") self.assertEqual(raisedexp.exception.status, 422) - self.assertEqual( - raisedexp.exception.data, {"message": 'Invalid event: "non-existing-event"'} - ) + self.assertEqual(raisedexp.exception.data, {"message": 'Invalid event: "non-existing-event"'}) def testUnsubscribePubSubHubbub(self): self.repo.unsubscribe_from_hub("push", "http://requestb.in/1bc1sc61") diff --git a/tests/RepositoryAdvisory.py b/tests/RepositoryAdvisory.py index faad095a..7bf03574 100644 --- a/tests/RepositoryAdvisory.py +++ b/tests/RepositoryAdvisory.py @@ -44,9 +44,7 @@ class RepositoryAdvisory(Framework.TestCase): self.advisory.created_at, datetime(2023, 3, 28, 21, 41, 40, tzinfo=timezone.utc), ) - self.assertListKeyEqual( - self.advisory.credits, lambda e: (e.login, e.type), [("octocat", "analyst")] - ) + self.assertListKeyEqual(self.advisory.credits, lambda e: (e.login, e.type), [("octocat", "analyst")]) self.assertListKeyEqual( self.advisory.credits_detailed, lambda e: (e.user.login, e.type), diff --git a/tests/RepositoryKey.py b/tests/RepositoryKey.py index 65799217..8cc7323f 100644 --- a/tests/RepositoryKey.py +++ b/tests/RepositoryKey.py @@ -48,18 +48,14 @@ class RepositoryKey(Framework.TestCase): "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLOoLSVPwG1OSgVSeEXNbfIofYdxR5zs3u4PryhnamfFPYwi2vZW3ZxeI1oRcDh2VEdwGvlN5VUduKJNoOWMVzV2jSyR8CeDHH+I0soQCC7kfJVodU96HcPMzZ6MuVwSfD4BFGvKMXyCnBUqzo28BGHFwVQG8Ya9gL6/cTbuWywgM4xaJgMHv1OVcESXBtBkrqOneTJuOgeEmP0RfUnIAK/3/wbg9mfiBq7JV4cmWAg1xNE8GJoAbci59Tdx1dQgVuuqdQGk5jzNusOVneyMtGEB+p7UpPLJsGBW29rsMt7ITUbXM/kl9v11vPtWb+oOUThoFsDYmsWy7fGGP9YAFB", ) self.assertEqual(self.key.title, "PyGithub Test Key") - self.assertEqual( - self.key.url, "https://api.github.com/repos/lra/mackup/keys/21870881" - ) + self.assertEqual(self.key.url, "https://api.github.com/repos/lra/mackup/keys/21870881") self.assertEqual( self.key.created_at, datetime(2017, 2, 22, 8, 16, 23, tzinfo=timezone.utc), ) self.assertTrue(self.key.verified) self.assertTrue(self.key.read_only) - self.assertEqual( - repr(self.key), 'RepositoryKey(title="PyGithub Test Key", id=21870881)' - ) + self.assertEqual(repr(self.key), 'RepositoryKey(title="PyGithub Test Key", id=21870881)') def testDelete(self): self.key.delete() diff --git a/tests/Requester.py b/tests/Requester.py index 5c1b0576..6c6dda6f 100644 --- a/tests/Requester.py +++ b/tests/Requester.py @@ -63,9 +63,7 @@ class Requester(Framework.TestCase): kwargs = requester.kwargs # assert kwargs consists of ALL constructor arguments - self.assertEqual( - kwargs.keys(), github.Requester.Requester.__init__.__annotations__.keys() - ) + self.assertEqual(kwargs.keys(), github.Requester.Requester.__init__.__annotations__.keys()) self.assertEqual( kwargs, dict( @@ -201,33 +199,21 @@ class Requester(Framework.TestCase): def testIsRateLimitError(self): for message in self.PrimaryRateLimitErrors + self.SecondaryRateLimitErrors: - self.assertTrue( - github.Requester.Requester.isRateLimitError(message), message - ) + self.assertTrue(github.Requester.Requester.isRateLimitError(message), message) for message in self.OtherErrors: - self.assertFalse( - github.Requester.Requester.isRateLimitError(message), message - ) + self.assertFalse(github.Requester.Requester.isRateLimitError(message), message) def testIsPrimaryRateLimitError(self): for message in self.PrimaryRateLimitErrors: - self.assertTrue( - github.Requester.Requester.isPrimaryRateLimitError(message), message - ) + self.assertTrue(github.Requester.Requester.isPrimaryRateLimitError(message), message) for message in self.OtherErrors + self.SecondaryRateLimitErrors: - self.assertFalse( - github.Requester.Requester.isPrimaryRateLimitError(message), message - ) + self.assertFalse(github.Requester.Requester.isPrimaryRateLimitError(message), message) def testIsSecondaryRateLimitError(self): for message in self.SecondaryRateLimitErrors: - self.assertTrue( - github.Requester.Requester.isSecondaryRateLimitError(message), message - ) + self.assertTrue(github.Requester.Requester.isSecondaryRateLimitError(message), message) for message in self.OtherErrors + self.PrimaryRateLimitErrors: - self.assertFalse( - github.Requester.Requester.isSecondaryRateLimitError(message), message - ) + self.assertFalse(github.Requester.Requester.isSecondaryRateLimitError(message), message) def assertException(self, exception, exception_type, status, data, headers, string): self.assertIsInstance(exception, exception_type) @@ -240,9 +226,7 @@ class Requester(Framework.TestCase): self.assertEqual(str(exception), string) def testShouldCreateBadCredentialsException(self): - exc = self.g._Github__requester.createException( - 401, {"header": "value"}, {"message": "Bad credentials"} - ) + exc = self.g._Github__requester.createException(401, {"header": "value"}, {"message": "Bad credentials"}) self.assertException( exc, github.BadCredentialsException, @@ -291,9 +275,7 @@ class Requester(Framework.TestCase): def testShouldCreateRateLimitExceededException(self): for message in self.PrimaryRateLimitErrors + self.SecondaryRateLimitErrors: with self.subTest(message=message): - exc = self.g._Github__requester.createException( - 403, {"header": "value"}, {"message": message} - ) + exc = self.g._Github__requester.createException(403, {"header": "value"}, {"message": message}) self.assertException( exc, github.RateLimitExceededException, @@ -304,9 +286,7 @@ class Requester(Framework.TestCase): ) def testShouldCreateUnknownObjectException(self): - exc = self.g._Github__requester.createException( - 404, {"header": "value"}, {"message": "Not Found"} - ) + exc = self.g._Github__requester.createException(404, {"header": "value"}, {"message": "Not Found"}) self.assertException( exc, github.UnknownObjectException, @@ -335,17 +315,13 @@ class Requester(Framework.TestCase): for status in range(400, 600): with self.subTest(status=status): exc = self.g._Github__requester.createException(status, {}, {}) - self.assertException( - exc, github.GithubException, status, {}, {}, f"{status} {{}}" - ) + self.assertException(exc, github.GithubException, status, {}, {}, f"{status} {{}}") def testShouldCreateExceptionWithoutOutput(self): for status in range(400, 600): with self.subTest(status=status): exc = self.g._Github__requester.createException(status, {}, None) - self.assertException( - exc, github.GithubException, status, None, {}, f"{status}" - ) + self.assertException(exc, github.GithubException, status, None, {}, f"{status}") class RequesterThrottleTestCase(Framework.TestCase): @@ -361,9 +337,9 @@ class RequesterThrottleTestCase(Framework.TestCase): @contextlib.contextmanager def mock_sleep(self): - with mock.patch( - "github.Requester.time.sleep", side_effect=self.sleep - ) as sleep_mock, mock.patch("github.Requester.datetime") as datetime_mock: + with mock.patch("github.Requester.time.sleep", side_effect=self.sleep) as sleep_mock, mock.patch( + "github.Requester.datetime" + ) as datetime_mock: datetime_mock.now = self.now yield sleep_mock @@ -390,9 +366,7 @@ class RequesterThrottled(RequesterThrottleTestCase): releases = [release for release in repository.get_releases()] self.assertEqual(len(releases), 30) - self.assertEqual( - sleep_mock.call_args_list, [mock.call(1), mock.call(1), mock.call(1)] - ) + self.assertEqual(sleep_mock.call_args_list, [mock.call(1), mock.call(1), mock.call(1)]) def testShouldDeferWrites(self): with self.mock_sleep() as sleep_mock: diff --git a/tests/RequiredPullRequestReviews.py b/tests/RequiredPullRequestReviews.py index f1c3d2d0..e6f67dfb 100644 --- a/tests/RequiredPullRequestReviews.py +++ b/tests/RequiredPullRequestReviews.py @@ -27,18 +27,13 @@ class RequiredPullRequestReviews(Framework.TestCase): def setUp(self): super().setUp() self.required_pull_request_reviews = ( - self.g.get_user() - .get_repo("PyGithub") - .get_branch("integrations") - .get_required_pull_request_reviews() + self.g.get_user().get_repo("PyGithub").get_branch("integrations").get_required_pull_request_reviews() ) def testAttributes(self): self.assertTrue(self.required_pull_request_reviews.dismiss_stale_reviews) self.assertTrue(self.required_pull_request_reviews.require_code_owner_reviews) - self.assertEqual( - self.required_pull_request_reviews.required_approving_review_count, 3 - ) + self.assertEqual(self.required_pull_request_reviews.required_approving_review_count, 3) self.assertEqual( self.required_pull_request_reviews.url, "https://api.github.com/repos/jacquev6/PyGithub/branches/integrations/protection/required_pull_request_reviews", diff --git a/tests/RequiredStatusChecks.py b/tests/RequiredStatusChecks.py index 882c57c5..87eb308d 100644 --- a/tests/RequiredStatusChecks.py +++ b/tests/RequiredStatusChecks.py @@ -27,10 +27,7 @@ class RequiredStatusChecks(Framework.TestCase): def setUp(self): super().setUp() self.required_status_checks = ( - self.g.get_user() - .get_repo("PyGithub") - .get_branch("integrations") - .get_required_status_checks() + self.g.get_user().get_repo("PyGithub").get_branch("integrations").get_required_status_checks() ) def testAttributes(self): diff --git a/tests/Retry.py b/tests/Retry.py index 45cedee7..8f6ab4b9 100644 --- a/tests/Retry.py +++ b/tests/Retry.py @@ -39,9 +39,7 @@ class Retry(Framework.TestCase): def setUp(self): # status codes returned on random github server errors status_forcelist = (500, 502, 504) - retry = urllib3.Retry( - total=3, read=3, connect=3, status_forcelist=status_forcelist - ) + retry = urllib3.Retry(total=3, read=3, connect=3, status_forcelist=status_forcelist) Framework.enableRetry(retry) super().setUp() diff --git a/tests/Search.py b/tests/Search.py index aa6c2b2a..d50d8aab 100644 --- a/tests/Search.py +++ b/tests/Search.py @@ -119,9 +119,7 @@ class Search(Framework.TestCase): ) def testSearchRepos(self): - repos = self.g.search_repositories( - "github", sort="stars", order="desc", language="Python" - ) + repos = self.g.search_repositories("github", sort="stars", order="desc", language="Python") self.assertListKeyBegin( repos, lambda r: r.full_name, @@ -169,9 +167,7 @@ class Search(Framework.TestCase): self.assertEqual(repos.totalCount, 0) def testSearchIssues(self): - issues = self.g.search_issues( - "compile", sort="comments", order="desc", language="C++" - ) + issues = self.g.search_issues("compile", sort="comments", order="desc", language="C++") self.assertListKeyBegin( issues, lambda i: i.id, @@ -190,9 +186,7 @@ class Search(Framework.TestCase): ) def testPaginateSearchCommits(self): - commits = self.g.search_commits( - query="hash:5b0224e868cc9242c9450ef02efbe3097abd7ba2" - ) + commits = self.g.search_commits(query="hash:5b0224e868cc9242c9450ef02efbe3097abd7ba2") self.assertEqual(commits.totalCount, 3) def testSearchCommits(self): @@ -245,21 +239,15 @@ class Search(Framework.TestCase): self.assertEqual(content[:30], "https\nGET\napi.github.com\nNone\n") def testSearchHighlightingCode(self): - files = self.g.search_code( - "toto", sort="indexed", order="asc", user="jacquev6", highlight=True - ) + files = self.g.search_code("toto", sort="indexed", order="asc", user="jacquev6", highlight=True) self.assertTrue(files[0].text_matches) def testUrlquotingOfQualifiers(self): # Example taken from #236 - issues = self.g.search_issues( - "repo:saltstack/salt-api type:Issues", updated=">2014-03-04T18:28:11Z" - ) + issues = self.g.search_issues("repo:saltstack/salt-api type:Issues", updated=">2014-03-04T18:28:11Z") self.assertEqual(issues[0].id, 29138794) def testUrlquotingOfQuery(self): # Example taken from #236 - issues = self.g.search_issues( - "repo:saltstack/salt-api type:Issues updated:>2014-03-04T18:28:11Z" - ) + issues = self.g.search_issues("repo:saltstack/salt-api type:Issues updated:>2014-03-04T18:28:11Z") self.assertEqual(issues[0].id, 29138794) diff --git a/tests/SourceImport.py b/tests/SourceImport.py index 4d97ac97..8334315f 100644 --- a/tests/SourceImport.py +++ b/tests/SourceImport.py @@ -55,9 +55,7 @@ class SourceImport(Framework.TestCase): ) self.assertEqual(self.source_import.use_lfs, "undecided") self.assertEqual(self.source_import.vcs, "mercurial") - self.assertEqual( - self.source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test" - ) + self.assertEqual(self.source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") self.assertEqual( self.source_import.__repr__(), diff --git a/tests/Tag.py b/tests/Tag.py index 270e2d88..4b85f138 100644 --- a/tests/Tag.py +++ b/tests/Tag.py @@ -35,16 +35,10 @@ class Tag(Framework.TestCase): self.tag = self.g.get_user().get_repo("PyGithub").get_tags()[0] def testAttributes(self): - self.assertEqual( - self.tag.commit.sha, "636e6112deb72277b3bffcc3303cd7e8a7431a5d" - ) + self.assertEqual(self.tag.commit.sha, "636e6112deb72277b3bffcc3303cd7e8a7431a5d") self.assertEqual(self.tag.name, "v0.3") - self.assertEqual( - self.tag.tarball_url, "https://github.com/jacquev6/PyGithub/tarball/v0.3" - ) - self.assertEqual( - self.tag.zipball_url, "https://github.com/jacquev6/PyGithub/zipball/v0.3" - ) + self.assertEqual(self.tag.tarball_url, "https://github.com/jacquev6/PyGithub/tarball/v0.3") + self.assertEqual(self.tag.zipball_url, "https://github.com/jacquev6/PyGithub/zipball/v0.3") self.assertEqual( repr(self.tag), 'Tag(name="v0.3", commit=Commit(sha="636e6112deb72277b3bffcc3303cd7e8a7431a5d"))', diff --git a/tests/Team.py b/tests/Team.py index 37e764bb..cabcf14a 100644 --- a/tests/Team.py +++ b/tests/Team.py @@ -55,12 +55,8 @@ class Team(Framework.TestCase): self.assertEqual(self.team.organization, self.org) self.assertEqual(self.team.privacy, "closed") self.assertEqual(self.team.parent, None) - self.assertEqual( - repr(self.team), 'Team(name="Team created by PyGithub", id=189850)' - ) - self.assertEqual( - self.team.html_url, "https://github.com/orgs/BeaverSoftware/teams/core" - ) + self.assertEqual(repr(self.team), 'Team(name="Team created by PyGithub", id=189850)') + self.assertEqual(self.team.html_url, "https://github.com/orgs/BeaverSoftware/teams/core") def testDiscussions(self): discussions = list(self.team.get_discussions()) @@ -72,12 +68,8 @@ class Team(Framework.TestCase): self.assertEqual(d.body_html, "

BODY

") self.assertEqual(d.body_version, "bedf0740b01d2d758cff9873c2387817") self.assertEqual(d.comments_count, 0) - self.assertEqual( - d.comments_url, "https://api.github.com/teams/189850/discussions/1/comments" - ) - self.assertEqual( - d.created_at, datetime(2019, 10, 8, 21, 3, 36, tzinfo=timezone.utc) - ) + self.assertEqual(d.comments_url, "https://api.github.com/teams/189850/discussions/1/comments") + self.assertEqual(d.created_at, datetime(2019, 10, 8, 21, 3, 36, tzinfo=timezone.utc)) self.assertEqual( d.html_url, "https://github.com/orgs/BeaverSoftware/teams/Team/discussions/1", @@ -89,9 +81,7 @@ class Team(Framework.TestCase): self.assertEqual(d.private, False) self.assertEqual(d.team_url, "https://api.github.com/teams/189850") self.assertEqual(d.title, "TITLE") - self.assertEqual( - d.updated_at, datetime(2019, 10, 8, 21, 3, 36, tzinfo=timezone.utc) - ) + self.assertEqual(d.updated_at, datetime(2019, 10, 8, 21, 3, 36, tzinfo=timezone.utc)) self.assertEqual(d.url, "https://api.github.com/teams/189850/discussions/1") self.assertEqual(repr(d), 'TeamDiscussion(title="TITLE", number=1)') @@ -100,9 +90,7 @@ class Team(Framework.TestCase): self.assertListKeyEqual(self.team.get_members(), None, []) self.assertFalse(self.team.has_in_members(user)) self.team.add_to_members(user) - self.assertListKeyEqual( - self.team.get_members(), lambda u: u.login, ["jacquev6"] - ) + self.assertListKeyEqual(self.team.get_members(), lambda u: u.login, ["jacquev6"]) self.assertTrue(self.team.has_in_members(user)) self.team.remove_from_members(user) self.assertListKeyEqual(self.team.get_members(), None, []) @@ -116,9 +104,7 @@ class Team(Framework.TestCase): self.assertEqual(list(self.team.get_members()), []) self.assertFalse(self.team.has_in_members(user)) self.team.add_membership(user) - self.assertListKeyEqual( - self.team.get_members(), lambda u: u.login, ["jacquev6"] - ) + self.assertListKeyEqual(self.team.get_members(), lambda u: u.login, ["jacquev6"]) self.assertTrue(self.team.has_in_members(user)) membership_data = self.team.get_team_membership(user) self.assertEqual(membership_data.user.login, "jacquev6") @@ -142,9 +128,7 @@ class Team(Framework.TestCase): self.assertFalse(self.team.has_in_repos(repo)) self.assertIsNone(self.team.get_repo_permission(repo)) self.team.add_to_repos(repo) - self.assertListKeyEqual( - self.team.get_repos(), lambda r: r.name, ["FatherBeaver"] - ) + self.assertListKeyEqual(self.team.get_repos(), lambda r: r.name, ["FatherBeaver"]) self.assertTrue(self.team.has_in_repos(repo)) permissions = self.team.get_repo_permission(repo) self.assertTrue(permissions.pull) @@ -170,9 +154,7 @@ class Team(Framework.TestCase): def testGetTeams(self): nested_teams = self.team.get_teams() - self.assertListKeyEqual( - nested_teams, lambda t: t.name, ["DummyTeam1", "DummyTeam2", "DummyTeam3"] - ) + self.assertListKeyEqual(nested_teams, lambda t: t.name, ["DummyTeam1", "DummyTeam2", "DummyTeam3"]) parent = nested_teams[0].parent self.assertEqual(self.team.name, parent.name) self.assertEqual(self.team.id, parent.id) diff --git a/tests/Topic.py b/tests/Topic.py index ddc8d448..95ba47ac 100644 --- a/tests/Topic.py +++ b/tests/Topic.py @@ -47,12 +47,8 @@ class Topic(Framework.TestCase): ) self.assertEqual(topic.created_by, "Guido van Rossum") self.assertEqual(topic.released, "February 20, 1991") - self.assertEqual( - topic.created_at, datetime(2016, 12, 7, 0, 7, 2, tzinfo=timezone.utc) - ) - self.assertEqual( - topic.updated_at, datetime(2019, 10, 9, 20, 33, 49, tzinfo=timezone.utc) - ) + self.assertEqual(topic.created_at, datetime(2016, 12, 7, 0, 7, 2, tzinfo=timezone.utc)) + self.assertEqual(topic.updated_at, datetime(2019, 10, 9, 20, 33, 49, tzinfo=timezone.utc)) self.assertEqual(topic.featured, True) self.assertEqual(topic.curated, True) self.assertEqual(topic.score, 7576.306) diff --git a/tests/Workflow.py b/tests/Workflow.py index 4c1ce352..91d55064 100644 --- a/tests/Workflow.py +++ b/tests/Workflow.py @@ -66,9 +66,7 @@ class Workflow(Framework.TestCase): sfdye = self.g.get_user("sfdye") master = self.g.get_repo("PyGithub/PyGithub").get_branch("master") self.assertListKeyEqual( - self.workflow.get_runs( - actor=sfdye, branch=master, event="push", status="completed" - ), + self.workflow.get_runs(actor=sfdye, branch=master, event="push", status="completed"), lambda r: r.id, [100957683, 94845611, 93946842, 92714488], ) @@ -89,28 +87,20 @@ class Workflow(Framework.TestCase): def testCreateDispatchWithBranch(self): dispatch_inputs = {"logLevel": "Warning", "message": "Log Message"} - workflow = self.g.get_repo("wrecker/PyGithub").get_workflow( - "manual_dispatch.yml" - ) - branch = self.g.get_repo("wrecker/PyGithub").get_branch( - "workflow_dispatch_branch" - ) + workflow = self.g.get_repo("wrecker/PyGithub").get_workflow("manual_dispatch.yml") + branch = self.g.get_repo("wrecker/PyGithub").get_branch("workflow_dispatch_branch") self.assertTrue(workflow.create_dispatch(branch, dispatch_inputs)) def testCreateDispatchWithTag(self): dispatch_inputs = {"logLevel": "Warning", "message": "Log Message"} - workflow = self.g.get_repo("wrecker/PyGithub").get_workflow( - "manual_dispatch.yml" - ) + workflow = self.g.get_repo("wrecker/PyGithub").get_workflow("manual_dispatch.yml") tags = self.g.get_repo("wrecker/PyGithub").get_tags() tag = [t for t in tags if t.name == "workflow_dispatch_tag"].pop() self.assertTrue(workflow.create_dispatch(tag, dispatch_inputs)) def testCreateDispatchWithString(self): dispatch_inputs = {"logLevel": "Warning", "message": "Log Message"} - workflow = self.g.get_repo("wrecker/PyGithub").get_workflow( - "manual_dispatch.yml" - ) + workflow = self.g.get_repo("wrecker/PyGithub").get_workflow("manual_dispatch.yml") ref_str = "main" self.assertTrue(workflow.create_dispatch(ref_str, dispatch_inputs)) diff --git a/tests/WorkflowRun.py b/tests/WorkflowRun.py index e00ecb68..b75cdc0f 100644 --- a/tests/WorkflowRun.py +++ b/tests/WorkflowRun.py @@ -39,9 +39,7 @@ class WorkflowRun(Framework.TestCase): self.assertEqual(self.workflow_run.id, 3881497935) self.assertEqual(self.workflow_run.name, "CI") self.assertEqual(self.workflow_run.head_branch, "feat/workflow-run") - self.assertEqual( - self.workflow_run.head_sha, "c6e5cac67a58a4eb11f1f28567a77a6e2cc8ee98" - ) + self.assertEqual(self.workflow_run.head_sha, "c6e5cac67a58a4eb11f1f28567a77a6e2cc8ee98") self.assertEqual(self.workflow_run.path, ".github/workflows/ci.yml") self.assertEqual(self.workflow_run.display_title, "TEST PR") self.assertEqual(self.workflow_run.run_number, 930) @@ -95,9 +93,7 @@ class WorkflowRun(Framework.TestCase): self.workflow_run.workflow_url, "https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1903133", ) - self.assertEqual( - self.workflow_run.head_commit.message, "add attribute 'name' on WorkflowRun" - ) + self.assertEqual(self.workflow_run.head_commit.message, "add attribute 'name' on WorkflowRun") self.assertEqual(self.workflow_run.repository.name, "PyGithub") self.assertEqual(self.workflow_run.head_repository.name, "PyGithub") diff --git a/tests/conftest.py b/tests/conftest.py index 2d5c77f3..e240b8e8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,9 +25,7 @@ from . import Framework def pytest_addoption(parser): parser.addoption("--record", action="store_true", help="record mode") - parser.addoption( - "--auth_with_token", action="store_true", help="auth using a token" - ) + parser.addoption("--auth_with_token", action="store_true", help="auth using a token") parser.addoption("--auth_with_jwt", action="store_true", help="auth using JWT") diff --git a/tox.ini b/tox.ini index 11268c86..1e6c0489 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,7 @@ deps = -rrequirements.txt commands = sphinx-build doc build [flake8] -max-line-length = 88 +max-line-length = 120 select = C,E,F,W ignore = E266, E501, W503