Skip to content

Run everything through 'black' #1442

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 10 commits into from
May 18, 2022
Merged
Prev Previous commit
Next Next commit
Revert "Remove flake8 linting in favor of black formatting"
This reverts commit a7c5d88.
  • Loading branch information
Byron committed May 17, 2022
commit b4b238057e7913c93245b484bdd50131dafd71f3
35 changes: 35 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[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 = move third party import to TYPE_CHECKING
# 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,
TC002,
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

min-python-version = 3.7.0
4 changes: 2 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig

- name: Lint with Black
- name: Lint with flake8
run: |
set -x
black --check .
flake8

- name: Check types with mypy
# With new versions of pypi new issues might arise. This is a problem if there is nobody able to fix them,
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ with MINGW's.
Ensure testing libraries are installed.
In the root directory, run: `pip install -r test-requirements.txt`

To lint, run: `flake8`

To typecheck, run: `mypy -p git`

To test, run: `pytest`

Configurations for mypy, pytest and coverage.py are in ./pyproject.toml.
Configuration for flake8 is in the ./.flake8 file.

Run `black` for formatting.
Configurations for mypy, pytest and coverage.py are in ./pyproject.toml.

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 and actions enabled).
Expand Down
1 change: 1 addition & 0 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
# flake8: noqa
# @PydevCodeAnalysisIgnore
from git.exc import * # @NoMove @IgnorePep8
import inspect
Expand Down
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def execute(
)
else:
cmd_not_found_exception = (
FileNotFoundError
FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
)
# end handle

Expand Down
1 change: 1 addition & 0 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
"""utilities to help provide compatibility with python 3"""
# flake8: noqa

import locale
import os
Expand Down
1 change: 1 addition & 0 deletions git/index/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Initialize the index package"""
# flake8: noqa
from .base import *
from .typ import *
1 change: 1 addition & 0 deletions git/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Import all submodules main classes into the package space
"""
# flake8: noqa
import inspect

from .base import *
Expand Down
1 change: 1 addition & 0 deletions git/refs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
# import all modules in order, fix the names they require
from .symbolic import *
from .reference import *
Expand Down
1 change: 1 addition & 0 deletions git/repo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Initialize the Repo package"""
# flake8: noqa
from .base import Repo as Repo
7 changes: 7 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

# libraries for additional local testing/linting - to be added to test-requirements.txt when all pass

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-icdiff
# pytest-profiling

Expand Down
5 changes: 4 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ddt>=1.1.1, !=1.4.3
mypy

black
flake8
flake8-bugbear
flake8-comprehensions
flake8-typing-imports

virtualenv

Expand Down