Skip to content

Miscellaneous CI fixes #1447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
rev: v0.0.283
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ dev-setup:

.PHONY: tests ## Run unit tests
tests:
PYTHONPATH=. py.test graphene_django --cov=graphene_django -vv
PYTHONPATH=. pytest graphene_django --cov=graphene_django -vv

.PHONY: format ## Format code
format:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side suggestion here: perhaps we add back black in the dev_requires dependencies in setup.py (so dev-setup in this Makefile also installs black, since that will likely be useful for folks' editor configurations just like ruff)

black graphene_django examples setup.py

.PHONY: lint ## Lint code
lint:
flake8 graphene_django examples
ruff graphene_django examples

.PHONY: docs ## Generate docs
docs: dev-setup
Expand Down
4 changes: 2 additions & 2 deletions graphene_django/forms/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def get_form_field_description(field):
@singledispatch
def convert_form_field(field):
raise ImproperlyConfigured(
"Don't know how to convert the Django form field {} ({}) "
"to Graphene type".format(field, field.__class__)
f"Don't know how to convert the Django form field {field} ({field.__class__}) "
"to Graphene type"
)


Expand Down
2 changes: 1 addition & 1 deletion graphene_django/management/commands/graphql_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_schema(self, schema, out, indent):
def handle(self, *args, **options):
options_schema = options.get("schema")

if options_schema and type(options_schema) is str:
if options_schema and isinstance(options_schema, str):
module_str, schema_name = options_schema.rsplit(".", 1)
mod = importlib.import_module(module_str)
schema = getattr(mod, schema_name)
Expand Down
4 changes: 2 additions & 2 deletions graphene_django/rest_framework/serializer_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@singledispatch
def get_graphene_type_from_serializer_field(field):
raise ImproperlyConfigured(
"Don't know how to convert the serializer field {} ({}) "
"to Graphene type".format(field, field.__class__)
f"Don't know how to convert the serializer field {field} ({field.__class__}) "
"to Graphene type"
)


Expand Down
12 changes: 6 additions & 6 deletions graphene_django/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def __init_subclass_with_meta__(
registry = get_global_registry()

assert isinstance(registry, Registry), (
"The attribute registry in {} needs to be an instance of "
'Registry, received "{}".'
).format(cls.__name__, registry)
f"The attribute registry in {cls.__name__} needs to be an instance of "
f'Registry, received "{registry}".'
)

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

assert not (fields and exclude), (
"Cannot set both 'fields' and 'exclude' options on "
"DjangoObjectType {class_name}.".format(class_name=cls.__name__)
f"DjangoObjectType {cls.__name__}."
)

# Alias only_fields -> fields
Expand Down Expand Up @@ -214,8 +214,8 @@ def __init_subclass_with_meta__(
warnings.warn(
"Creating a DjangoObjectType without either the `fields` "
"or the `exclude` option is deprecated. Add an explicit `fields "
"= '__all__'` option on DjangoObjectType {class_name} to use all "
"fields".format(class_name=cls.__name__),
f"= '__all__'` option on DjangoObjectType {cls.__name__} to use all "
"fields",
DeprecationWarning,
stacklevel=2,
)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@


dev_requires = [
"ruff",
"black==23.7.0",
"ruff==0.0.283",
"pre-commit",
] + tests_require

Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
envlist =
py{38,39,310}-django32,
py{38,39,310}-django{41,42,main},
py311-django{41,42,main}
py{38,39,310}-django32
py{38,39}-django{41,42}
py{310,311}-django{41,42,main}
pre-commit

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

[testenv:pre-commit]
skip_install = true
deps = pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure
pre-commit run {posargs:--all-files --show-diff-on-failure}