Update flake8 (#688)

* Include setup.py in black formatting

* Add new flake8 plugins and update errors to look for

* Fix duplicate test name

* Don't use mutable data structure

* Install all dev dependencies for flake8 and black tox envs
This commit is contained in:
Jonathan Kim 2019-06-24 18:55:44 +01:00 committed by GitHub
parent 91c1278d1a
commit 692540cc78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 8 deletions

View File

@ -14,7 +14,7 @@ test: tests # Alias test -> tests
.PHONY: format .PHONY: format
format: format:
black --exclude "/migrations/" graphene_django examples black --exclude "/migrations/" graphene_django examples setup.py
.PHONY: lint .PHONY: lint
lint: lint:

View File

@ -321,12 +321,14 @@ def test_filter_filterset_related_results():
pub_date=datetime.now(), pub_date=datetime.now(),
pub_date_time=datetime.now(), pub_date_time=datetime.now(),
reporter=r1, reporter=r1,
editor=r1,
) )
Article.objects.create( Article.objects.create(
headline="a2", headline="a2",
pub_date=datetime.now(), pub_date=datetime.now(),
pub_date_time=datetime.now(), pub_date_time=datetime.now(),
reporter=r2, reporter=r2,
editor=r2,
) )
query = """ query = """
@ -450,7 +452,7 @@ def test_global_id_multiple_field_explicit_reverse():
assert multiple_filter.field_class == GlobalIDMultipleChoiceField assert multiple_filter.field_class == GlobalIDMultipleChoiceField
def test_filter_filterset_related_results(): def test_filter_filterset_related_results_with_filter():
class ReporterFilterNode(DjangoObjectType): class ReporterFilterNode(DjangoObjectType):
class Meta: class Meta:
model = Reporter model = Reporter

View File

@ -52,7 +52,7 @@ class SerializerMutation(ClientIDMutation):
lookup_field=None, lookup_field=None,
serializer_class=None, serializer_class=None,
model_class=None, model_class=None,
model_operations=["create", "update"], model_operations=("create", "update"),
only_fields=(), only_fields=(),
exclude_fields=(), exclude_fields=(),
**options **options

View File

@ -5,8 +5,33 @@ test=pytest
universal=1 universal=1
[flake8] [flake8]
exclude = setup.py,docs/*,examples/*,tests,graphene_django/debug/sql/* exclude = docs,graphene_django/debug/sql/*,migrations
max-line-length = 120 max-line-length = 120
select =
# Dictionary key repeated
F601,
# Ensure use of ==/!= to compare with str, bytes and int literals
F632,
# Redefinition of unused name
F811,
# Using an undefined variable
F821,
# Defining an undefined variable in __all__
F822,
# Using a variable before it is assigned
F823,
# Duplicate argument in function declaration
F831,
# Black would format this line
BLK,
# Do not use bare except
B001,
# Don't allow ++n. You probably meant n += 1
B002,
# Do not use mutable structures for argument defaults
B006,
# Do not perform calls in argument defaults
B008
[coverage:run] [coverage:run]
omit = */tests/* omit = */tests/*

View File

@ -28,6 +28,8 @@ tests_require = [
dev_requires = [ dev_requires = [
"black==19.3b0", "black==19.3b0",
"flake8==3.7.7", "flake8==3.7.7",
"flake8-black==0.1.0",
"flake8-bugbear==19.3.0",
] + tests_require ] + tests_require
setup( setup(
@ -64,7 +66,11 @@ setup(
setup_requires=["pytest-runner"], setup_requires=["pytest-runner"],
tests_require=tests_require, tests_require=tests_require,
rest_framework_require=rest_framework_require, rest_framework_require=rest_framework_require,
extras_require={"test": tests_require, "rest_framework": rest_framework_require, "dev": dev_requires}, extras_require={
"test": tests_require,
"rest_framework": rest_framework_require,
"dev": dev_requires,
},
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
platforms="any", platforms="any",

View File

@ -28,12 +28,12 @@ commands = {posargs:py.test --cov=graphene_django graphene_django examples}
[testenv:black] [testenv:black]
basepython = python3.7 basepython = python3.7
deps = black deps = -e.[dev]
commands = commands =
black --exclude "/migrations/" graphene_django examples --check black --exclude "/migrations/" graphene_django examples setup.py --check
[testenv:flake8] [testenv:flake8]
basepython = python3.7 basepython = python3.7
deps = flake8 deps = -e.[dev]
commands = commands =
flake8 graphene_django examples flake8 graphene_django examples