Skip to content

Fix for metaclasses that use type annotation (Issue #979) #981

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 6 commits into from
May 31, 2019
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
4 changes: 3 additions & 1 deletion graphene/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def create_type(cls, class_name, **options):
return type(class_name, (cls,), {"Meta": options})

@classmethod
def __init_subclass_with_meta__(cls, name=None, description=None, _meta=None):
def __init_subclass_with_meta__(
cls, name=None, description=None, _meta=None, **_kwargs
):
assert "_meta" not in cls.__dict__, "Can't assign directly meta"
if not _meta:
return
Expand Down
15 changes: 15 additions & 0 deletions tests_py36/test_objecttype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from graphene import Schema, ObjectType, String


def test_objecttype_meta_with_annotations():
class Query(ObjectType):
class Meta:
name: str = "oops"

hello = String()

def resolve_hello(self, info):
return "Hello"

schema = Schema(query=Query)
assert schema is not None
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ setenv =
PYTHONPATH = .:{envdir}
commands =
py{27,py}: py.test --cov=graphene graphene examples {posargs}
py{35,36,37}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
py{35}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}

[testenv:pre-commit]
basepython=python3.6
Expand Down