diff --git a/.isort.cfg b/.isort.cfg index 043be517..6154c80f 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -4,5 +4,5 @@ include_trailing_comma=True force_grid_wrap=0 use_parentheses=True line_length=88 -known_third_party=deprecated,httpretty,jwt,requests,setuptools,urllib3 +known_third_party=deprecated,httpretty,jwt,pytest,requests,setuptools,urllib3 known_first_party=github diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84d3cbae..36c7c1ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,8 +16,3 @@ repos: rev: 3.7.9 hooks: - id: flake8 - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 - hooks: - - id: end-of-file-fixer - - id: trailing-whitespace diff --git a/.travis.yml b/.travis.yml index 9b9c91bf..5da9640d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python matrix: include: + - env: TOXENV=lint - python: 3.5 env: TOXENV=py35 - python: 3.6 @@ -9,9 +10,7 @@ matrix: env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 - - env: TOXENV=flake8 - - env: TOXENV=isort - - env: TOXENV=black + - env: TOXENV=docs install: - pip install tox script: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 91799093..235cd0db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ PyGithub adopts the black coding style and uses isort to sort imports. To manually format the code: ``` -tox -e format +tox -e lint ``` ## Pre-commit plugin @@ -106,7 +106,7 @@ You may also want to investigate `tox` to run tests: ``` pip install tox -tox -epy36,flake8,black,isort +tox -epy36 ``` ## Build documentation locally diff --git a/github/GithubException.pyi b/github/GithubException.pyi index ff70e5b0..ffb91bd0 100644 --- a/github/GithubException.pyi +++ b/github/GithubException.pyi @@ -33,3 +33,11 @@ class GithubException: def data(self) -> Dict[str, Union[str, List[str], List[Dict[str, str]]]]: ... @property def status(self) -> int: ... + +class IncompletableObject: + def __init__(self, status: Union[int, str], data: Any,) -> None: ... + def __str__(self) -> str: ... + @property + def data(self) -> Dict[str, Union[str, List[str], List[Dict[str, str]]]]: ... + @property + def status(self) -> int: ... diff --git a/tests/Connection.py b/tests/Connection.py index e2cd218c..6f7f878f 100644 --- a/tests/Connection.py +++ b/tests/Connection.py @@ -27,9 +27,8 @@ import itertools from io import StringIO from unittest.mock import Mock -import httpretty - -import pytest +import httpretty # type: ignore +import pytest # type: ignore from . import Framework diff --git a/tests/Retry.py b/tests/Retry.py index a3a21e0e..87034e2f 100644 --- a/tests/Retry.py +++ b/tests/Retry.py @@ -27,8 +27,8 @@ ################################################################################ import requests -import urllib3 -from httpretty import httpretty +import urllib3 # type: ignore +from httpretty import httpretty # type: ignore import github diff --git a/tox.ini b/tox.ini index 83e104ea..2b57cc78 100644 --- a/tox.ini +++ b/tox.ini @@ -1,41 +1,24 @@ [tox] envlist = + lint, py{35,36,37,38}, - flake8, - isort, - black + docs [testenv] deps = -rtest-requirements.txt commands = pytest --cov=github {posargs} -[testenv:flake8] -basepython = python3.6 -skip_install = true -deps = flake8 -commands = flake8 github tests scripts setup.py - -[testenv:isort] -basepython = python3.6 -skip_install = true -deps = isort -commands = isort --check -rc github tests scripts setup.py - -[testenv:black] -basepython = python3.6 -skip_install = true -deps = black -commands = black --check --diff github tests scripts setup.py - -[testenv:format] +[testenv:lint] basepython = python3.6 skip_install = true deps = - black - isort + pre-commit + mypy commands = - isort -rc github tests scripts setup.py - black github tests scripts setup.py + pre-commit run --all-files --show-diff-on-failure + ; Run mypy outside pre-commit because pre-commit runs mypy in a venv + ; that doesn't have dependencies or their type annotations installed. + mypy github/ tests/ [testenv:docs] basepython = python3.6