Skip to content

Commit b41b499

Browse files
authored
Merge branch 'main' into action-secrets
2 parents 2be9f19 + 2043ad3 commit b41b499

File tree

116 files changed

+479
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+479
-260
lines changed

.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Please provide:
1212

1313
- The version of pip you used to install github3.py
1414

15-
- The version of github3.py, requests, uritemplate, and dateutil installed
15+
- The version of github3.py, requests, uritemplate, and python-dateutil installed
1616

1717
## Minimum Reproducible Example
1818

.github/workflows/docs.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Check documentation
3+
4+
"on":
5+
schedule:
6+
- cron: "0 1 * * *" # everyday at 1am
7+
push:
8+
paths:
9+
- "**.rst"
10+
- "docs/**"
11+
pull_request:
12+
paths:
13+
- "**.rst"
14+
- "docs/**"
15+
16+
jobs:
17+
docs:
18+
name: Build documentation & check links
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Upgrade pip
27+
run: |
28+
pip install -U pip
29+
pip --version
30+
31+
- name: Install Tox
32+
run: |
33+
pip install tox
34+
tox --version
35+
36+
- name: Build documentation
37+
run: tox
38+
env:
39+
TOXENV: docs
40+
41+
- name: Upload documentation
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: docs
45+
path: docs/build

.pre-commit-config.yaml

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-toml
@@ -13,31 +13,33 @@ repos:
1313
- id: trailing-whitespace
1414
types: [text]
1515
stages: [commit, push, manual]
16-
- repo: https://github.com/asottile/reorder-python-imports
17-
rev: v3.10.0
16+
- repo: https://github.com/PyCQA/isort
17+
rev: 5.13.2
1818
hooks:
19-
- id: reorder-python-imports
20-
args: [--application-directories, '.:src', --py37-plus]
19+
- id: isort
2120
- repo: https://github.com/psf/black
22-
rev: 23.3.0
21+
rev: 24.4.0
2322
hooks:
2423
- id: black
2524
- repo: https://github.com/asottile/pyupgrade
26-
rev: v3.7.0
25+
rev: v3.15.2
2726
hooks:
2827
- id: pyupgrade
2928
args: [--py37-plus]
30-
#- repo: https://github.com/pre-commit/mirrors-mypy
31-
# rev: v0.910
32-
# hooks:
33-
# - id: mypy
34-
# exclude: ^(docs/|tests/)
29+
- repo: https://github.com/pre-commit/mirrors-mypy
30+
rev: v1.9.0
31+
hooks:
32+
- id: mypy
33+
additional_dependencies:
34+
- types-python-dateutil
35+
- types-requests
36+
exclude: ^(docs/|tests/)
3537
- repo: https://github.com/jorisroovers/gitlint
3638
rev: v0.19.1
3739
hooks:
3840
- id: gitlint
3941
- repo: https://github.com/asottile/setup-cfg-fmt
40-
rev: v2.3.0
42+
rev: v2.5.0
4143
hooks:
4244
- id: setup-cfg-fmt
4345
args: [--min-py3-version, '3.7']

.readthedocs.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
build:
3+
os: ubuntu-22.04
4+
tools:
5+
python: "3.11"
6+
sphinx:
7+
configuration: docs/source/conf.py
8+
formats: all
9+
python:
10+
install:
11+
- requirements: docs/source/requirements.txt
12+
- path: .

AUTHORS.rst

+2
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,5 @@ Contributors
224224
- Chris R (@offbyone)
225225

226226
- Thomas Buchner (@MrBatschner)
227+
228+
- Chris Cotter (@ccotter)

docs/source/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
sphinx>=4.2.0
22
docutils!=0.18
3+
sphinx_rtd_theme

pyproject.toml

+13-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Source = "https://github.com/sigmavirus24/github3.py"
7070
[tool.black]
7171
line-length = 78
7272
target-version = ['py37']
73-
safe = true
7473
exclude = '''
7574
(
7675
/(
@@ -83,6 +82,19 @@ exclude = '''
8382
| _build
8483
| build
8584
| dist
85+
| venv
8686
)/
8787
)
8888
'''
89+
90+
[tool.mypy]
91+
files = ["."]
92+
exclude = [
93+
"^docs/",
94+
"^tests/",
95+
]
96+
97+
[tool.isort]
98+
profile = "black"
99+
line_length = 78
100+
force_single_line = true

src/github3/__about__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The module that holds much of the metadata about github3.py."""
2+
23
__package_name__ = "github3.py"
34
__title__ = "github3"
45
__author__ = "Ian Stapleton Cordasco"

src/github3/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:license: Modified BSD, see LICENSE for more details
99
1010
"""
11+
1112
from .__about__ import __author__
1213
from .__about__ import __author_email__
1314
from .__about__ import __copyright__

src/github3/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:license: Modified BSD, see LICENSE for more details
77
88
"""
9+
910
from .github import GitHub
1011
from .github import GitHubEnterprise
1112

src/github3/apps.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
https://developer.github.com/apps/building-github-apps/
44
"""
5+
56
import time
67

78
import jwt

src/github3/auths.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains the Authorization object."""
2+
23
from .decorators import requires_basic_auth
34
from .models import GitHubCore
45

src/github3/checks.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains all the classes relating to Checks."""
2+
23
from json import dumps
34

45
from . import decorators
@@ -45,7 +46,7 @@ def _update_attributes(self, pull):
4546
def _repr(self):
4647
return f"<CheckPullRequest [#{self.number}]>"
4748

48-
def to_pull(self):
49+
def to_pull(self, conditional: bool = False):
4950
"""Retrieve a full PullRequest object for this CheckPullRequest.
5051
5152
:returns:
@@ -119,7 +120,7 @@ def _repr(self):
119120
self.name, str(self.owner["login"])
120121
)
121122

122-
def to_app(self):
123+
def to_app(self, conditional: bool = False) -> models.GitHubCore:
123124
"""Retrieve a full App object for this CheckApp.
124125
125126
:returns:

src/github3/decorators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module provides decorators to the rest of the library."""
2+
23
import os
34
from functools import wraps
45
from io import BytesIO as StringIO

src/github3/events.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains the classes related to Events."""
2+
23
import copy
34

45
from . import models
@@ -41,7 +42,7 @@ def _update_attributes(self, user):
4142
self.login = user["login"]
4243
self._api = self.url = user["url"]
4344

44-
def to_user(self):
45+
def to_user(self, conditional: bool = False) -> models.GitHubCore:
4546
"""Retrieve a full User object for this EventUser.
4647
4748
:returns:
@@ -93,7 +94,7 @@ def _update_attributes(self, org):
9394
self.login = org["login"]
9495
self._api = self.url = org["url"]
9596

96-
def to_org(self):
97+
def to_org(self, conditional: bool = False) -> models.GitHubCore:
9798
"""Retrieve a full Organization object for this EventOrganization.
9899
99100
:returns:
@@ -148,7 +149,7 @@ def _update_attributes(self, pull):
148149
self.locked = pull["locked"]
149150
self._api = self.url = pull["url"]
150151

151-
def to_pull(self):
152+
def to_pull(self, conditional: bool = False) -> models.GitHubCore:
152153
"""Retrieve a full PullRequest object for this EventPullRequest.
153154
154155
:returns:
@@ -258,7 +259,9 @@ def _update_attributes(self, comment):
258259
self.updated_at = self._strptime(comment["updated_at"])
259260
self.user = users.ShortUser(comment["user"], self)
260261

261-
def to_review_comment(self):
262+
def to_review_comment(
263+
self, conditional: bool = False
264+
) -> models.GitHubCore:
262265
"""Retrieve a full ReviewComment object for this EventReviewComment.
263266
264267
:returns:
@@ -269,7 +272,7 @@ def to_review_comment(self):
269272
from . import pulls
270273

271274
comment = self._json(self._get(self._api), 200)
272-
return pulls.ReviewComment(comment, self)
275+
return pulls.ReviewComment(comment, self.session)
273276

274277
refresh = to_review_comment
275278

@@ -285,7 +288,7 @@ def _update_attributes(self, issue):
285288
self.locked = issue["locked"]
286289
self._api = self.url = issue["url"]
287290

288-
def to_issue(self):
291+
def to_issue(self, conditional: bool = False) -> models.GitHubCore:
289292
"""Retrieve a full Issue object for this EventIssue."""
290293
from . import issues
291294

@@ -352,7 +355,9 @@ def _update_attributes(self, comment):
352355
self.updated_at = self._strptime(comment["updated_at"])
353356
self.user = users.ShortUser(comment["user"], self)
354357

355-
def to_issue_comment(self):
358+
def to_issue_comment(
359+
self, conditional: bool = False
360+
) -> models.GitHubCore:
356361
"""Retrieve the full IssueComment object for this comment.
357362
358363
:returns:

src/github3/gists/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
See also: http://developer.github.com/v3/gists/
1414
"""
15+
1516
from .gist import Gist
1617
from .gist import ShortGist
1718

src/github3/gists/comment.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the logic for a GistComment."""
2+
23
from .. import decorators
34
from .. import models
45
from .. import users

src/github3/gists/file.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the GistFile object."""
2+
23
from .. import models
34

45

src/github3/gists/gist.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""This module contains the Gist, ShortGist, and GistFork objects."""
2+
3+
import typing as t
24
from json import dumps
35

4-
from . import comment
5-
from . import file as gistfile
6-
from . import history
76
from .. import models
87
from .. import users
98
from ..decorators import requires_auth
9+
from . import comment
10+
from . import file as gistfile
11+
from . import history
1012

1113

1214
class _Gist(models.GitHubCore):
@@ -31,7 +33,9 @@ class _Gist(models.GitHubCore):
3133
"""
3234

3335
class_name = "_Gist"
34-
_file_class = gistfile.ShortGistFile
36+
_file_class: t.Type[
37+
t.Union[gistfile.ShortGistFile, gistfile.GistFile]
38+
] = gistfile.ShortGistFile
3539

3640
def _update_attributes(self, gist):
3741
self.comments_count = gist["comments"]
@@ -265,7 +269,7 @@ def _update_attributes(self, fork):
265269
def _repr(self):
266270
return f"<GistFork [{self.id}]>"
267271

268-
def to_gist(self):
272+
def to_gist(self, conditional: bool = False) -> models.GitHubCore:
269273
"""Retrieve the full Gist representation of this fork.
270274
271275
:returns:

src/github3/gists/history.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing the GistHistory object."""
2+
23
from .. import models
34
from .. import users
45

@@ -51,7 +52,7 @@ class GistHistory(models.GitHubCore):
5152
def _update_attributes(self, history) -> None:
5253
self.url = self._api = history["url"]
5354
self.version = history["version"]
54-
self.user = users.ShortUser(history["user"], self)
55+
self.user = users.ShortUser(history["user"], self.session)
5556
self.change_status = history["change_status"]
5657
self.additions = self.change_status.get("additions")
5758
self.deletions = self.change_status.get("deletions")

0 commit comments

Comments
 (0)