pygithub
Advanced tools
| ############################ Copyrights and license ############################ | ||
| # # | ||
| # Copyright 2024 Enrico Minack <github@enrico.minack.dev> # | ||
| # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # | ||
| # Copyright 2024 Thomas Cooper <coopernetes@proton.me> # | ||
| # Copyright 2025 Enrico Minack <github@enrico.minack.dev> # | ||
| # # | ||
| # This file is part of PyGithub. # | ||
| # http://pygithub.readthedocs.io/ # | ||
| # # | ||
| # PyGithub is free software: you can redistribute it and/or modify it under # | ||
| # the terms of the GNU Lesser General Public License as published by the Free # | ||
| # Software Foundation, either version 3 of the License, or (at your option) # | ||
| # any later version. # | ||
| # # | ||
| # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | ||
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | ||
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | ||
| # details. # | ||
| # # | ||
| # You should have received a copy of the GNU Lesser General Public License # | ||
| # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | ||
| # # | ||
| ################################################################################ | ||
| from __future__ import annotations | ||
| from typing import TYPE_CHECKING, Any | ||
| import github.Repository | ||
| from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet | ||
| if TYPE_CHECKING: | ||
| from github.Repository import Repository | ||
| class CodeSecurityConfigRepository(NonCompletableGithubObject): | ||
| """ | ||
| This class represents CodeSecurityConfigRepository. | ||
| The reference can be found here | ||
| https://docs.github.com/en/rest/code-security/configurations | ||
| The OpenAPI schema can be found at | ||
| - /components/schemas/code-security-configuration-repositories | ||
| """ | ||
| def _initAttributes(self) -> None: | ||
| self._repository: Attribute[Repository] = NotSet | ||
| self._status: Attribute[str] = NotSet | ||
| def __repr__(self) -> str: | ||
| return self.repository.__repr__() | ||
| @property | ||
| def repository(self) -> Repository: | ||
| return self._repository.value | ||
| @property | ||
| def status(self) -> str: | ||
| return self._status.value | ||
| def _useAttributes(self, attributes: dict[str, Any]) -> None: | ||
| if "repository" in attributes: # pragma no branch | ||
| self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) | ||
| if "status" in attributes: # pragma no branch | ||
| self._status = self._makeStringAttribute(attributes["status"]) |
+14
-8
@@ -189,2 +189,15 @@ ############################ Copyrights and license ############################ | ||
| class JwtSigner: | ||
| def __init__(self, private_key_or_func: Union[str, PrivateKeyGenerator], jwt_algorithm: str): | ||
| self._private_key_or_func = private_key_or_func | ||
| self._jwt_algorithm = jwt_algorithm | ||
| def jwt_sign(self, payload: dict) -> Union[str, bytes]: | ||
| if callable(self._private_key_or_func): | ||
| private_key = self._private_key_or_func() | ||
| else: | ||
| private_key = self._private_key_or_func | ||
| return jwt.encode(payload, key=private_key, algorithm=self._jwt_algorithm) | ||
| class AppAuth(JWT): | ||
@@ -200,11 +213,4 @@ """ | ||
| def create_jwt_sign(private_key_or_func: Union[str, PrivateKeyGenerator], jwt_algorithm: str) -> DictSignFunction: | ||
| def jwt_sign(payload: dict) -> Union[str, bytes]: | ||
| if callable(private_key_or_func): | ||
| private_key = private_key_or_func() | ||
| else: | ||
| private_key = private_key_or_func | ||
| return jwt.encode(payload, key=private_key, algorithm=jwt_algorithm) | ||
| return JwtSigner(private_key_or_func, jwt_algorithm).jwt_sign | ||
| return jwt_sign | ||
| # v3: move * above private_key | ||
@@ -211,0 +217,0 @@ def __init__( |
@@ -37,3 +37,3 @@ ############################ Copyrights and license ############################ | ||
| from typing_extensions import deprecated | ||
| import deprecated | ||
@@ -113,3 +113,3 @@ import github.CheckRunAnnotation | ||
| @property | ||
| @deprecated("Use property check_suite.id instead") | ||
| @deprecated.deprecated("Use property check_suite.id instead") | ||
| def check_suite_id(self) -> int: | ||
@@ -116,0 +116,0 @@ self._completeIfNotSet(self._check_suite_id) |
@@ -73,3 +73,2 @@ ############################ Copyrights and license ############################ | ||
| - /components/schemas/deployment-simple | ||
| - /paths/"/repos/{owner}/{repo}/deployments"/post/responses/202/content/"application/json"/schema | ||
@@ -84,3 +83,2 @@ """ | ||
| self._id: Attribute[int] = NotSet | ||
| self._message: Attribute[str] = NotSet | ||
| self._node_id: Attribute[str] = NotSet | ||
@@ -129,7 +127,2 @@ self._original_environment: Attribute[str] = NotSet | ||
| @property | ||
| def message(self) -> str: | ||
| self._completeIfNotSet(self._message) | ||
| return self._message.value | ||
| @property | ||
| def node_id(self) -> str: | ||
@@ -281,4 +274,2 @@ self._completeIfNotSet(self._node_id) | ||
| self._id = self._makeIntAttribute(attributes["id"]) | ||
| if "message" in attributes: # pragma no branch | ||
| self._message = self._makeStringAttribute(attributes["message"]) | ||
| if "node_id" in attributes: # pragma no branch | ||
@@ -285,0 +276,0 @@ self._node_id = self._makeStringAttribute(attributes["node_id"]) |
+7
-3
@@ -46,2 +46,3 @@ ############################ Copyrights and license ############################ | ||
| import github.GitAuthor | ||
| import github.GitCommitVerification | ||
| import github.GithubObject | ||
@@ -54,2 +55,3 @@ import github.GitObject | ||
| from github.GitAuthor import GitAuthor | ||
| from github.GitCommitVerification import GitCommitVerification | ||
| from github.GitObject import GitObject | ||
@@ -78,3 +80,3 @@ | ||
| self._url: Attribute[str] = NotSet | ||
| self._verification: Attribute[dict[str, Any]] = NotSet | ||
| self._verification: Attribute[GitCommitVerification] = NotSet | ||
@@ -120,3 +122,3 @@ def __repr__(self) -> str: | ||
| @property | ||
| def verification(self) -> dict[str, Any]: | ||
| def verification(self) -> GitCommitVerification: | ||
| self._completeIfNotSet(self._verification) | ||
@@ -141,2 +143,4 @@ return self._verification.value | ||
| if "verification" in attributes: # pragma no branch | ||
| self._verification = self._makeDictAttribute(attributes["verification"]) | ||
| self._verification = self._makeClassAttribute( | ||
| github.GitCommitVerification.GitCommitVerification, attributes["verification"] | ||
| ) |
+1
-1
| Metadata-Version: 2.2 | ||
| Name: PyGithub | ||
| Version: 2.6.0 | ||
| Version: 2.6.1 | ||
| Summary: Use the full Github API v3 | ||
@@ -5,0 +5,0 @@ Author-email: Vincent Jacques <vincent@vincent-jacques.net> |
| Metadata-Version: 2.2 | ||
| Name: PyGithub | ||
| Version: 2.6.0 | ||
| Version: 2.6.1 | ||
| Summary: Use the full Github API v3 | ||
@@ -5,0 +5,0 @@ Author-email: Vincent Jacques <vincent@vincent-jacques.net> |
@@ -78,2 +78,3 @@ .git-blame-ignore-revs | ||
| github/CodeSecurityConfig.py | ||
| github/CodeSecurityConfigRepository.py | ||
| github/Commit.py | ||
@@ -80,0 +81,0 @@ github/CommitCombinedStatus.py |
@@ -56,3 +56,2 @@ ############################ Copyrights and license ############################ | ||
| self.assertEqual(self.deployment.id, 263877258) | ||
| self.assertIsNone(self.deployment.message) | ||
| self.assertEqual(self.deployment.node_id, "MDEwOkRlcGxveW1lbnQyNjIzNTE3NzY=") | ||
@@ -59,0 +58,0 @@ self.assertEqual(self.deployment.original_environment, "test") |
@@ -5,2 +5,3 @@ ############################ Copyrights and license ############################ | ||
| # Copyright 2023 Enrico Minack <github@enrico.minack.dev> # | ||
| # Copyright 2025 Enrico Minack <github@enrico.minack.dev> # | ||
| # Copyright 2025 Tim Gates <tim.gates@iress.com> # | ||
@@ -7,0 +8,0 @@ # # |
+1
-4
@@ -68,5 +68,2 @@ ############################ Copyrights and license ############################ | ||
| self.assertEqual(repr(self.tag), 'GitTag(tag="v0.6", sha="f5f37322407b02a80de4526ad88d5f188977bc3c")') | ||
| self.assertEqual( | ||
| self.tag.verification, | ||
| {"verified": False, "reason": "unsigned", "signature": None, "payload": None, "verified_at": None}, | ||
| ) | ||
| self.assertEqual(self.tag.verification.reason, "unsigned") |
+31
-0
@@ -27,5 +27,9 @@ ############################ Copyrights and license ############################ | ||
| import inspect | ||
| import pickle | ||
| import sys | ||
| from abc import ABC | ||
| import github | ||
| from github.Auth import AppAuth, AppAuthToken, AppInstallationAuth, AppUserAuth, Auth, Login, NetrcAuth, Token | ||
| from github.PaginatedList import PaginatedList | ||
@@ -63,1 +67,28 @@ from github.Repository import Repository | ||
| self.assertIsInstance(branches2, PaginatedList) | ||
| auths = [ | ||
| Login("login", "password"), | ||
| Token("token"), | ||
| AppAuth("id", "key"), | ||
| AppAuthToken("token"), | ||
| AppInstallationAuth(AppAuth("id", "key"), 123), | ||
| AppUserAuth("client_id", "client_secret", "access_token"), | ||
| NetrcAuth(), | ||
| ] | ||
| def testPickleAuthSetup(self): | ||
| # check we are testing *all* exiting auth classes | ||
| auth_module = sys.modules[github.Auth.__name__] | ||
| existing_auths = [ | ||
| clazz_type.__name__ | ||
| for clazz, clazz_type in inspect.getmembers(auth_module, inspect.isclass) | ||
| if Auth in clazz_type.mro() and ABC not in clazz_type.__bases__ | ||
| ] | ||
| tested_auths = [type(auth).__name__ for auth in self.auths] | ||
| self.assertSequenceEqual(sorted(existing_auths), sorted(tested_auths)) | ||
| def testPickleAuth(self): | ||
| for auth in self.auths: | ||
| with self.subTest(auth=type(auth).__name__): | ||
| auth2 = pickle.loads(pickle.dumps(auth)) | ||
| self.assertIsInstance(auth2, type(auth)) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
31277759
0.02%1295
0.08%54801
0.15%