From 1322ddb8b4027ad9103096500b83ff58a8360ce3 Mon Sep 17 00:00:00 2001 From: KingDarBoja Date: Sun, 15 Mar 2020 13:34:48 -0500 Subject: [PATCH 1/3] feat: add __str__ to ExecutionResult class --- .gitignore | 2 +- graphql/error/base.py | 1 - graphql/execution/base.py | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e282a875..1715eb7f 100644 --- a/.gitignore +++ b/.gitignore @@ -67,7 +67,7 @@ docs/_build/ *.iml # Visual Studio -/.vscode +.vscode/* # OS X .DS_Store diff --git a/graphql/error/base.py b/graphql/error/base.py index 2865e4a4..2ed1803f 100644 --- a/graphql/error/base.py +++ b/graphql/error/base.py @@ -44,7 +44,6 @@ def __init__( self._locations = locations self.path = path self.extensions = extensions - return None @property def source(self): diff --git a/graphql/execution/base.py b/graphql/execution/base.py index d71151a5..240b95c1 100644 --- a/graphql/execution/base.py +++ b/graphql/execution/base.py @@ -48,6 +48,9 @@ def __eq__(self, other): and self.invalid == other.invalid ) + def __str__(self): + return str(self.to_dict()) + def to_dict(self, format_error=None, dict_class=OrderedDict): # type: (Optional[Callable[[Exception], Dict]], Type[Dict]) -> Dict[str, Any] if format_error is None: From ab13ec6aa60125b3772c95403a85eba37b4b1095 Mon Sep 17 00:00:00 2001 From: KingDarBoja Date: Sun, 15 Mar 2020 13:36:44 -0500 Subject: [PATCH 2/3] refactor: provide super calls to definitions --- graphql/type/definition.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/graphql/type/definition.py b/graphql/type/definition.py index 3f8d2ba0..cee6677c 100644 --- a/graphql/type/definition.py +++ b/graphql/type/definition.py @@ -110,10 +110,6 @@ def is_same_type(self, other): return self.__class__ is other.__class__ and self.name == other.name -def none_func(x): - None - - class GraphQLScalarType(GraphQLNamedType): """Scalar Type Definition @@ -144,6 +140,7 @@ def __init__( # type: (...) -> None assert name, "Type must be named." assert_valid_name(name) + super(GraphQLScalarType, self).__init__(name) self.name = name self.description = description @@ -161,8 +158,8 @@ def __init__( ) self.serialize = serialize - self.parse_value = parse_value or none_func - self.parse_literal = parse_literal or none_func + self.parse_value = parse_value or None + self.parse_literal = parse_literal or None def __str__(self): # type: () -> str @@ -207,6 +204,7 @@ def __init__( # type: (...) -> None assert name, "Type must be named." assert_valid_name(name) + super(GraphQLObjectType, self).__init__(name) self.name = name self.description = description @@ -341,7 +339,7 @@ class GraphQLArgument(object): def __init__( self, - type, # type: Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType] + type, # type: Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, GraphQLEnumType] default_value=None, # type: Optional[Any] description=None, # type: Optional[Any] out_name=None, # type: Optional[str] @@ -388,6 +386,7 @@ def __init__( description=None, # type: Optional[Any] ): # type: (...) -> None + super(GraphQLInterfaceType, self).__init__(name) assert name, "Type must be named." assert_valid_name(name) self.name = name @@ -435,6 +434,7 @@ def __init__( description=None, # type: Optional[Any] ): # type: (...) -> None + super(GraphQLUnionType, self).__init__(name) assert name, "Type must be named." assert_valid_name(name) self.name = name @@ -510,6 +510,7 @@ class GraphQLEnumType(GraphQLNamedType): def __init__(self, name, values, description=None): assert name, "Type must provide name." assert_valid_name(name) + super(GraphQLEnumType, self).__init__(name) self.name = name self.description = description @@ -646,6 +647,7 @@ def __init__( ): # type: (...) -> None assert name, "Type must be named." + super(GraphQLInputObjectType, self).__init__(name) self.name = name self.description = description if container_type is None: From 934dc85ed2e28f7cd6a4e2699a76f398088fdb9c Mon Sep 17 00:00:00 2001 From: KingDarBoja Date: Sun, 15 Mar 2020 22:07:15 -0500 Subject: [PATCH 3/3] chore: set encoding while loading readme on setup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 73730ec2..d483ca0c 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def run_tests(self): name="graphql-core", version=version, description="GraphQL implementation for Python", - long_description=open("README.md").read(), + long_description=open("README.md", encoding="utf8").read(), long_description_content_type="text/markdown", url="https://github.com/graphql-python/graphql-core-legacy", download_url="https://github.com/graphql-python/graphql-core-legacy/releases",