diff --git a/outer_join/__init__.py b/outer_join/__init__.py index a4df881..1e0d592 100644 --- a/outer_join/__init__.py +++ b/outer_join/__init__.py @@ -16,11 +16,11 @@ BaseTable as _BaseTable, Join as _Join, ) -from selfhacked.util.func import ( + +from .util import ( + cached_property, returns as _returns, ) - -from .util import cached_property from .util.info import ( ModelInfo as _ModelInfo, FieldInfo as _FieldInfo, diff --git a/outer_join/util/__init__.py b/outer_join/util/__init__.py index 8532614..098339e 100644 --- a/outer_join/util/__init__.py +++ b/outer_join/util/__init__.py @@ -1,8 +1,33 @@ +import typing as _typing from django.utils.functional import ( cached_property as _cached_property, ) +from functools import ( + wraps as _wraps, +) -cached_property = _cached_property +from .typing import ( + T as _T, +) # PyCharm doesn't like aliases for cached_property, so we unify import from here # Avoid cleanup import by PyCharm +cached_property = _cached_property + + +class returns(object): + """ + This code can be found in selfhacked-util + However it's the only thing we need from the package, + so we are copying the code here and getting rid of the dependency. + """ + + def __init__(self, type: _typing.Type[_T]): + self.__type = type + + def __call__(self, func) -> _T: + @_wraps(func) + def __new_func(*args, **kwargs): + return self.__type(func(*args, **kwargs)) + + return __new_func diff --git a/outer_join/util/info.py b/outer_join/util/info.py index 1bde90c..f8c9837 100644 --- a/outer_join/util/info.py +++ b/outer_join/util/info.py @@ -9,11 +9,11 @@ from django.forms import ( model_to_dict as _model_to_dict, ) -from selfhacked.util.func import ( + +from . import ( + cached_property, returns as _returns, ) - -from . import cached_property from .datatypes import ( ImmutableDict as _ImmutableDict, ) diff --git a/setup.py b/setup.py index e3022d6..3bd51a3 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,6 @@ install_requires=[ 'Django>=1.11', - 'selfhacked-util @ https://github.com/SelfHacked/selfhacked-util/archive/master.zip', ], extras_require={