Skip to content

Commit

Permalink
Merge branch 'main' into action-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmavirus24 committed Apr 25, 2024
2 parents 2be9f19 + 2043ad3 commit b41b499
Show file tree
Hide file tree
Showing 116 changed files with 479 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Please provide:

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

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

## Minimum Reproducible Example

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Check documentation

"on":
schedule:
- cron: "0 1 * * *" # everyday at 1am
push:
paths:
- "**.rst"
- "docs/**"
pull_request:
paths:
- "**.rst"
- "docs/**"

jobs:
docs:
name: Build documentation & check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Upgrade pip
run: |
pip install -U pip
pip --version
- name: Install Tox
run: |
pip install tox
tox --version
- name: Build documentation
run: tox
env:
TOXENV: docs

- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: docs
path: docs/build
28 changes: 15 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-toml
Expand All @@ -13,31 +13,33 @@ repos:
- id: trailing-whitespace
types: [text]
stages: [commit, push, manual]
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.10.0
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py37-plus]
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.4.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py37-plus]
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.910
# hooks:
# - id: mypy
# exclude: ^(docs/|tests/)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
- types-python-dateutil
- types-requests
exclude: ^(docs/|tests/)
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.3.0
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
args: [--min-py3-version, '3.7']
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
sphinx:
configuration: docs/source/conf.py
formats: all
python:
install:
- requirements: docs/source/requirements.txt
- path: .
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,5 @@ Contributors
- Chris R (@offbyone)

- Thomas Buchner (@MrBatschner)

- Chris Cotter (@ccotter)
1 change: 1 addition & 0 deletions docs/source/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx>=4.2.0
docutils!=0.18
sphinx_rtd_theme
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ Source = "https://github.com/sigmavirus24/github3.py"
[tool.black]
line-length = 78
target-version = ['py37']
safe = true
exclude = '''
(
/(
Expand All @@ -83,6 +82,19 @@ exclude = '''
| _build
| build
| dist
| venv
)/
)
'''

[tool.mypy]
files = ["."]
exclude = [
"^docs/",
"^tests/",
]

[tool.isort]
profile = "black"
line_length = 78
force_single_line = true
1 change: 1 addition & 0 deletions src/github3/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The module that holds much of the metadata about github3.py."""

__package_name__ = "github3.py"
__title__ = "github3"
__author__ = "Ian Stapleton Cordasco"
Expand Down
1 change: 1 addition & 0 deletions src/github3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:license: Modified BSD, see LICENSE for more details
"""

from .__about__ import __author__
from .__about__ import __author_email__
from .__about__ import __copyright__
Expand Down
1 change: 1 addition & 0 deletions src/github3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:license: Modified BSD, see LICENSE for more details
"""

from .github import GitHub
from .github import GitHubEnterprise

Expand Down
1 change: 1 addition & 0 deletions src/github3/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
https://developer.github.com/apps/building-github-apps/
"""

import time

import jwt
Expand Down
1 change: 1 addition & 0 deletions src/github3/auths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the Authorization object."""

from .decorators import requires_basic_auth
from .models import GitHubCore

Expand Down
5 changes: 3 additions & 2 deletions src/github3/checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains all the classes relating to Checks."""

from json import dumps

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

def to_pull(self):
def to_pull(self, conditional: bool = False):
"""Retrieve a full PullRequest object for this CheckPullRequest.
:returns:
Expand Down Expand Up @@ -119,7 +120,7 @@ def _repr(self):
self.name, str(self.owner["login"])
)

def to_app(self):
def to_app(self, conditional: bool = False) -> models.GitHubCore:
"""Retrieve a full App object for this CheckApp.
:returns:
Expand Down
1 change: 1 addition & 0 deletions src/github3/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides decorators to the rest of the library."""

import os
from functools import wraps
from io import BytesIO as StringIO
Expand Down
19 changes: 12 additions & 7 deletions src/github3/events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the classes related to Events."""

import copy

from . import models
Expand Down Expand Up @@ -41,7 +42,7 @@ def _update_attributes(self, user):
self.login = user["login"]
self._api = self.url = user["url"]

def to_user(self):
def to_user(self, conditional: bool = False) -> models.GitHubCore:
"""Retrieve a full User object for this EventUser.
:returns:
Expand Down Expand Up @@ -93,7 +94,7 @@ def _update_attributes(self, org):
self.login = org["login"]
self._api = self.url = org["url"]

def to_org(self):
def to_org(self, conditional: bool = False) -> models.GitHubCore:
"""Retrieve a full Organization object for this EventOrganization.
:returns:
Expand Down Expand Up @@ -148,7 +149,7 @@ def _update_attributes(self, pull):
self.locked = pull["locked"]
self._api = self.url = pull["url"]

def to_pull(self):
def to_pull(self, conditional: bool = False) -> models.GitHubCore:
"""Retrieve a full PullRequest object for this EventPullRequest.
:returns:
Expand Down Expand Up @@ -258,7 +259,9 @@ def _update_attributes(self, comment):
self.updated_at = self._strptime(comment["updated_at"])
self.user = users.ShortUser(comment["user"], self)

def to_review_comment(self):
def to_review_comment(
self, conditional: bool = False
) -> models.GitHubCore:
"""Retrieve a full ReviewComment object for this EventReviewComment.
:returns:
Expand All @@ -269,7 +272,7 @@ def to_review_comment(self):
from . import pulls

comment = self._json(self._get(self._api), 200)
return pulls.ReviewComment(comment, self)
return pulls.ReviewComment(comment, self.session)

refresh = to_review_comment

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

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

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

def to_issue_comment(self):
def to_issue_comment(
self, conditional: bool = False
) -> models.GitHubCore:
"""Retrieve the full IssueComment object for this comment.
:returns:
Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
See also: http://developer.github.com/v3/gists/
"""

from .gist import Gist
from .gist import ShortGist

Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/comment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the logic for a GistComment."""

from .. import decorators
from .. import models
from .. import users
Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the GistFile object."""

from .. import models


Expand Down
14 changes: 9 additions & 5 deletions src/github3/gists/gist.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""This module contains the Gist, ShortGist, and GistFork objects."""

import typing as t
from json import dumps

from . import comment
from . import file as gistfile
from . import history
from .. import models
from .. import users
from ..decorators import requires_auth
from . import comment
from . import file as gistfile
from . import history


class _Gist(models.GitHubCore):
Expand All @@ -31,7 +33,9 @@ class _Gist(models.GitHubCore):
"""

class_name = "_Gist"
_file_class = gistfile.ShortGistFile
_file_class: t.Type[
t.Union[gistfile.ShortGistFile, gistfile.GistFile]
] = gistfile.ShortGistFile

def _update_attributes(self, gist):
self.comments_count = gist["comments"]
Expand Down Expand Up @@ -265,7 +269,7 @@ def _update_attributes(self, fork):
def _repr(self):
return f"<GistFork [{self.id}]>"

def to_gist(self):
def to_gist(self, conditional: bool = False) -> models.GitHubCore:
"""Retrieve the full Gist representation of this fork.
:returns:
Expand Down
3 changes: 2 additions & 1 deletion src/github3/gists/history.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the GistHistory object."""

from .. import models
from .. import users

Expand Down Expand Up @@ -51,7 +52,7 @@ class GistHistory(models.GitHubCore):
def _update_attributes(self, history) -> None:
self.url = self._api = history["url"]
self.version = history["version"]
self.user = users.ShortUser(history["user"], self)
self.user = users.ShortUser(history["user"], self.session)
self.change_status = history["change_status"]
self.additions = self.change_status.get("additions")
self.deletions = self.change_status.get("deletions")
Expand Down

0 comments on commit b41b499

Please sign in to comment.