diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index e658e6785..000000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -engines: - duplication: - enabled: true - config: - languages: - - python - pep8: - enabled: true - radon: - enabled: true -ratings: - paths: - - "**.py" -exclude_paths: diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index e2b6256e9..000000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -source = git - -; to make nosetests happy -[report] -include = */git/* -omit = */git/ext/* diff --git a/.deepsource.toml b/.deepsource.toml deleted file mode 100644 index d55288b87..000000000 --- a/.deepsource.toml +++ /dev/null @@ -1,15 +0,0 @@ -version = 1 - -test_patterns = [ - 'test/**/test_*.py' -] - -exclude_patterns = [ - 'doc/**', - 'etc/sublime-text' -] - -[[analyzers]] -name = 'python' -enabled = true -runtime_version = '3.x.x' diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..ffa60483d --- /dev/null +++ b/.flake8 @@ -0,0 +1,32 @@ +[flake8] +show-source = True +count= True +statistics = True +# E265 = comment blocks like @{ section, which it can't handle +# E266 = too many leading '#' for block comment +# E731 = do not assign a lambda expression, use a def +# W293 = Blank line contains whitespace +# W504 = Line break after operator +# E704 = multiple statements in one line - used for @override +# TC002 = +# ANN = flake8-annotations +# TC, TC2 = flake8-type-checking +# D = flake8-docstrings + +# select = C,E,F,W ANN, TC, TC2 # to enable code. Disabled if not listed, including builtin codes +enable-extensions = TC, TC2 # only needed for extensions not enabled by default + +ignore = E265,E266,E731,E704, + W293, W504, + ANN0 ANN1 ANN2, + TC0, TC1, TC2 + # B, + A, + D, + RST, RST3 +max-line-length = 120 + +exclude = .tox,.venv,build,dist,doc,git/ext/,test + +rst-roles = # for flake8-RST-docstrings + attr,class,func,meth,mod,obj,ref,term,var # used by sphinx diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 115610f35..bf712b2d8 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-beta.3"] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-beta.4"] steps: - uses: actions/checkout@v2 @@ -46,26 +46,21 @@ jobs: - name: Lint with flake8 run: | set -x - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 --ignore=W293,E265,E266,W503,W504,E704,E731 --count --show-source --statistics + flake8 - name: Check types with mypy run: | set -x - pip install mypy mypy -p git - name: Test with pytest run: | set -x - pip install -r requirements-dev.txt - pytest --cov --cov-report=term - # pytest settings in tox.ini[pytest] + pytest continue-on-error: false - name: Documentation run: | set -x pip install -r doc/requirements.txt - make -C doc html \ No newline at end of file + make -C doc html diff --git a/README.md b/README.md index 0f7ac5ea4..ad7aae516 100644 --- a/README.md +++ b/README.md @@ -106,18 +106,20 @@ On *Windows*, make sure you have `git-daemon` in your PATH. For MINGW-git, the exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine with MINGW's. -The easiest way to run tests is by using [tox](https://pypi.python.org/pypi/tox) -a wrapper around virtualenv. It will take care of setting up environments with the proper -dependencies installed and execute test commands. To install it simply: +Ensure testing libraries are installed. In the root directory, run: `pip install test-requirements.txt` +Then, - pip install tox +To lint, run `flake8` +To typecheck, run `mypy -p git` +To test, `pytest` -Then run: +Configuration for flake8 is in root/.flake8 file. +Configuration for mypy, pytest, coverage is in root/pyproject.toml. - tox +The same linting and testing will also be performed against different supported python versions +upon submitting a pull request (or on each push if you have a fork with a "main" branch). -For more fine-grained control, you can use `unittest`. ### Contributions diff --git a/doc/requirements.txt b/doc/requirements.txt index 98e5c06a0..20598a39c 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,2 +1,3 @@ -sphinx<2.0 +sphinx==4.1.1 sphinx_rtd_theme +sphinx-autodoc-typehints diff --git a/doc/source/conf.py b/doc/source/conf.py index 0ec64179e..286058fdc 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -14,7 +14,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys +import os # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it @@ -50,7 +51,7 @@ # built documents. # # The short X.Y version. -with open(os.path.join(os.path.dirname(__file__),"..", "..", 'VERSION')) as fd: +with open(os.path.join(os.path.dirname(__file__), "..", "..", 'VERSION')) as fd: VERSION = fd.readline().strip() version = VERSION # The full version, including alpha/beta/rc tags. @@ -170,8 +171,8 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ - ('index', 'GitPython.tex', ur'GitPython Documentation', - ur'Michael Trier', 'manual'), + ('index', 'GitPython.tex', r'GitPython Documentation', + r'Michael Trier', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 67397d40f..000000000 --- a/mypy.ini +++ /dev/null @@ -1,14 +0,0 @@ - -[mypy] - -# TODO: enable when we've fully annotated everything -# disallow_untyped_defs = True -no_implicit_optional = True -warn_redundant_casts = True -# warn_unused_ignores = True -# warn_unreachable = True -pretty = True - -# TODO: remove when 'gitdb' is fully annotated -[mypy-gitdb.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..79e628404 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,35 @@ +[tool.pytest.ini_options] +python_files = 'test_*.py' +testpaths = 'test' # space seperated list of paths from root e.g test tests doc/testing +addopts = '--cov=git --cov-report=term --maxfail=10 --force-sugar --disable-warnings' +filterwarnings = 'ignore::DeprecationWarning' +# --cov coverage +# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml +# --cov-report term-missing # to terminal with line numbers +# --cov-report html:path # html file at path +# --maxfail # number of errors before giving up +# -disable-warnings # Disable pytest warnings (not codebase warnings) +# -rf # increased reporting of failures +# -rE # increased reporting of errors +# --ignore-glob=**/gitdb/* # ignore glob paths +# filterwarnings ignore::WarningType # ignores those warnings + +[tool.mypy] +# disallow_untyped_defs = True +no_implicit_optional = true +warn_redundant_casts = true +# warn_unused_ignores = True +# warn_unreachable = True +show_error_codes = true + +# TODO: remove when 'gitdb' is fully annotated +[[tool.mypy.overrides]] +module = "gitdb.*" +ignore_missing_imports = true + +[tool.coverage.run] +source = ["git"] + +[tool.coverage.report] +include = ["*/git/*"] +omit = ["*/git/ext/*"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 6644bacde..0ece0a659 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,17 @@ -r requirements.txt -r test-requirements.txt -pytest -pytest-cov +# libraries for additional local testing/linting - to be added to test-requirements.txt when all pass + +flake8-bugbear +flake8-comprehensions +flake8-type-checking;python_version>="3.8" # checks for TYPE_CHECKING only imports +# flake8-annotations # checks for presence of type annotations +# flake8-rst-docstrings # checks docstrings are valid RST +# flake8-builtins # warns about shadowing builtin names +# flake8-pytest-style + +# pytest-flake8 pytest-sugar pytest-icdiff +# pytest-profiling diff --git a/test-requirements.txt b/test-requirements.txt index c5be39a2d..7397c3732 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,5 @@ ddt>=1.1.1 -coverage +mypy flake8 virtualenv pytest diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 7231f0459..000000000 --- a/tox.ini +++ /dev/null @@ -1,61 +0,0 @@ -[tox] -envlist = py36,py37,py38,py39,flake8 - -[testenv] -commands = python -m unittest --buffer {posargs} -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -passenv = HOME - -[testenv:cover] -commands = coverage run --omit="git/test/*" -m unittest --buffer {posargs} - coverage report - -[testenv:flake8] -commands = flake8 --ignore=W293,E265,E266,W503,W504,E704,E731 {posargs} - -[testenv:type] -description = type check ourselves -deps = - {[testenv]deps} - mypy -commands = - mypy -p git - -[testenv:venv] -commands = {posargs} - -[flake8] -#show-source = True -# E265 = comment blocks like @{ section, which it can't handle -# E266 = too many leading '#' for block comment -# E731 = do not assign a lambda expression, use a def -# W293 = Blank line contains whitespace -# W504 = Line break after operator -# E707 = multiple statements in one line - used for @overloads -ignore = E265,W293,E266,E731,E704, W504 -max-line-length = 120 -exclude = .tox,.venv,build,dist,doc,git/ext/ - -[pytest] -python_files = - test_*.py - -# space seperated list of paths from root e.g test tests doc/testing -testpaths = test - -# --cov coverage -# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml -# --cov-report term-missing # to terminal with line numbers -# --cov-report html:path # html file at path -# --maxfail # number of errors before giving up -# -disable-warnings # Disable pytest warnings (not codebase warnings) -#-rf # increased reporting of failures -# -rE # increased reporting of errors -# --ignore-glob=**/gitdb/* # ignore glob paths -addopts = --cov=git --cov-report=term --maxfail=50 -rf --verbosity=0 --disable-warnings - -# ignore::WarningType # ignores those warnings -# error # turn any unignored warning into errors -filterwarnings = - ignore::DeprecationWarning