Skip to content

Graphene v3 following v3 graphql-core #1048

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 9 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -18,7 +18,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/ambv/black
rev: 18.9b0
rev: 19.3b0
hooks:
- id: black
language_version: python3
Expand Down
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
language: python
matrix:
include:
- env: TOXENV=py27
python: 2.7
- env: TOXENV=py35
python: 3.5
- env: TOXENV=py36
python: 3.6
- env: TOXENV=py37
python: 3.7
dist: xenial
sudo: true
- env: TOXENV=pypy
python: pypy-5.7.1
- env: TOXENV=pre-commit
python: 3.6
- env: TOXENV=mypy
Expand Down
2 changes: 1 addition & 1 deletion graphene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from .utils.module_loading import lazy_import


VERSION = (2, 1, 5, "final", 0)
VERSION = (3, 0, 0, "alpha", 0)

__version__ = get_version(VERSION)

Expand Down
13 changes: 0 additions & 13 deletions graphene/pyutils/compat.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
from __future__ import absolute_import

import six

from graphql.pyutils.compat import Enum

try:
from inspect import signature
except ImportError:
from .signature import signature

if six.PY2:

def func_name(func):
return func.func_name


else:

def func_name(func):
return func.__name__
3 changes: 1 addition & 2 deletions graphene/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from promise import Promise, is_thenable
import six
from graphql.error import format_error as format_graphql_error
from graphql.error import GraphQLError

Expand All @@ -10,7 +9,7 @@ def default_format_error(error):
if isinstance(error, GraphQLError):
return format_graphql_error(error)

return {"message": six.text_type(error)}
return {"message": str(error)}


def format_execution_result(execution_result, format_error):
Expand Down
6 changes: 2 additions & 4 deletions graphene/types/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from typing import Type

from ..utils.subclass_with_meta import SubclassWithMeta
from ..utils.trim_docstring import trim_docstring
import six

if six.PY3:
from typing import Type


class BaseOptions(object):
Expand Down
7 changes: 3 additions & 4 deletions graphene/types/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from aniso8601 import parse_date, parse_datetime, parse_time
from graphql.language import ast
from six import string_types

from .scalars import Scalar

Expand Down Expand Up @@ -35,7 +34,7 @@ def parse_value(value):
try:
if isinstance(value, datetime.date):
return value
elif isinstance(value, string_types):
elif isinstance(value, str):
return parse_date(value)
except ValueError:
return None
Expand Down Expand Up @@ -65,7 +64,7 @@ def parse_value(value):
try:
if isinstance(value, datetime.datetime):
return value
elif isinstance(value, string_types):
elif isinstance(value, str):
return parse_datetime(value)
except ValueError:
return None
Expand Down Expand Up @@ -95,7 +94,7 @@ def parse_value(cls, value):
try:
if isinstance(value, datetime.time):
return value
elif isinstance(value, string_types):
elif isinstance(value, str):
return parse_time(value)
except ValueError:
return None
5 changes: 1 addition & 4 deletions graphene/types/enum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from collections import OrderedDict

import six

from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta

from ..pyutils.compat import Enum as PyEnum
Expand Down Expand Up @@ -66,7 +63,7 @@ def from_enum(cls, enum, description=None, deprecation_reason=None): # noqa: N8
return type(meta_class.enum.__name__, (Enum,), {"Meta": meta_class})


class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
class Enum(UnmountedType, BaseType, metaclass=EnumMeta):
@classmethod
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options):
if not _meta:
Expand Down
8 changes: 3 additions & 5 deletions graphene/types/scalars.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import six
from typing import Any

from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue

from .base import BaseOptions, BaseType
from .unmountedtype import UnmountedType

if six.PY3:
from typing import Any


class ScalarOptions(BaseOptions):
pass
Expand Down Expand Up @@ -114,7 +112,7 @@ class String(Scalar):
def coerce_string(value):
if isinstance(value, bool):
return u"true" if value else u"false"
return six.text_type(value)
return str(value)

serialize = coerce_string
parse_value = coerce_string
Expand Down
5 changes: 0 additions & 5 deletions graphene/types/tests/test_enum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import six

from ..argument import Argument
from ..enum import Enum, PyEnum
from ..field import Field
Expand Down Expand Up @@ -115,9 +113,6 @@ class Query(ObjectType):


def test_enum_from_python3_enum_uses_enum_doc():
if not six.PY3:
return

from enum import Enum as PyEnum

class Color(PyEnum):
Expand Down
14 changes: 14 additions & 0 deletions graphene/types/tests/test_objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,17 @@ class Meta:
field = MyScalar()

assert str(MyObjectType) == "MyObjectType"


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
4 changes: 1 addition & 3 deletions graphene/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from collections import OrderedDict
from functools import partial

from six import string_types

from ..utils.module_loading import import_string
from .mountedtype import MountedType
from .unmountedtype import UnmountedType
Expand Down Expand Up @@ -39,7 +37,7 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True):


def get_type(_type):
if isinstance(_type, string_types):
if isinstance(_type, str):
return import_string(_type)
if inspect.isfunction(_type) or isinstance(_type, partial):
return _type()
Expand Down
3 changes: 1 addition & 2 deletions graphene/types/uuid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import absolute_import
import six
from uuid import UUID as _UUID

from graphql.language import ast
Expand All @@ -12,7 +11,7 @@ class UUID(Scalar):

@staticmethod
def serialize(uuid):
if isinstance(uuid, six.string_types):
if isinstance(uuid, str):
uuid = _UUID(uuid)

assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format(
Expand Down
35 changes: 0 additions & 35 deletions graphene/utils/annotate.py

This file was deleted.

4 changes: 1 addition & 3 deletions graphene/utils/subclass_with_meta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from inspect import isclass

import six

from ..pyutils.init_subclass import InitSubclassMeta
from .props import props

Expand All @@ -18,7 +16,7 @@ def __repr__(cls):
return "<{} meta={}>".format(cls.__name__, repr(cls._meta))


class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)):
class SubclassWithMeta(metaclass=SubclassWithMeta_Meta):
"""This class improves __init_subclass__ to receive automatically the options from meta"""

# We will only have the metaclass in Python 2
Expand Down
37 changes: 0 additions & 37 deletions graphene/utils/tests/test_annotate.py

This file was deleted.

7 changes: 1 addition & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run_tests(self):
"pytest-benchmark",
"pytest-cov",
"pytest-mock",
"pytest-asyncio",
"snapshottest",
"coveralls",
"promise",
Expand All @@ -73,18 +74,12 @@ def run_tests(self):
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: PyPy",
],
keywords="api graphql protocol rest relay graphene",
packages=find_packages(exclude=["tests", "tests.*", "examples"]),
install_requires=[
"six>=1.10.0,<2",
"graphql-core>=2.1,<3",
"graphql-relay>=0.4.5,<1",
"aniso8601>=3,<=6.0.*",
Expand Down
15 changes: 0 additions & 15 deletions tests_py36/test_objecttype.py

This file was deleted.

7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
[tox]
envlist = flake8,py27,py34,py35,py36,py37,pre-commit,pypy,mypy
envlist = flake8,py36,py37,pre-commit,mypy
skipsdist = true

[testenv]
deps =
.[test]
py{35,36,37}: pytest-asyncio
setenv =
PYTHONPATH = .:{envdir}
commands =
py{27,py}: py.test --cov=graphene graphene examples {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}
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio {posargs}

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