Skip to content

Commit

Permalink
Remove compatibility with_metaclass method (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocolato authored Apr 1, 2024
1 parent 3977f39 commit a12b13d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
21 changes: 0 additions & 21 deletions thriftpy2/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,3 @@

UNIX = platform.system() in ("Linux", "Darwin")
CYTHON = UNIX and not PYPY # Cython always disabled in pypy and windows


def with_metaclass(meta, *bases):
"""Create a base class with a metaclass for py2 & py3
This code snippet is copied from six."""
# This requires a bit of explanation: the basic idea is to make a
# dummy metaclass for one level of class instantiation that replaces
# itself with the actual metaclass. Because of internal type checks
# we also need to make sure that we downgrade the custom metaclass
# for one level to something closer to type (that's why __call__ and
# __init__ comes back from type etc.).
class metaclass(meta):
__call__ = type.__call__
__init__ = type.__init__

def __new__(cls, name, this_bases, d):
if this_bases is None:
return type.__new__(cls, name, (), d)
return meta(name, bases, d)
return metaclass('temporary_class', None, {})
4 changes: 1 addition & 3 deletions thriftpy2/thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import types
from itertools import zip_longest

from ._compat import with_metaclass


def args_to_kwargs(thrift_spec, *args, **kwargs):
for item, value in zip_longest(sorted(thrift_spec.items()), args):
Expand Down Expand Up @@ -149,7 +147,7 @@ def gen_init(cls, thrift_spec=None, default_spec=None):
return cls


class TPayload(with_metaclass(TPayloadMeta, object)):
class TPayload(metaclass=TPayloadMeta):

__hash__ = None

Expand Down

0 comments on commit a12b13d

Please sign in to comment.