测试gitnore
This commit is contained in:
@@ -14,19 +14,18 @@ class cached_property:
|
||||
The optional ``name`` argument is obsolete as of Python 3.6 and will be
|
||||
deprecated in Django 4.0 (#30127).
|
||||
"""
|
||||
|
||||
name = None
|
||||
|
||||
@staticmethod
|
||||
def func(instance):
|
||||
raise TypeError(
|
||||
"Cannot use cached_property instance without calling "
|
||||
"__set_name__() on it."
|
||||
'Cannot use cached_property instance without calling '
|
||||
'__set_name__() on it.'
|
||||
)
|
||||
|
||||
def __init__(self, func, name=None):
|
||||
self.real_func = func
|
||||
self.__doc__ = getattr(func, "__doc__")
|
||||
self.__doc__ = getattr(func, '__doc__')
|
||||
|
||||
def __set_name__(self, owner, name):
|
||||
if self.name is None:
|
||||
@@ -55,7 +54,6 @@ class classproperty:
|
||||
Decorator that converts a method with a single cls argument into a property
|
||||
that can be accessed directly from the class.
|
||||
"""
|
||||
|
||||
def __init__(self, method=None):
|
||||
self.fget = method
|
||||
|
||||
@@ -72,7 +70,6 @@ class Promise:
|
||||
Base class for the proxy class created in the closure of the lazy function.
|
||||
It's used to recognize promises in code.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -91,7 +88,6 @@ def lazy(func, *resultclasses):
|
||||
called on the result of that function. The function is not evaluated
|
||||
until one of the methods on the result is called.
|
||||
"""
|
||||
|
||||
__prepared = False
|
||||
|
||||
def __init__(self, args, kw):
|
||||
@@ -104,7 +100,7 @@ def lazy(func, *resultclasses):
|
||||
def __reduce__(self):
|
||||
return (
|
||||
_lazy_proxy_unpickle,
|
||||
(func, self.__args, self.__kw) + resultclasses,
|
||||
(func, self.__args, self.__kw) + resultclasses
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
@@ -123,10 +119,8 @@ def lazy(func, *resultclasses):
|
||||
setattr(cls, method_name, meth)
|
||||
cls._delegate_bytes = bytes in resultclasses
|
||||
cls._delegate_text = str in resultclasses
|
||||
if cls._delegate_bytes and cls._delegate_text:
|
||||
raise ValueError(
|
||||
"Cannot call lazy() with both bytes and text return types."
|
||||
)
|
||||
assert not (cls._delegate_bytes and cls._delegate_text), (
|
||||
"Cannot call lazy() with both bytes and text return types.")
|
||||
if cls._delegate_text:
|
||||
cls.__str__ = cls.__text_cast
|
||||
elif cls._delegate_bytes:
|
||||
@@ -140,7 +134,6 @@ def lazy(func, *resultclasses):
|
||||
# applies the given magic method of the result type.
|
||||
res = func(*self.__args, **self.__kw)
|
||||
return getattr(res, method_name)(*args, **kw)
|
||||
|
||||
return __wrapper__
|
||||
|
||||
def __text_cast(self):
|
||||
@@ -230,15 +223,10 @@ def keep_lazy(*resultclasses):
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if any(
|
||||
isinstance(arg, Promise)
|
||||
for arg in itertools.chain(args, kwargs.values())
|
||||
):
|
||||
if any(isinstance(arg, Promise) for arg in itertools.chain(args, kwargs.values())):
|
||||
return lazy_func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
@@ -257,7 +245,6 @@ def new_method_proxy(func):
|
||||
if self._wrapped is empty:
|
||||
self._setup()
|
||||
return func(self._wrapped, *args)
|
||||
|
||||
return inner
|
||||
|
||||
|
||||
@@ -300,9 +287,7 @@ class LazyObject:
|
||||
"""
|
||||
Must be implemented by subclasses to initialize the wrapped object.
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"subclasses of LazyObject must provide a _setup() method"
|
||||
)
|
||||
raise NotImplementedError('subclasses of LazyObject must provide a _setup() method')
|
||||
|
||||
# Because we have messed with __class__ below, we confuse pickle as to what
|
||||
# class we are pickling. We're going to have to initialize the wrapped
|
||||
@@ -381,7 +366,6 @@ class SimpleLazyObject(LazyObject):
|
||||
Designed for compound objects of unknown type. For builtins or objects of
|
||||
known type, use django.utils.functional.lazy.
|
||||
"""
|
||||
|
||||
def __init__(self, func):
|
||||
"""
|
||||
Pass in a callable that returns the object to be wrapped.
|
||||
@@ -391,7 +375,7 @@ class SimpleLazyObject(LazyObject):
|
||||
callable can be safely run more than once and will return the same
|
||||
value.
|
||||
"""
|
||||
self.__dict__["_setupfunc"] = func
|
||||
self.__dict__['_setupfunc'] = func
|
||||
super().__init__()
|
||||
|
||||
def _setup(self):
|
||||
@@ -404,7 +388,7 @@ class SimpleLazyObject(LazyObject):
|
||||
repr_attr = self._setupfunc
|
||||
else:
|
||||
repr_attr = self._wrapped
|
||||
return "<%s: %r>" % (type(self).__name__, repr_attr)
|
||||
return '<%s: %r>' % (type(self).__name__, repr_attr)
|
||||
|
||||
def __copy__(self):
|
||||
if self._wrapped is empty:
|
||||
|
||||
Reference in New Issue
Block a user