mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-27 20:13:44 +03:00
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
This commit is contained in:
parent
db34d2e815
commit
79b4a23ae0
|
@ -20,7 +20,7 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.0.282
|
rev: v0.0.283
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
|
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -10,7 +10,7 @@ dev-setup:
|
||||||
|
|
||||||
.PHONY: tests ## Run unit tests
|
.PHONY: tests ## Run unit tests
|
||||||
tests:
|
tests:
|
||||||
PYTHONPATH=. py.test graphene_django --cov=graphene_django -vv
|
PYTHONPATH=. pytest graphene_django --cov=graphene_django -vv
|
||||||
|
|
||||||
.PHONY: format ## Format code
|
.PHONY: format ## Format code
|
||||||
format:
|
format:
|
||||||
|
@ -18,7 +18,7 @@ format:
|
||||||
|
|
||||||
.PHONY: lint ## Lint code
|
.PHONY: lint ## Lint code
|
||||||
lint:
|
lint:
|
||||||
flake8 graphene_django examples
|
ruff graphene_django examples
|
||||||
|
|
||||||
.PHONY: docs ## Generate docs
|
.PHONY: docs ## Generate docs
|
||||||
docs: dev-setup
|
docs: dev-setup
|
||||||
|
|
|
@ -27,8 +27,8 @@ def get_form_field_description(field):
|
||||||
@singledispatch
|
@singledispatch
|
||||||
def convert_form_field(field):
|
def convert_form_field(field):
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"Don't know how to convert the Django form field {} ({}) "
|
f"Don't know how to convert the Django form field {field} ({field.__class__}) "
|
||||||
"to Graphene type".format(field, field.__class__)
|
"to Graphene type"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Command(CommandArguments):
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
options_schema = options.get("schema")
|
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)
|
module_str, schema_name = options_schema.rsplit(".", 1)
|
||||||
mod = importlib.import_module(module_str)
|
mod = importlib.import_module(module_str)
|
||||||
schema = getattr(mod, schema_name)
|
schema = getattr(mod, schema_name)
|
||||||
|
|
|
@ -13,8 +13,8 @@ from .types import DictType
|
||||||
@singledispatch
|
@singledispatch
|
||||||
def get_graphene_type_from_serializer_field(field):
|
def get_graphene_type_from_serializer_field(field):
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"Don't know how to convert the serializer field {} ({}) "
|
f"Don't know how to convert the serializer field {field} ({field.__class__}) "
|
||||||
"to Graphene type".format(field, field.__class__)
|
"to Graphene type"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,9 @@ class DjangoObjectType(ObjectType):
|
||||||
registry = get_global_registry()
|
registry = get_global_registry()
|
||||||
|
|
||||||
assert isinstance(registry, Registry), (
|
assert isinstance(registry, Registry), (
|
||||||
"The attribute registry in {} needs to be an instance of "
|
f"The attribute registry in {cls.__name__} needs to be an instance of "
|
||||||
'Registry, received "{}".'
|
f'Registry, received "{registry}".'
|
||||||
).format(cls.__name__, registry)
|
)
|
||||||
|
|
||||||
if filter_fields and filterset_class:
|
if filter_fields and filterset_class:
|
||||||
raise Exception("Can't set both filter_fields and filterset_class")
|
raise Exception("Can't set both filter_fields and filterset_class")
|
||||||
|
@ -175,7 +175,7 @@ class DjangoObjectType(ObjectType):
|
||||||
|
|
||||||
assert not (fields and exclude), (
|
assert not (fields and exclude), (
|
||||||
"Cannot set both 'fields' and 'exclude' options on "
|
"Cannot set both 'fields' and 'exclude' options on "
|
||||||
"DjangoObjectType {class_name}.".format(class_name=cls.__name__)
|
f"DjangoObjectType {cls.__name__}."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Alias only_fields -> fields
|
# Alias only_fields -> fields
|
||||||
|
@ -214,8 +214,8 @@ class DjangoObjectType(ObjectType):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"Creating a DjangoObjectType without either the `fields` "
|
"Creating a DjangoObjectType without either the `fields` "
|
||||||
"or the `exclude` option is deprecated. Add an explicit `fields "
|
"or the `exclude` option is deprecated. Add an explicit `fields "
|
||||||
"= '__all__'` option on DjangoObjectType {class_name} to use all "
|
f"= '__all__'` option on DjangoObjectType {cls.__name__} to use all "
|
||||||
"fields".format(class_name=cls.__name__),
|
"fields",
|
||||||
DeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=2,
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -26,7 +26,8 @@ tests_require = [
|
||||||
|
|
||||||
|
|
||||||
dev_requires = [
|
dev_requires = [
|
||||||
"ruff",
|
"black==23.7.0",
|
||||||
|
"ruff==0.0.283",
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
] + tests_require
|
] + tests_require
|
||||||
|
|
||||||
|
|
10
tox.ini
10
tox.ini
|
@ -1,8 +1,8 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
py{38,39,310}-django32,
|
py{38,39,310}-django32
|
||||||
py{38,39,310}-django{41,42,main},
|
py{38,39}-django{41,42}
|
||||||
py311-django{41,42,main}
|
py{310,311}-django{41,42,main}
|
||||||
pre-commit
|
pre-commit
|
||||||
|
|
||||||
[gh-actions]
|
[gh-actions]
|
||||||
|
@ -32,10 +32,10 @@ deps =
|
||||||
django41: Django>=4.1,<4.2
|
django41: Django>=4.1,<4.2
|
||||||
django42: Django>=4.2,<4.3
|
django42: Django>=4.2,<4.3
|
||||||
djangomain: https://github.com/django/django/archive/main.zip
|
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]
|
[testenv:pre-commit]
|
||||||
skip_install = true
|
skip_install = true
|
||||||
deps = pre-commit
|
deps = pre-commit
|
||||||
commands =
|
commands =
|
||||||
pre-commit run --all-files --show-diff-on-failure
|
pre-commit run {posargs:--all-files --show-diff-on-failure}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user