Skip to content

Commit 79b4a23

Browse files
authored
Miscellaneous CI fixes (#1447)
* Update Makefile * django master requires at least python 3.10 now * Allow customizing options passed to tox -e pre-commit * py.test -> pytest * Update ruff * Fix E721 Do not compare types, use `isinstance()` * Add back black to dev dependencies * Pin black and ruff versions
1 parent db34d2e commit 79b4a23

File tree

8 files changed

+21
-20
lines changed

8 files changed

+21
-20
lines changed

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
hooks:
2121
- id: black
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.0.282
23+
rev: v0.0.283
2424
hooks:
2525
- id: ruff
2626
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ dev-setup:
1010

1111
.PHONY: tests ## Run unit tests
1212
tests:
13-
PYTHONPATH=. py.test graphene_django --cov=graphene_django -vv
13+
PYTHONPATH=. pytest graphene_django --cov=graphene_django -vv
1414

1515
.PHONY: format ## Format code
1616
format:
1717
black graphene_django examples setup.py
1818

1919
.PHONY: lint ## Lint code
2020
lint:
21-
flake8 graphene_django examples
21+
ruff graphene_django examples
2222

2323
.PHONY: docs ## Generate docs
2424
docs: dev-setup

Diff for: graphene_django/forms/converter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def get_form_field_description(field):
2727
@singledispatch
2828
def convert_form_field(field):
2929
raise ImproperlyConfigured(
30-
"Don't know how to convert the Django form field {} ({}) "
31-
"to Graphene type".format(field, field.__class__)
30+
f"Don't know how to convert the Django form field {field} ({field.__class__}) "
31+
"to Graphene type"
3232
)
3333

3434

Diff for: graphene_django/management/commands/graphql_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_schema(self, schema, out, indent):
8383
def handle(self, *args, **options):
8484
options_schema = options.get("schema")
8585

86-
if options_schema and type(options_schema) is str:
86+
if options_schema and isinstance(options_schema, str):
8787
module_str, schema_name = options_schema.rsplit(".", 1)
8888
mod = importlib.import_module(module_str)
8989
schema = getattr(mod, schema_name)

Diff for: graphene_django/rest_framework/serializer_converter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
@singledispatch
1414
def get_graphene_type_from_serializer_field(field):
1515
raise ImproperlyConfigured(
16-
"Don't know how to convert the serializer field {} ({}) "
17-
"to Graphene type".format(field, field.__class__)
16+
f"Don't know how to convert the serializer field {field} ({field.__class__}) "
17+
"to Graphene type"
1818
)
1919

2020

Diff for: graphene_django/types.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def __init_subclass_with_meta__(
160160
registry = get_global_registry()
161161

162162
assert isinstance(registry, Registry), (
163-
"The attribute registry in {} needs to be an instance of "
164-
'Registry, received "{}".'
165-
).format(cls.__name__, registry)
163+
f"The attribute registry in {cls.__name__} needs to be an instance of "
164+
f'Registry, received "{registry}".'
165+
)
166166

167167
if filter_fields and filterset_class:
168168
raise Exception("Can't set both filter_fields and filterset_class")
@@ -175,7 +175,7 @@ def __init_subclass_with_meta__(
175175

176176
assert not (fields and exclude), (
177177
"Cannot set both 'fields' and 'exclude' options on "
178-
"DjangoObjectType {class_name}.".format(class_name=cls.__name__)
178+
f"DjangoObjectType {cls.__name__}."
179179
)
180180

181181
# Alias only_fields -> fields
@@ -214,8 +214,8 @@ def __init_subclass_with_meta__(
214214
warnings.warn(
215215
"Creating a DjangoObjectType without either the `fields` "
216216
"or the `exclude` option is deprecated. Add an explicit `fields "
217-
"= '__all__'` option on DjangoObjectType {class_name} to use all "
218-
"fields".format(class_name=cls.__name__),
217+
f"= '__all__'` option on DjangoObjectType {cls.__name__} to use all "
218+
"fields",
219219
DeprecationWarning,
220220
stacklevel=2,
221221
)

Diff for: setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727

2828
dev_requires = [
29-
"ruff",
29+
"black==23.7.0",
30+
"ruff==0.0.283",
3031
"pre-commit",
3132
] + tests_require
3233

Diff for: tox.ini

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tox]
22
envlist =
3-
py{38,39,310}-django32,
4-
py{38,39,310}-django{41,42,main},
5-
py311-django{41,42,main}
3+
py{38,39,310}-django32
4+
py{38,39}-django{41,42}
5+
py{310,311}-django{41,42,main}
66
pre-commit
77

88
[gh-actions]
@@ -32,10 +32,10 @@ deps =
3232
django41: Django>=4.1,<4.2
3333
django42: Django>=4.2,<4.3
3434
djangomain: https://github.com/django/django/archive/main.zip
35-
commands = {posargs:py.test --cov=graphene_django graphene_django examples}
35+
commands = {posargs:pytest --cov=graphene_django graphene_django examples}
3636

3737
[testenv:pre-commit]
3838
skip_install = true
3939
deps = pre-commit
4040
commands =
41-
pre-commit run --all-files --show-diff-on-failure
41+
pre-commit run {posargs:--all-files --show-diff-on-failure}

0 commit comments

Comments
 (0)