mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Don't need to implement __new__ to make an immutable class
This commit is contained in:
parent
a858987844
commit
b1953640d2
|
@ -55,8 +55,7 @@ class Range(object):
|
||||||
"""
|
"""
|
||||||
__slots__ = ('_lower', '_upper', '_bounds')
|
__slots__ = ('_lower', '_upper', '_bounds')
|
||||||
|
|
||||||
def __new__(cls, lower=None, upper=None, bounds='[)', empty=False):
|
def __init__(self, lower=None, upper=None, bounds='[)', empty=False):
|
||||||
self = super(Range, cls).__new__(cls)
|
|
||||||
if not empty:
|
if not empty:
|
||||||
if bounds not in ('[)', '(]', '()', '[]'):
|
if bounds not in ('[)', '(]', '()', '[]'):
|
||||||
raise ValueError("bound flags not valid: %r" % bounds)
|
raise ValueError("bound flags not valid: %r" % bounds)
|
||||||
|
@ -67,8 +66,6 @@ class Range(object):
|
||||||
else:
|
else:
|
||||||
self._lower = self._upper = self._bounds = None
|
self._lower = self._upper = self._bounds = None
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if self._bounds is None:
|
if self._bounds is None:
|
||||||
return "%s(empty=True)" % self.__class__.__name__
|
return "%s(empty=True)" % self.__class__.__name__
|
||||||
|
|
Loading…
Reference in New Issue
Block a user