Skip to content

Tidy tools #1294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 19, 2021
15 changes: 0 additions & 15 deletions .codeclimate.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .coveragerc

This file was deleted.

15 changes: 0 additions & 15 deletions .deepsource.toml

This file was deleted.

32 changes: 32 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
13 changes: 4 additions & 9 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
make -C doc html
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx<2.0
sphinx==4.1.1
sphinx_rtd_theme
sphinx-autodoc-typehints
9 changes: 5 additions & 4 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions mypy.ini

This file was deleted.

35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/*"]
14 changes: 12 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ddt>=1.1.1
coverage
mypy
flake8
virtualenv
pytest
Expand Down
61 changes: 0 additions & 61 deletions tox.ini

This file was deleted.