mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-10 19:57:15 +03:00
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:
parent
91c1278d1a
commit
692540cc78
2
Makefile
2
Makefile
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
27
setup.cfg
27
setup.cfg
|
@ -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/*
|
||||||
|
|
8
setup.py
8
setup.py
|
@ -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",
|
||||||
|
|
6
tox.ini
6
tox.ini
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user