mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Remove subclass polyfill (#1156)
The subclass polyfill was only needed for Python 2.7-3.5 Python 3.6 introduced the __init_subclass__, so since Graphene now requires Python 3.6+, this is no longer needed. https://www.python.org/dev/peps/pep-0487/
This commit is contained in:
parent
1cf303a27b
commit
14183012a8
|
@ -1,23 +0,0 @@
|
|||
is_init_subclass_available = hasattr(object, "__init_subclass__")
|
||||
|
||||
if not is_init_subclass_available:
|
||||
|
||||
class InitSubclassMeta(type):
|
||||
"""Metaclass that implements PEP 487 protocol"""
|
||||
|
||||
def __new__(cls, name, bases, ns, **kwargs):
|
||||
__init_subclass__ = ns.pop("__init_subclass__", None)
|
||||
if __init_subclass__:
|
||||
__init_subclass__ = classmethod(__init_subclass__)
|
||||
ns["__init_subclass__"] = __init_subclass__
|
||||
return super(InitSubclassMeta, cls).__new__(cls, name, bases, ns, **kwargs)
|
||||
|
||||
def __init__(cls, name, bases, ns, **kwargs):
|
||||
super(InitSubclassMeta, cls).__init__(name, bases, ns)
|
||||
super_class = super(cls, cls)
|
||||
if hasattr(super_class, "__init_subclass__"):
|
||||
super_class.__init_subclass__.__func__(cls, **kwargs)
|
||||
|
||||
|
||||
else:
|
||||
InitSubclassMeta = type # type: ignore
|
|
@ -1,10 +1,9 @@
|
|||
from inspect import isclass
|
||||
|
||||
from ..pyutils.init_subclass import InitSubclassMeta
|
||||
from .props import props
|
||||
|
||||
|
||||
class SubclassWithMeta_Meta(InitSubclassMeta):
|
||||
class SubclassWithMeta_Meta(type):
|
||||
_meta = None
|
||||
|
||||
def __str__(cls):
|
||||
|
|
Loading…
Reference in New Issue
Block a user