8000 Update branch protection API support · marknet15/github3.py@1df2461 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1df2461

Browse files
committed
Update branch protection API support
This updates the necessary cassettes, example JSON, and other classes to support GitHub's ever backwards-incompatible Branch Protection APIs Closes sigmavirus24#1030 Closes sigmavirus24#893
1 parent 4d958e3 commit 1df2461

23 files changed

+747
-265
lines changed

docs/source/release-notes/2.1.0.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/release-notes/3.0.0.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
3.0.0: 2021-10-30
2+
-----------------
3+
4+
Backwards Incompatible Changes
5+
``````````````````````````````
6+
7+
- :meth:`~github3.repos.branch.Branch.protect` has been updated to reflect the
8+
GitHub API
9+
10+
Features Added
11+
``````````````
12+
13+
- Add ``maintainer_can_modify`` parameter to
14+
:meth:`~github3.repos.repo.Repository.create_pull`
15+
16+
- Add :attr:`~github3.repos.branch.BranchProtection.required_linear_history`,
17+
:attr:`~github3.repos.branch.BranchProtection.allow_force_pushes`,
18+
:attr:`~github3.repos.branch.BranchProtection.allow_deletions`, and
19+
:attr:`~github3.repos.branch.BranchProtection.required_conversation_resolution`.
20+
21+
- Add support for blocking users to :class:`~github3.github.GitHub` and
22+
:class:`~github3.orgs.Organization`.
23+
24+
- :meth:`~github3.github.GitHub.blocked_users`
25+
- :meth:`~github3.github.GitHub.block`
26+
- :meth:`~github3.github.GitHub.is_blocking`
27+
- :meth:`~github3.github.GitHub.unblock`
28+
- :meth:`~github3.orgs.Organization.blocked_users`
29+
- :meth:`~github3.orgs.Organization.block`
30+
- :meth:`~github3.orgs.Organization.is_blocking`
31+
- :meth:`~github3.orgs.Organization.unblock`
32+
33+
- Add support for beta branch synchronization endpoint
34+
:meth:`~github3.repos.branch.Branch.sync_with_upstream`

docs/source/release-notes/index.rst

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,49 @@
55
All of the release notes that have been recorded for github3.py are organized
66
here with the newest releases first.
77

8+
3.x Release Series
9+
==================
10+
11+
.. toctree::
12+
3.0.0
13+
814
2.x Release Series
915
==================
1016

1117
.. toctree::
12-
2.1.0
13-
2.0.0
18+
2.0.0
1419

1520
1.x Release Series
1621
==================
1722

1823
.. toctree::
19-
1.3.0
20-
1.2.0
21-
1.1.0
22-
1.0.2
23-
1.0.1
24-
1.0.0
24+
1.3.0
25+
1.2.0
26+
1.1.0
27+
1.0.2
28+
1.0.1
29+
1.0.0
2530

2631
0.x Release Series
2732
==================
2833

2934
.. toctree::
30-
0.9.3
31-
0.9.2
32-
0.9.1
33-
0.9.0
34-
0.8.2
35-
0.8.1
36-
0.8.0
37-
0.7.1
38-
0.7.0
39-
0.6.1
40-
0.6.0
41-
0.5.3
42-
0.5.2
43-
0.5.1
44-
0.5.0
45-
0.4.0
46-
0.3.0
47-
0.2.0
48-
0.1.0
35+
0.9.3
36+
0.9.2
37+
0.9.1
38+
0.9.0
39+
0.8.2
40+
0.8.1
41+
0.8.0
42+
0.7.1
43+
0.7.0
44+
0.6.1
45+
0.6.0
46+
0.5.3
47+
0.5.2
48+
0.5.1
49+
0.5.0
50+
0.4.0
51+
0.3.0
52+
0.2.0
53+
0.1.0

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[metadata]
22
name = github3.py
3+
version = attr:github3.__about__.__version__
34
description = Python wrapper for the GitHub API(http://developer.github.com/v3)
45
long_description = file: README.rst
56
long_description_content_type = text/x-rst
@@ -35,6 +36,7 @@ install_requires =
3536
python-dateutil>=2.6.0
3637
requests>=2.18
3738
uritemplate>=3.0.0
39+
typing-extensions>=3.10.0.2;python_version < "3.7"
3840
python_requires = >=3.6
3941
package_dir =
4042
=src

setup.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
"""Packaging logic."""
2-
import re
3-
42
import setuptools
53

6-
__version__ = ""
7-
with open("src/github3/__about__.py") as fd:
8-
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
9-
for line in fd:
10-
m = reg.match(line)
11-
if m:
12-
__version__ = m.group(1)
13-
break
14-
15-
setuptools.setup(
16-
version=__version__,
17-
)
4+
setuptools.setup()

src/github3/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__author_email__ = "graffatcolmingov@gmail.com"
66
__license__ = "Modified BSD"
77
__copyright__ = "Copyright 2012-2021 Ian Stapleton Cordasco"
8-
__version__ = "2.0.0"
8+
__version__ = "3.0.0"
99
__version_info__ = tuple(
1010
int(i) for i in __version__.split(".") if i.isdigit()
1111
)

src/github3/apps.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class App(models.GitHubCore):
4141
4242
The description of the App provided by the owner.
4343
44+
.. attribute:: events
45+
46+
An array of the event types an App receives
47+
4448
.. attribute:: external_url
4549
4650
The URL provided for the App by the owner.
@@ -69,6 +73,14 @@ class App(models.GitHubCore):
6973
A :class:`~github3.users.ShortUser` object representing the GitHub
7074
user who owns the App.
7175
76+
.. attribute:: permissions
77+
78+
A dictionary describing the permissions the App has
79+
80+
.. attribute:: slug
81+
82+
A short string used to identify the App
83+
7284
.. attribute:: updated_at
7385
7486
A :class:`~datetime.datetime` object representing the day and time
@@ -88,14 +100,16 @@ def _update_attributes(self, json):
88100
self.created_at = self._strptime(json["created_at"])
89101
self.description = json["description"]
90102
self.external_url = json["external_url"]
103+
self.events = json["events"]
91104
self.html_url = json["html_url"]
92105
self.id = json["id"]
93106
self.name = json["name"]
94107
self.node_id = json["node_id"]
95108
self.owner = users.ShortUser(json["owner"], self)
109+
self.permissions = json["permissions"]
110+
self.slug = json["slug"]
96111
self.updated_at = self._strptime(json["updated_at"])
97-
_, slug = json["html_url"].rsplit("/", 1)
98-
self._api = self.url = self._build_url("apps", slug)
112+
self._api = self.url = self._build_url("apps", self.slug)
99113

100114
def _repr(self):
101115
return f'<App ["{self.name}" by {str(self.owner)}]>'

src/github3/github.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ def blocked_users(
506506
) -> t.Generator[users.ShortUser, None, None]:
507507
"""Iterate over the users blocked by this organization.
508508
509+
.. versionadded:: 2.1.0
510+
509511
:param int number:
510512
(optional), number of users to iterate over. Default: -1 iterates
511513
over all values
@@ -523,6 +525,8 @@ def blocked_users(
523525
def block(self, username: users.UserLike) -> bool:
524526
"""Block a specific user from an organization.
525527
528+
.. versionadded:: 2.1.0
529+
526530
:parameter str username:
527531
Name (or user-like instance) of the user to block.
528532
:returns:
@@ -537,6 +541,8 @@ def block(self, username: users.UserLike) -> bool:
537541
def unblock(self, username: users.UserLike) -> bool:
538542
"""Unblock a specific user from an organization.
539543
544+
.. versionadded:: 2.1.0
545+
540546
:parameter str username:
541547
Name (or user-like instance) of the user to unblock.
542548
:returns:
@@ -551,6 +557,8 @@ def unblock(self, username: users.UserLike) -> bool:
551557
def is_blocking(self, username: users.UserLike) -> bool:
552558
"""Check if this organization is blocking a specific user.
553559
560+
.. versionadded:: 2.1.0
561+
554562
:parameter str username:
555563
Name (or user-like instance) of the user to unblock.
556564
:returns:

src/github3/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def ratelimit_remaining(self):
282282
self._remaining = core.get("remaining", 0)
283283
return self._remaining
284284

285-
def refresh(self, conditional=False):
285+
def refresh(self, conditional: bool = False) -> "GitHubCore":
286286
"""Re-retrieve the information for this object.
287287
288288
The reasoning for the return value is the following example: ::

src/github3/orgs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ def blocked_users(
439439
) -> t.Generator[users.ShortUser, None, None]:
440440
"""Iterate over the users blocked by this organization.
441441
442+
.. versionadded:: 2.1.0
443+
442444
:param int number:
443445
(optional), number of users to iterate over. Default: -1 iterates
444446
over all values
@@ -456,6 +458,8 @@ def blocked_users(
456458
def block(self, username: users.UserLike) -> bool:
457459
"""Block a specific user from an organization.
458460
461+
.. versionadded:: 2.1.0
462+
459463
:parameter str username:
460464
Name (or user-like instance) of the user to block.
461465
:returns:
@@ -470,6 +474,8 @@ def block(self, username: users.UserLike) -> bool:
470474
def unblock(self, username: users.UserLike) -> bool:
471475
"""Unblock a specific user from an organization.
472476
477+
.. versionadded:: 2.1.0
478+
473479
:parameter str username:
474480
Name (or user-like instance) of the user to unblock.
475481
:returns:
@@ -484,6 +490,8 @@ def unblock(self, username: users.UserLike) -> bool:
484490
def is_blocking(self, username: users.UserLike) -> bool:
485491
"""Check if this organization is blocking a specific user.
486492
493+
.. versionadded:: 2.1.0
494+
487495
:parameter str username:
488496
Name (or user-like instance) of the user to unblock.
489497
:returns:

0 commit comments

Comments
 (0)
0