Skip to content
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

Use Python 3 metaclass syntax #414

Merged
merged 1 commit into from Aug 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 2 additions & 13 deletions freezegun/api.py
Expand Up @@ -132,11 +132,6 @@ def _get_cached_module_attributes(module):
return cached_attrs


# Stolen from six
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
return meta("NewBase", bases, {})

_is_cpython = (
hasattr(platform, 'python_implementation') and
platform.python_implementation().lower() == "cpython"
Expand Down Expand Up @@ -309,10 +304,7 @@ def date_to_fakedate(date):
date.day)


class FakeDate(with_metaclass(FakeDateMeta, real_date)):
def __new__(cls, *args, **kwargs):
return real_date.__new__(cls, *args, **kwargs)

class FakeDate(real_date, metaclass=FakeDateMeta):
def __add__(self, other):
result = real_date.__add__(self, other)
if result is NotImplemented:
Expand Down Expand Up @@ -355,10 +347,7 @@ def __subclasscheck__(cls, subclass):
return issubclass(subclass, real_datetime)


class FakeDatetime(with_metaclass(FakeDatetimeMeta, real_datetime, FakeDate)):
def __new__(cls, *args, **kwargs):
return real_datetime.__new__(cls, *args, **kwargs)

class FakeDatetime(real_datetime, FakeDate, metaclass=FakeDatetimeMeta):
def __add__(self, other):
result = real_datetime.__add__(self, other)
if result is NotImplemented:
Expand Down