Skip to content

Commit eb7966e

Browse files
authored
Fix for metaclasses that use type annotation (Issue #979) (#981)
* Replicate error with test * Fix - ignore parameters we do not recognize * Seperate Python3.6+ tests to their own folder * lint * Unused import * Black formatting
1 parent 1fcdeaa commit eb7966e

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

graphene/types/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def create_type(cls, class_name, **options):
3434
return type(class_name, (cls,), {"Meta": options})
3535

3636
@classmethod
37-
def __init_subclass_with_meta__(cls, name=None, description=None, _meta=None):
37+
def __init_subclass_with_meta__(
38+
cls, name=None, description=None, _meta=None, **_kwargs
39+
):
3840
assert "_meta" not in cls.__dict__, "Can't assign directly meta"
3941
if not _meta:
4042
return

tests_py36/test_objecttype.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from graphene import Schema, ObjectType, String
2+
3+
4+
def test_objecttype_meta_with_annotations():
5+
class Query(ObjectType):
6+
class Meta:
7+
name: str = "oops"
8+
9+
hello = String()
10+
11+
def resolve_hello(self, info):
12+
return "Hello"
13+
14+
schema = Schema(query=Query)
15+
assert schema is not None

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ setenv =
1010
PYTHONPATH = .:{envdir}
1111
commands =
1212
py{27,py}: py.test --cov=graphene graphene examples {posargs}
13-
py{35,36,37}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
13+
py{35}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
14+
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
1415

1516
[testenv:pre-commit]
1617
basepython=python3.6

0 commit comments

Comments
 (0)