Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/rest_framework_simplejwt/compat.py: 68%
30 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1import warnings
3try:
4 from django.urls import reverse, reverse_lazy
5except ImportError:
6 from django.core.urlresolvers import reverse, reverse_lazy # NOQA
9class RemovedInDjango20Warning(DeprecationWarning):
10 pass
13class CallableBool: # pragma: no cover
14 """
15 An boolean-like object that is also callable for backwards compatibility.
16 """
18 do_not_call_in_templates = True
20 def __init__(self, value):
21 self.value = value
23 def __bool__(self):
24 return self.value
26 def __call__(self):
27 warnings.warn(
28 "Using user.is_authenticated() and user.is_anonymous() as a method "
29 "is deprecated. Remove the parentheses to use it as an attribute.",
30 RemovedInDjango20Warning,
31 stacklevel=2,
32 )
33 return self.value
35 def __nonzero__(self): # Python 2 compatibility
36 return self.value
38 def __repr__(self):
39 return "CallableBool(%r)" % self.value
41 def __eq__(self, other):
42 return self.value == other
44 def __ne__(self, other):
45 return self.value != other
47 def __or__(self, other):
48 return bool(self.value or other)
50 def __hash__(self):
51 return hash(self.value)
54CallableFalse = CallableBool(False)
55CallableTrue = CallableBool(True)