Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.10-dev", "3.11-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
include:
- { python-version: "3.7", nox-python-version: "3.7" }
- { python-version: "3.8", nox-python-version: "3.8" }
- { python-version: "3.9", nox-python-version: "3.9" }
- { python-version: "3.10", nox-python-version: "3.10" }
- { python-version: "3.10-dev", nox-python-version: "3.10" }
- { python-version: "3.11-dev", nox-python-version: "3.11" }
- { python-version: "3.11", nox-python-version: "3.11" }
- { python-version: "3.12", nox-python-version: "3.12" }
- { python-version: "3.13-dev", nox-python-version: "3.13" }

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
if: "!endsWith(matrix.python-version, '-dev')"
with:
python-version: ${{ matrix.python-version }}
- uses: deadsnakes/action@v2.1.1
- uses: deadsnakes/action@v3.1.0
if: endsWith(matrix.python-version, '-dev')
with:
python-version: ${{ matrix.python-version }}
- run: pip install nox
- run: nox --session tests-${{ matrix.nox-python-version }}
env:
PYTHONDEVMODE: 1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -55,14 +55,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install nox
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sphinx:
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3"

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gidgethub is `available on PyPI <https://pypi.org/project/gidgethub/>`_.
python3 -m pip install gidgethub


Gidgethub requires Python version 3.7 and up.
Gidgethub requires Python version 3.8 and up.


Goals
Expand Down
15 changes: 1 addition & 14 deletions gidgethub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
"""An async GitHub API library"""

__version__ = "5.3.0"

import http
from typing import Any, Optional


class GitHubException(Exception):

"""Base exception for this library."""


class ValidationFailure(GitHubException):

"""An exception representing failed validation of a webhook event."""

# https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/securing-your-webhooks#validating-payloads-from-github


class HTTPException(GitHubException):

"""A general exception to represent HTTP responses."""

def __init__(self, status_code: http.HTTPStatus, *args: Any) -> None:
Expand All @@ -30,7 +28,6 @@ def __init__(self, status_code: http.HTTPStatus, *args: Any) -> None:


class RedirectionException(HTTPException):

"""Exception for 3XX HTTP responses."""


Expand All @@ -44,7 +41,6 @@ class BadRequest(HTTPException):


class BadRequestUnknownError(BadRequest):

"""A bad request whose response body is not JSON."""

def __init__(self, response: str) -> None:
Expand All @@ -53,7 +49,6 @@ def __init__(self, response: str) -> None:


class RateLimitExceeded(BadRequest):

"""Request rejected due to the rate limit being exceeded."""

# Technically rate_limit is of type gidgethub.sansio.RateLimit, but a
Expand All @@ -68,7 +63,6 @@ def __init__(self, rate_limit: Any, *args: Any) -> None:


class InvalidField(BadRequest):

"""A field in the request is invalid.

Represented by a 422 HTTP Response. Details of what fields were
Expand All @@ -82,7 +76,6 @@ def __init__(self, errors: Any, *args: Any) -> None:


class ValidationError(BadRequest):

"""A request was unable to be completed.

Represented by a 422 HTTP response. Details of what went wrong
Expand All @@ -96,12 +89,10 @@ def __init__(self, errors: Any, *args: Any) -> None:


class GitHubBroken(HTTPException):

"""Exception for 5XX HTTP responses."""


class GraphQLException(GitHubException):

"""Base exception for the GraphQL v4 API."""

def __init__(self, message: str, response: Any) -> None:
Expand All @@ -110,7 +101,6 @@ def __init__(self, message: str, response: Any) -> None:


class BadGraphQLRequest(GraphQLException):

"""A 4XX HTTP response."""

def __init__(self, status_code: http.HTTPStatus, response: Any) -> None:
Expand All @@ -120,23 +110,20 @@ def __init__(self, status_code: http.HTTPStatus, response: Any) -> None:


class GraphQLAuthorizationFailure(BadGraphQLRequest):

"""401 HTTP response to a bad oauth token."""

def __init__(self, response: Any) -> None:
super().__init__(http.HTTPStatus(401), response)


class QueryError(GraphQLException):

"""An error occurred while attempting to handle a GraphQL v4 query."""

def __init__(self, response: Any) -> None:
super().__init__(response["errors"][0]["message"], response)


class GraphQLResponseTypeError(GraphQLException):

"""The GraphQL response has an unexpected content type."""

def __init__(self, content_type: Optional[str], response: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion gidgethub/abc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide an abstract base class for easier requests."""

import abc
import http
import json
Expand Down Expand Up @@ -29,7 +30,6 @@


class GitHubAPI(abc.ABC):

"""Provide an idiomatic API for making calls to GitHub's API."""

def __init__(
Expand Down
1 change: 1 addition & 0 deletions gidgethub/actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for GitHub Actions."""

import functools
import json
import os
Expand Down
1 change: 1 addition & 0 deletions gidgethub/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for GitHub Actions."""

from typing import cast, Any, Dict

import time
Expand Down
1 change: 0 additions & 1 deletion gidgethub/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Router:

"""Route webhook events to registered functions."""

def __init__(self, *other_routers: "Router") -> None:
Expand Down
3 changes: 1 addition & 2 deletions gidgethub/sansio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
when working with GitHub's API (e.g. validating webhook events or specifying the
API version you want your request to work against).
"""

import datetime
from email.message import Message
import hmac
Expand Down Expand Up @@ -93,7 +94,6 @@ def validate_event(payload: bytes, *, signature: str, secret: str) -> None:


class Event:

"""Details of a GitHub webhook event."""

def __init__(self, data: Any, *, event: str, delivery_id: str) -> None:
Expand Down Expand Up @@ -219,7 +219,6 @@ def create_headers(


class RateLimit:

"""The rate limit imposed upon the requester.

The 'limit' attribute specifies the rate of requests per hour the client is
Expand Down
16 changes: 2 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@

def install_flit_dev_deps(session):
session.install("flit")
# TEMP for 3.11
if session.python == "3.11":
env = {
# https://github.com/aio-libs/aiohttp/issues/6600
"AIOHTTP_NO_EXTENSIONS": "1",
# https://github.com/aio-libs/frozenlist/issues/285
"FROZENLIST_NO_EXTENSIONS": "1",
# https://github.com/aio-libs/yarl/issues/680
"YARL_NO_EXTENSIONS": "1",
}
else:
env = {}
session.run("flit", "install", "--deps", "develop", env=env)
session.run("flit", "install", "--deps", "develop")


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"])
def tests(session):
install_flit_dev_deps(session)
session.run("pytest", "--cov=gidgethub", "--cov-report=xml", "-n=auto", "tests")
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ requires = [
"uritemplate>=3.0.1",
"PyJWT[crypto]>=2.4.0"
]
requires-python = ">=3.7"
requires-python = ">=3.8"
license = "Apache"
keywords = "github sans-io async"
description-file = "README.rst"
classifiers = ["Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[tool.flit.metadata.requires-extra]
Expand Down
1 change: 1 addition & 0 deletions tests/samples/convert_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

All keys will be lowercase and the status code will be used for the file name.
"""

import json
import sys

Expand Down
1 change: 0 additions & 1 deletion tests/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ async def test_no_cache(self):


class TestGraphQL:

"""Test gidgethub.abc.GitHubAPI.graphql()."""

def gh_and_response(self, payload_filename):
Expand Down
5 changes: 0 additions & 5 deletions tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def tmp_pathfile(tmpdir, tmp_path, monkeypatch):


class TestWorkspace:

"""Tests for gidgethub.actions.workspace()."""

def test_reading(self, tmp_path, monkeypatch):
Expand All @@ -49,7 +48,6 @@ def test_caching(self, tmp_path, monkeypatch):


class TestEvent:

"""Tests for gidgethub.actions.event()."""

def test_reading(self, tmp_webhook):
Expand All @@ -67,7 +65,6 @@ def test_caching(self, tmp_webhook):


class TestCommand:

"""Tests for gidgethub.actions.command()."""

# https://help.github.com/en/actions/reference/development-tools-for-github-actions#logging-commands
Expand Down Expand Up @@ -123,7 +120,6 @@ def test_resume_command(self, capsys):


class TestSetenv:

"""Tests for gidgethub.actions.setenv()."""

def test_creating(self, tmp_envfile):
Expand Down Expand Up @@ -168,7 +164,6 @@ def test_creating_multiline(self, tmp_envfile):


class TestAddpath:

"""Tests for gidgethub.actions.addpath()."""

def test_string_path(self, tmp_pathfile):
Expand Down
1 change: 0 additions & 1 deletion tests/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class TestGitHubAppUtils:

"""Tests for GitHub App utilities."""

@mock.patch("time.time")
Expand Down
Loading