Browse Source

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
pull/681/head
Jonathan Kim 3 years ago committed by GitHub
parent
commit
692540cc78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Makefile
  2. 4
      graphene_django/filter/tests/test_fields.py
  3. 2
      graphene_django/rest_framework/mutation.py
  4. 27
      setup.cfg
  5. 8
      setup.py
  6. 6
      tox.ini

2
Makefile

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

4
graphene_django/filter/tests/test_fields.py

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

2
graphene_django/rest_framework/mutation.py

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

27
setup.cfg

@ -5,8 +5,33 @@ test=pytest
universal=1
[flake8]
exclude = setup.py,docs/*,examples/*,tests,graphene_django/debug/sql/*
exclude = docs,graphene_django/debug/sql/*,migrations
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]
omit = */tests/*

8
setup.py

@ -28,6 +28,8 @@ tests_require = [
dev_requires = [
"black==19.3b0",
"flake8==3.7.7",
"flake8-black==0.1.0",
"flake8-bugbear==19.3.0",
] + tests_require
setup(
@ -64,7 +66,11 @@ setup(
setup_requires=["pytest-runner"],
tests_require=tests_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,
zip_safe=False,
platforms="any",

6
tox.ini

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

Loading…
Cancel
Save