Releases: PyGithub/PyGithub
v2.3.0
New features
- Support oauth for enterprise @EnricoMi (#2780)
- Support creation of Dependabot Organization and Repository Secrets @thomascrowley (#2874)
Improvements
- Create release with optional
name
andmessage
whengenerate_release_notes
is true @heitorpolidoro (#2868) - Add missing attributes to
WorkflowJob
@xvega (#2921) - Add
created
andcheck_suite_id
filter for Repository Workflow runs @treee111 (#2891) - Assert requester argument type in Auth @EnricoMi (#2912)
Bug Fixes
- Revert having allowed values for
add_to_collaborators
@jodelasur (#2905)
Maintenance
- Fix imports in authentication docs @wurstbrot (#2923)
- CI: add docformatter to precommit @Borda (#2614)
- Add
.swp
fils to.gitignore
@boomanaiden154 (#2903) - Fix instructions building docs in
CONTRIBUTING.md
@wakamex (#2900) - Explicitly name the modules built in
pyproject.toml
@treee111 (#2894)
v2.2.0
Breaking Changes
The github.Comparison.Comparison
instance returned by Repository.compare
provides a commits
property that used to return a list[github.Commit.Commit]
, which has now been changed to PaginatedList[github.Commit.Commit]
. This breaks user code that assumes a list
:
commits = repo.compare("v0.6", "v0.7").commits
no_of_commits = len(commits) # will raise a TypeError
This will raise a TypeError: object of type 'PaginatedList' has no len()
, as the returned PaginatedList
does not support the len()
method. Use the totalCount
property instead:
commits = repo.compare("v0.6", "v0.7").commits
no_of_commits = commits.totalCount
New features
- Add support to call GraphQL API
Improvements
- Add parent_team_id, maintainers and notification_setting for creating and updating teams. by @Cheshirez in #2863
- Add support for issue reactions summary by @smuzaffar in #2866
- Support for DependabotAlert APIs by @coopernetes in #2879
- Derive GraphQL URL from base_url by @EnricoMi in #2880
- Make
Repository.compare().commits
return paginated list by @EnricoMi in #2882 - Add missing branch protection fields by @treee111 in #2873
- Add
include_all_branches
tocreate_repo_from_template
ofAuthenticatedUser
andOrganization
by @janssonoskar in #2871 - Add and update organisation dependabot secrets by @mohy01 in #2316
- Add missing params to
Organization.create_repo
by @tekumara in #2700 - Update allowed values for
Repository
collaborator permissions by @flying-sheep in #1996 - Support editing PullRequestReview by @ColasGael in #2851
- Update attributes after calling
PullRequestReview.dismiss
by @ColasGael in #2854 - Add
request_cve
onRepositoryAdvisories
by @JLLeitschuh in #2855 - Filter collaborators of a repository by permissions by @notmicaelfilipe in #2792
- Set pull request to auto merge via GraphQL API by @heitorpolidoro in #2816
- Support Environment Variables and Secrets by @AndrewJDawes in #2848
- Update workflow.get_runs & pullrequest.add_to_assignees function signature by @sd-kialo in #2799
- Add
GithubObject.last_modified_datetime
to havelast_modified
as adatetime
by @chouetz in #2772 - Add support for global advisories and unify some shared logic with repository advisories by @crimsonknave in #2702
- Add
internal
as valid Repository visibility value by @AndrewJDawes in #2806 - Add support for issue comments reactions summary by @smuzaffar in #2813
Bug Fixes
- Add a bunch of missing urllib.parse.quote calls by @ExplodingCabbage in #1976
- Fix Variable and Secret url bugs by @AndrewJDawes in #2835
Maintenance
- Update the class name for NetrcAuth in the examples by @vinnybod in #2860
- Move build to PEP517 by @trim21 in #2800
- Use new type assert functions in
Repository
by @trim21 in #2798 - PyTest: Move config to pyproject.toml by @Borda in #2859
- codespell: ignore-words-list by @Borda in #2858
- Improve fix-headers.py script by @EnricoMi in #2728
- Remove dependency on python-dateutil by @lazka in #2804
- CI: update precommit & apply by @Borda in #2600
- Docs: Fix parameter order according to Version 2.1.0 by @nad182 in #2786
- Add missing GitHub classes to docs by @EnricoMi in #2783
- CI: Fix mypy error by ignoring override by @EnricoMi in #2779
Full Changelog: v2.1.1...v2.2.0
v2.1.1
v2.1.0.post0
Important
Request throttling
This release introduces a default throttling mechanism to mitigate secondary rate limit errors and comply with Github's best practices:
https://docs.github.com/en/rest/guides/best-practices-for-integrators?apiVersion=2022-11-28#dealing-with-secondary-rate-limits
The default throttling of 1 second between writes and 0.25 second between any requests can be configured
for github.Github
and github.GithubIntegration
:
g = github.Github(seconds_between_requests=0.25, seconds_between_writes=1)
Set these parameters to None
to disable throttling and restore earlier behavior.
Request retry
This release introduces a default retry mechanism to retry retry-able 403 responses (primary and secondary rate limit errors only) and any 5xx response.
Class github.GithubRetry
implements this behavior, and can be configured via the retry
argument of github.Github
and github.GithubIntegration
.
Retry behavior is configured similar to urllib3.Retry
: https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html
g = github.Github(retry=github.GithubRetry())
Set this parameter to None
to disable retry mechanism and restore earlier behaviour.
Breaking Changes
Timestamps
Any timestamps returned by this library are datetime
with timezone information, usually UTC.
Before this release, timestamps used to be naive datetime
instances without timezone.
Comparing (other than ==
) these timestamps with naive datetime
instances used to work but will now break.
Add a timezone information to your datetime
instances before comparison:
if g.get_repo("PyGithub/PyGithub").created_at < datetime(2012, 2, 26, tzinfo=timezone.utc):
...
Netrc authentication
A Netrc file (e.g. ~/.netrc
) does not override PyGithub authentication, anymore.
If you require authentication through Netrc, then this is a breaking change.
Use a github.Auth.NetrcAuth
instance to use Netrc credentials:
>>> auth = Auth.NetrcAuth()
>>> g = Github(auth=auth)
>>> g.get_user().login
'login'
Repository.create_pull
Merged overloaded create_pull
methods
def create_pull(self, issue, base, head)
def create_pull(self, title, body, base, head, maintainer_can_modify=NotSet, draft=False)
into
def create_pull(self, base, head, *, title=NotSet, body=NotSet, maintainer_can_modify=NotSet, draft=NotSet, issue=NotSet)
Please update your usage of Repository.create_pull
accordingly.
New features
- Throttle requests to mitigate RateLimitExceededExceptions (#2145) (9915580)
- Retry retryable 403 (rate limit) (#2387) (0bb72ca)
- Close connections after use (#2724) (73236e2)
Improvements
- Make datetime objects timezone-aware (#2565) (0177f7c)
- Make
Branch.edit_*
functions return objects (#2748) (8dee53a) - Add
license
attribute toRepository
(#2721) (26d353e) - Add missing attributes to
Repository
(#2742) (65cfeb1) - Add
is_alphanumeric
attribute toAutolink
andRepository.create_autolink
(#2630) (b6a28a2) - Suppress
requests
fallback to netrc, providegithub.Auth.Netrc
(#2739) (ac36f6a) - Pass Requester arguments to
AppInstallationAuth.__integration
(#2695) (8bf542a) - Adding feature for enterprise consumed license (#2626) (a7bfdf2)
- Search Workflows by Name (#2711) (eadc241)
- Add
Secret
andVariable
classes (#2623) (bcca758) - Add Autolink API link (#2632) (aedfa0b)
- Add
required_linear_history
attribute toBranchProtection
(#2643) (7a80fad) - Add retry issue to
GithubException
, don't log it (#2611) (de80ff4) - Add
message
property toGithubException
(#2591) (f087cad) - Add support for repo and org level actions variables (#2580) (91b3f40)
- Add missing arguments to
Workflow.get_runs()
(#2346) (766df99) - Add
github.Rate.used
field (#2531) (c4c2e52)
Bug Fixes
- Fix
Branch.bypass_pull_request_allowances
failing with "nil is not an object" (#2535) (c5542a6) - Fix
required_conversation_resolution
assertion (#2715) (54f2226) - Fix assertion creating pull request review comment (#2641) (2fa568b)
- Safely coerce
responseHeaders
toint
(#2697) (adbfce9) - Fix assertion for
subject_type
in creating pull request review comment (#2642) (4933459) - Use timezone-aware reset datetime in
GithubRetry.py
(#2610) (950a694) - Fix
Branch.bypass_pull_request_allowances
failing with "nil is not an object" (#2535) (c5542a6)
Maintenance
- Epic mass-merge
.pyi
type stubs back to.py
sources (#2636) - Move to main default branch (#2566) (e66c163)
- Force Unix EOL (#2573) (094538e)
- Close replay test data file silently when test is failing already (#2747) (6d871d5)
- CI: Make CI support merge queue (#2644) (a91debf)
- CI: Run CI on release branches (#2708) (9a88b6b)
- CI: remove conflict label workflow (#2669) (95d8b83)
- Fix pip install command in README.md (#2731) (2cc1ba2)
- Update
add_attribute.py
to latest conding style (#2631) (e735972) - CI: Improve ruff DX (#2667) (48d2009)
- CI: Increase wait and retries of labels action (#2670) (ff0f31c)
- Replace
flake8
withruff
(#2617) (42c3b47) - CI: update labels action name and version (#2654) (c5c83eb)
- CI: label PRs that have conflicts (#2622) (1d637e4)
- Unify requirements files location & source in setup.py (#2598) (2edc0f8)
- Enable mypy
disallow_untyped_defs
(#2609) (294c0cc) - Enable mypy
check_untyped_defs
(#2607) (8816889) - Set line length to 120 characters (#2599) (13e178a)
- CI: Build and check package before release (#2593) (3c880e7)
- Use
typing_extensions
forTypedDict
(#2592) (5fcb0c7) - CI: Update action actions/setup-python (#2382) (2e5cd31)
- Add more methods and attributes to Repository.pyi (#2581) (72840de)
- CI: Make pytest color logs (#2597) (7324110)
- precommit: move
flake8
as last (#2595) (11bb6bd) - Test on Windows and macOS, don't fail fast (#2590) (5c60089)
- Remove symlinks from test data (#2588) (8d3b905)
v2.0.1-preview
v1.59.1
v2.0.0-preview.1
v2.0.0-preview
Important
Request throttling
This release introduces a default throttling mechanism to mitigate secondary rate limit errors and comply with Github's best practices:
https://docs.github.com/en/rest/guides/best-practices-for-integrators?apiVersion=2022-11-28#dealing-with-secondary-rate-limits
The default throttling of 1 second between writes and 0.25 second between any requests can be configured for github.Github
and github.GithubIntegration
:
g = github.Github(seconds_between_requests=0.25, seconds_between_writes=1)
Set these parameters to None
to disable throttling and restore earlier behavior.
Request retry
This release introduces a default retry mechanism to retry retry-able 403 responses (primary and secondary rate limit errors only) and any 5xx response.
Class github.GithubRetry
implements this behavior, and can be configured via the retry
argument of github.Github
and github.GithubIntegration
. Retry behavior is configured similar to urllib3.Retry
: https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html
g = github.Github(retry=github.GithubRetry())
Set this parameter to None
to disable retry mechanism and restore earlier behaviour.
Breaking Changes
Any timestamps returned by this library are datetime
with timezone information, usually UTC. Before this release, timestamps used to be naive datetime
instances without timezone. Comparing (other than ==
) these timestamps with naive datetime
instances used to work but will now break. Add a timezone information to your datetime
instances before comparison:
if g.get_repo("PyGithub/PyGithub").created_at < datetime(2012, 2, 26, tzinfo=timezone.utc):
...
New features
- Throttle requests to mitigate RateLimitExceededExceptions (#2145) (9915580)
- Retry retryable 403 (rate limit) (#2387) (0bb72ca)
Improvements
Bug Fixes
Maintenance
v1.59.0
Important
This release introduces new way of authentication. All authentication-related arguments github.Github(login_or_token=…, password=…, jwt=…, app_auth=…)
and github.GithubIntegration(integration_id=…, private_key=…, jwt_expiry=…, jwt_issued_at=…, jwt_algorithm=…)
are replaced by a single auth=…
argument. Module github.Auth
provides classes for all supported ways of authentication: Login
, Token
, AppAuth
, AppAuthToken
, AppInstallationAuth
, AppUserAuth
. Old arguments are deprecated but continue to work. They are scheduled for removal for version 2.0 release.
This project has decided to move all typing information from .pyi
files into the respective .py
source files. This will happen gradually over time.
Breaking Changes
- The
position
argument ingithub.PullRequest.create_review_comment(position=…)
has been renamed toline
.
This breaks user code that callscreate_review_comment
with keyword argumentposition
. Call withline=…
instead.
Calling this method with positional arguments is not breaking. - The
jwt_expiry
,jwt_issued_at
andjwt_algorithm
arguments ingithub.GithubIntegration()
have changed their position.
User code callinggithub.GithubIntegration(…)
with these arguments as positional arguments breaks.
Please use keyword arguments:github.GithubIntegration(…, jwt_expiry=…, jwt_issued_at=…, jwt_algorithm=…)
. - The
since
argument ingithub.PullRequest.get_review_comments(…)
has changed position.User code calling
github.PullRequest.get_review_comments(…)with this argument as positional argument breaks. Please use keyword argument:
github.PullRequest.get_review_comments(since=…)`.
Deprecations
- The use of
github.Github(login_or_token=…)
is deprecated, usegithub.Github(auth=github.Auth.Login(…))
orgithub.Github(auth=github.Auth.Token(…))
instead. - The use of
github.Github(password=…)
is deprecated, usegithub.Github(auth=github.Auth.Login(…))
instead. - The use of
github.Github(jwt=…)
is deprecated, usegithub.Github(auth=github.AppAuth(…))
orgithub.Github(auth=github.AppAuthToken(…))
instead. - The use of
github.Github(app_auth=…)
is deprecated, usegithub.Github(auth=github.Auth.AppInstallationAuth(…))
instead. - The use of
github.GithubIntegration(integration_id=…, private_key=…, jwt_expiry=…, jwt_issued_at=…, jwt_algorithm=…)
is deprecated, usegithub.GithubIntegration(auth=github.Auth.AppAuth(…))
instead. - The use of
github.GithubIntegration.create_jwt
is deprecated, usegithub.Github(auth=github.Auth.AppAuth)
,github.Auth.AppAuth.token
orgithub.Auth.AppAuth.create_jwt(expiration)
instead. - The use of
AppAuthentication
is deprecated, usegithub.Auth.AppInstallationAuth
instead. - The use of
github.Github.get_app()
without providing argumentslug
is deprecated, usegithub.GithubIntegration(auth=github.Auth.AppAuth(…)).get_app()
.
Bug Fixes
- Test and fix UTC issue with AppInstallationAuth (#2561) (ff3b80f)
- Make Requester.__createException robust against missing message and body (#2159) (7be3f76)
- Fix auth issues with
Installation.get_repos
(#2547) (6407512) - Fix broken urls in docstrings (#2393) (f82ad61)
- Raise error on unsupported redirects, log supported redirects (#2524) (17cd0b7)
- Fix GithubIntegration that uses expiring jwt (#2460) (5011548)
- Add expiration argument back to GithubIntegration.create_jwt (#2439) (822fc05)
- Add crypto extras to pyjwt, which pulls in cryptogaphy package (#2443) (554b2b2)
- Remove RLock from Requester (#2446) (45f3d72)
- Move CI to Python 3.11 release and 3.12 dev (#2434) (e414c32)
- Pass Requester base URL to integration (#2420) (bdceae2)
Improvements
- Add Webhook Deliveries (#2508) (517ad33)
- Add support for workflow jobs and steps (#1951) (804c310)
- Add support for get_app() with App authentication (#2549) (6d4b6d1)
- Allow multiline comments in PullRequest (#2540) (6a21761)
- Implement
AppUserAuth
for Github App user tokens (#2546) (f291a36) - Add support for environments (#2223) (0384e2f)
- Add support for new RepositoryAdvisories API 🎉 (#2483) (daf62bd)
- Make
MainClass.get_app
return completedGithubApp
when slug is given (#2543) (84912a6) - Add authentication classes, move auth logic there (#2528) (fc2d0e1)
- Add sort order and direction for getting comments (#2544) (a8e7c42)
- Add
name
filter toRepository.get_artifacts()
(#2459) (9f52e94) - Add
name
,display_title
andpath
attributes toWorkflowRun
(#2397) (1081638) - Add new
create_fork
arguments (#2493) (b94a83c) - add
ref
to Deployment (#2489) (e8075c4) - Add query
check_suite_id
integer toWorkflow.get_runs
(#2466) (a485451) - Add
generate_release_notes
parameter tocreate_git_release
andcreate_git_tag_and_release
(#2417) (49b3ae1) - Add example for Pull Request comments to documentation (#2390) (c2f12bd)
- Add allow_auto_merge support to Repository (#2477) (8c4b946)
- Add
artifact_id
argument toRepository.get_artifact()
(#2458) (4fa0a5f) - Add missing attributes to Branch (#2512) (e296dbd)
- Add allow_update_branch option to Organization (#2465) (bab4180)
- Add support for Issue.state_reason #2370 (#2392) (5aa544a)
- Add parameters to Repository.get_workflow_runs (#2408) (4198dbf)
Maintenance
- Add type stub for MainClass.get_project_column (#2502) (d514222)
- Sync GithubIntegration init arguments with github.Github (#2556) (ea45237)
- Update MAINTAINERS (#2545) (f4e9dcb)
- Link to stable docs, update introduction in package used by pypi, move auth arg front (#2557) (006766f)
- Merge PaginatedList.pyi back to source (#2555) (cb50dec)
- Merge GithubObject.pyi/Requester.pyi stubs back to source (#2463) (b6258f4)
- [CI] Moving linting into separate workflow (#2522) (52fc107)
- Merging 1.58.x patch release notes into master (#2525) (217d424)
- Merge AppAuthentication.pyi to source (#2519) (8e8cfb3)
- Merge GithubException.pyi stubs back to source (#2464) (03a2f69)
- Add missing fields from
GithubCredentials.py
to CONTRIBUTING.md (#2482) (297317b) - Update docstring and typing for allow_forking and allow_update_branch (Repository) (#2529) (600217f)
- Bump actions/checkout from 2 to 3.1.0 (#2327) (300c501)
- RTD: install current project (def5223)
- Add current dir sys.path as well (9c96faa)
- Use use_scm_version to get current version from git tag (#2429) (3ea91a3)