chore: update dev dependencies (#1345)

Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
This commit is contained in:
Thomas Leonard 2022-09-22 10:26:21 +01:00 committed by GitHub
parent 8ae576394e
commit 42a40b4df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 72 additions and 50 deletions

View File

@ -1,22 +1,21 @@
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@grep -E '^\.PHONY: [a-zA-Z_-]+ .*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: |##)"}; {printf "\033[36m%-30s\033[0m %s\n", $$2, $$3}'
.PHONY: dev-setup ## Install development dependencies .PHONY: dev-setup ## Install development dependencies
dev-setup: dev-setup:
pip install -e ".[dev]" pip install -e ".[dev]"
.PHONY: install-dev .PHONY: tests ## Run unit tests
install-dev: dev-setup # Alias install-dev -> dev-setup
.PHONY: tests
tests: tests:
py.test graphene_django --cov=graphene_django -vv py.test graphene_django --cov=graphene_django -vv
.PHONY: test .PHONY: format ## Format code
test: tests # Alias test -> tests
.PHONY: format
format: format:
black --exclude "/migrations/" graphene_django examples setup.py black --exclude "/migrations/" graphene_django examples setup.py
.PHONY: lint .PHONY: lint ## Lint code
lint: lint:
flake8 graphene_django examples flake8 graphene_django examples

View File

@ -69,7 +69,10 @@ class DjangoListField(Field):
_type = _type.of_type _type = _type.of_type
django_object_type = _type.of_type.of_type django_object_type = _type.of_type.of_type
return partial( return partial(
self.list_resolver, django_object_type, resolver, self.get_manager(), self.list_resolver,
django_object_type,
resolver,
self.get_manager(),
) )

View File

@ -13,7 +13,7 @@ class GlobalIDFilter(Filter):
field_class = GlobalIDFormField field_class = GlobalIDFormField
def filter(self, qs, value): def filter(self, qs, value):
""" Convert the filter value to a primary key before filtering """ """Convert the filter value to a primary key before filtering"""
_id = None _id = None
if value is not None: if value is not None:
_, _id = from_global_id(value) _, _id = from_global_id(value)

View File

@ -18,8 +18,8 @@ GRAPHENE_FILTER_SET_OVERRIDES = {
class GrapheneFilterSetMixin(BaseFilterSet): class GrapheneFilterSetMixin(BaseFilterSet):
""" A django_filters.filterset.BaseFilterSet with default filter overrides """A django_filters.filterset.BaseFilterSet with default filter overrides
to handle global IDs """ to handle global IDs"""
FILTER_DEFAULTS = dict( FILTER_DEFAULTS = dict(
itertools.chain( itertools.chain(
@ -29,8 +29,7 @@ class GrapheneFilterSetMixin(BaseFilterSet):
def setup_filterset(filterset_class): def setup_filterset(filterset_class):
""" Wrap a provided filterset in Graphene-specific functionality """Wrap a provided filterset in Graphene-specific functionality"""
"""
return type( return type(
"Graphene{}".format(filterset_class.__name__), "Graphene{}".format(filterset_class.__name__),
(filterset_class, GrapheneFilterSetMixin), (filterset_class, GrapheneFilterSetMixin),
@ -39,8 +38,7 @@ def setup_filterset(filterset_class):
def custom_filterset_factory(model, filterset_base_class=FilterSet, **meta): def custom_filterset_factory(model, filterset_base_class=FilterSet, **meta):
""" Create a filterset for the given model using the provided meta data """Create a filterset for the given model using the provided meta data"""
"""
meta.update({"model": model}) meta.update({"model": model})
meta_class = type(str("Meta"), (object,), meta) meta_class = type(str("Meta"), (object,), meta)
filterset = type( filterset = type(

View File

@ -89,10 +89,10 @@ def Query(EventType):
def resolve_events(self, info, **kwargs): def resolve_events(self, info, **kwargs):
events = [ events = [
Event(name="Live Show", tags=["concert", "music", "rock"],), Event(name="Live Show", tags=["concert", "music", "rock"]),
Event(name="Musical", tags=["movie", "music"],), Event(name="Musical", tags=["movie", "music"]),
Event(name="Ballet", tags=["concert", "dance"],), Event(name="Ballet", tags=["concert", "dance"]),
Event(name="Speech", tags=[],), Event(name="Speech", tags=[]),
] ]
STORE["events"] = events STORE["events"] = events

View File

@ -54,13 +54,13 @@ def reporter_article_data():
first_name="Jane", last_name="Doe", email="janedoe@example.com", a_choice=2 first_name="Jane", last_name="Doe", email="janedoe@example.com", a_choice=2
) )
Article.objects.create( Article.objects.create(
headline="Article Node 1", reporter=john, editor=john, lang="es", headline="Article Node 1", reporter=john, editor=john, lang="es"
) )
Article.objects.create( Article.objects.create(
headline="Article Node 2", reporter=john, editor=john, lang="en", headline="Article Node 2", reporter=john, editor=john, lang="en"
) )
Article.objects.create( Article.objects.create(
headline="Article Node 3", reporter=jane, editor=jane, lang="en", headline="Article Node 3", reporter=jane, editor=jane, lang="en"
) )
@ -80,7 +80,13 @@ def test_filter_enum_on_connection(schema, reporter_article_data):
} }
""" """
expected = {"allArticles": {"edges": [{"node": {"headline": "Article Node 1"}},]}} expected = {
"allArticles": {
"edges": [
{"node": {"headline": "Article Node 1"}},
]
}
}
result = schema.execute(query) result = schema.execute(query)
assert not result.errors assert not result.errors

View File

@ -1224,7 +1224,7 @@ def test_filter_filterset_based_on_mixin():
} }
} }
result = schema.execute(query, variable_values={"email": reporter_1.email},) result = schema.execute(query, variable_values={"email": reporter_1.email})
assert not result.errors assert not result.errors
assert result.data == expected assert result.data == expected
@ -1265,13 +1265,23 @@ def test_filter_string_contains():
result = schema.execute(query, variables={"filter": "Ja"}) result = schema.execute(query, variables={"filter": "Ja"})
assert not result.errors assert not result.errors
assert result.data == { assert result.data == {
"people": {"edges": [{"node": {"name": "Jack"}}, {"node": {"name": "Jane"}},]} "people": {
"edges": [
{"node": {"name": "Jack"}},
{"node": {"name": "Jane"}},
]
}
} }
result = schema.execute(query, variables={"filter": "o"}) result = schema.execute(query, variables={"filter": "o"})
assert not result.errors assert not result.errors
assert result.data == { assert result.data == {
"people": {"edges": [{"node": {"name": "Joe"}}, {"node": {"name": "Bob"}},]} "people": {
"edges": [
{"node": {"name": "Joe"}},
{"node": {"name": "Bob"}},
]
}
} }

View File

@ -103,15 +103,9 @@ def test_typed_filter_schema(schema):
def test_typed_filters_work(schema): def test_typed_filters_work(schema):
reporter = Reporter.objects.create(first_name="John", last_name="Doe", email="") reporter = Reporter.objects.create(first_name="John", last_name="Doe", email="")
Article.objects.create( Article.objects.create(headline="A", reporter=reporter, editor=reporter, lang="es")
headline="A", reporter=reporter, editor=reporter, lang="es", Article.objects.create(headline="B", reporter=reporter, editor=reporter, lang="es")
) Article.objects.create(headline="C", reporter=reporter, editor=reporter, lang="en")
Article.objects.create(
headline="B", reporter=reporter, editor=reporter, lang="es",
)
Article.objects.create(
headline="C", reporter=reporter, editor=reporter, lang="en",
)
query = "query { articles (lang_In: [ES]) { edges { node { headline } } } }" query = "query { articles (lang_In: [ES]) { edges { node { headline } } } }"

View File

@ -94,7 +94,9 @@ def get_filtering_args_from_filterset(filterset_class, type):
field_type = graphene.List(field_type) field_type = graphene.List(field_type)
args[name] = graphene.Argument( args[name] = graphene.Argument(
field_type, description=filter_field.label, required=required, field_type,
description=filter_field.label,
required=required,
) )
return args return args

View File

@ -1480,7 +1480,11 @@ def test_connection_should_enable_offset_filtering():
result = schema.execute(query) result = schema.execute(query)
assert not result.errors assert not result.errors
expected = { expected = {
"allReporters": {"edges": [{"node": {"firstName": "Some", "lastName": "Guy"}},]} "allReporters": {
"edges": [
{"node": {"firstName": "Some", "lastName": "Guy"}},
]
}
} }
assert result.data == expected assert result.data == expected
@ -1521,7 +1525,9 @@ def test_connection_should_enable_offset_filtering_higher_than_max_limit(
assert not result.errors assert not result.errors
expected = { expected = {
"allReporters": { "allReporters": {
"edges": [{"node": {"firstName": "Some", "lastName": "Lady"}},] "edges": [
{"node": {"firstName": "Some", "lastName": "Lady"}},
]
} }
} }
assert result.data == expected assert result.data == expected
@ -1590,7 +1596,11 @@ def test_connection_should_allow_offset_filtering_with_after():
result = schema.execute(query, variable_values=dict(after=after)) result = schema.execute(query, variable_values=dict(after=after))
assert not result.errors assert not result.errors
expected = { expected = {
"allReporters": {"edges": [{"node": {"firstName": "Jane", "lastName": "Roe"}},]} "allReporters": {
"edges": [
{"node": {"firstName": "Jane", "lastName": "Roe"}},
]
}
} }
assert result.data == expected assert result.data == expected

View File

@ -216,7 +216,7 @@ class DjangoObjectType(ObjectType):
"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 " "= '__all__'` option on DjangoObjectType {class_name} to use all "
"fields".format(class_name=cls.__name__,), "fields".format(class_name=cls.__name__),
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )

View File

@ -6,4 +6,4 @@ def test_to_const():
def test_to_const_unicode(): def test_to_const_unicode():
assert to_const(u"Skoða þetta unicode stöff") == "SKODA_THETTA_UNICODE_STOFF" assert to_const("Skoða þetta unicode stöff") == "SKODA_THETTA_UNICODE_STOFF"

View File

@ -14,22 +14,22 @@ rest_framework_require = ["djangorestframework>=3.6.3"]
tests_require = [ tests_require = [
"pytest>=3.6.3", "pytest>=7.1.3",
"pytest-cov", "pytest-cov",
"pytest-random-order", "pytest-random-order",
"coveralls", "coveralls",
"mock", "mock",
"pytz", "pytz",
"django-filter>=2", "django-filter>=22.1",
"pytest-django>=3.3.2", "pytest-django>=4.5.2",
] + rest_framework_require ] + rest_framework_require
dev_requires = [ dev_requires = [
"black==19.10b0", "black==22.8.0",
"flake8==3.7.9", "flake8==5.0.4",
"flake8-black==0.1.1", "flake8-black==0.3.3",
"flake8-bugbear==20.1.4", "flake8-bugbear==22.9.11",
] + tests_require ] + tests_require
setup( setup(