Skip to content

Commit 692540c

Browse files
authored
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
1 parent 91c1278 commit 692540c

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test: tests # Alias test -> tests
1414

1515
.PHONY: format
1616
format:
17-
black --exclude "/migrations/" graphene_django examples
17+
black --exclude "/migrations/" graphene_django examples setup.py
1818

1919
.PHONY: lint
2020
lint:

graphene_django/filter/tests/test_fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,14 @@ class Query(ObjectType):
321321
pub_date=datetime.now(),
322322
pub_date_time=datetime.now(),
323323
reporter=r1,
324+
editor=r1,
324325
)
325326
Article.objects.create(
326327
headline="a2",
327328
pub_date=datetime.now(),
328329
pub_date_time=datetime.now(),
329330
reporter=r2,
331+
editor=r2,
330332
)
331333

332334
query = """
@@ -450,7 +452,7 @@ class Meta:
450452
assert multiple_filter.field_class == GlobalIDMultipleChoiceField
451453

452454

453-
def test_filter_filterset_related_results():
455+
def test_filter_filterset_related_results_with_filter():
454456
class ReporterFilterNode(DjangoObjectType):
455457
class Meta:
456458
model = Reporter

graphene_django/rest_framework/mutation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init_subclass_with_meta__(
5252
lookup_field=None,
5353
serializer_class=None,
5454
model_class=None,
55-
model_operations=["create", "update"],
55+
model_operations=("create", "update"),
5656
only_fields=(),
5757
exclude_fields=(),
5858
**options

setup.cfg

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,33 @@ test=pytest
55
universal=1
66

77
[flake8]
8-
exclude = setup.py,docs/*,examples/*,tests,graphene_django/debug/sql/*
8+
exclude = docs,graphene_django/debug/sql/*,migrations
99
max-line-length = 120
10+
select =
11+
# Dictionary key repeated
12+
F601,
13+
# Ensure use of ==/!= to compare with str, bytes and int literals
14+
F632,
15+
# Redefinition of unused name
16+
F811,
17+
# Using an undefined variable
18+
F821,
19+
# Defining an undefined variable in __all__
20+
F822,
21+
# Using a variable before it is assigned
22+
F823,
23+
# Duplicate argument in function declaration
24+
F831,
25+
# Black would format this line
26+
BLK,
27+
# Do not use bare except
28+
B001,
29+
# Don't allow ++n. You probably meant n += 1
30+
B002,
31+
# Do not use mutable structures for argument defaults
32+
B006,
33+
# Do not perform calls in argument defaults
34+
B008
1035

1136
[coverage:run]
1237
omit = */tests/*

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
dev_requires = [
2929
"black==19.3b0",
3030
"flake8==3.7.7",
31+
"flake8-black==0.1.0",
32+
"flake8-bugbear==19.3.0",
3133
] + tests_require
3234

3335
setup(
@@ -64,7 +66,11 @@
6466
setup_requires=["pytest-runner"],
6567
tests_require=tests_require,
6668
rest_framework_require=rest_framework_require,
67-
extras_require={"test": tests_require, "rest_framework": rest_framework_require, "dev": dev_requires},
69+
extras_require={
70+
"test": tests_require,
71+
"rest_framework": rest_framework_require,
72+
"dev": dev_requires,
73+
},
6874
include_package_data=True,
6975
zip_safe=False,
7076
platforms="any",

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ commands = {posargs:py.test --cov=graphene_django graphene_django examples}
2828

2929
[testenv:black]
3030
basepython = python3.7
31-
deps = black
31+
deps = -e.[dev]
3232
commands =
33-
black --exclude "/migrations/" graphene_django examples --check
33+
black --exclude "/migrations/" graphene_django examples setup.py --check
3434

3535
[testenv:flake8]
3636
basepython = python3.7
37-
deps = flake8
37+
deps = -e.[dev]
3838
commands =
3939
flake8 graphene_django examples

0 commit comments

Comments
 (0)