Skip to content

Commit 5685991

Browse files
committed
Cleanup more dead code.
1 parent 00a7af8 commit 5685991

File tree

6 files changed

+18
-108
lines changed

6 files changed

+18
-108
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changelog
66
------------------
77

88
* Cleaned up use of cPickle. Contributed by Sandro Tosi in `#62 <https://github.com/ionelmc/python-lazy-object-proxy/pull/62>`_.
9+
* Cleaned up more dead Python 2 code.
910
* Added Python 3.11 wheels.
1011
* Dropped support for Python 3.6.
1112

conftest.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/lazy_object_proxy/simple.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import operator
22

3-
from .compat import PY2
4-
from .compat import PY3
53
from .compat import string_types
64
from .compat import with_metaclass
75
from .utils import await_
@@ -89,9 +87,7 @@ def __wrapped__(self):
8987
__annotations__ = property(make_proxy_method(operator.attrgetter('__anotations__')))
9088
__dir__ = make_proxy_method(dir)
9189
__str__ = make_proxy_method(str)
92-
93-
if PY3:
94-
__bytes__ = make_proxy_method(bytes)
90+
__bytes__ = make_proxy_method(bytes)
9591

9692
def __repr__(self, __getattr__=object.__getattribute__):
9793
if '__wrapped__' in self.__dict__:
@@ -113,10 +109,7 @@ def __fspath__(self):
113109
return fspath()
114110

115111
__reversed__ = make_proxy_method(reversed)
116-
117-
if PY3:
118-
__round__ = make_proxy_method(round)
119-
112+
__round__ = make_proxy_method(round)
120113
__lt__ = make_proxy_method(operator.lt)
121114
__le__ = make_proxy_method(operator.le)
122115
__eq__ = make_proxy_method(operator.eq)
@@ -148,7 +141,6 @@ def __delattr__(self, name):
148141
__add__ = make_proxy_method(operator.add)
149142
__sub__ = make_proxy_method(operator.sub)
150143
__mul__ = make_proxy_method(operator.mul)
151-
__div__ = make_proxy_method(operator.div if PY2 else operator.truediv)
152144
__truediv__ = make_proxy_method(operator.truediv)
153145
__floordiv__ = make_proxy_method(operator.floordiv)
154146
__mod__ = make_proxy_method(operator.mod)
@@ -205,7 +197,6 @@ def __ror__(self, other):
205197
__iadd__ = make_proxy_method(operator.iadd)
206198
__isub__ = make_proxy_method(operator.isub)
207199
__imul__ = make_proxy_method(operator.imul)
208-
__idiv__ = make_proxy_method(operator.idiv if PY2 else operator.itruediv)
209200
__itruediv__ = make_proxy_method(operator.itruediv)
210201
__ifloordiv__ = make_proxy_method(operator.ifloordiv)
211202
__imod__ = make_proxy_method(operator.imod)
@@ -219,12 +210,7 @@ def __ror__(self, other):
219210
__pos__ = make_proxy_method(operator.pos)
220211
__abs__ = make_proxy_method(operator.abs)
221212
__invert__ = make_proxy_method(operator.invert)
222-
223213
__int__ = make_proxy_method(int)
224-
225-
if PY2:
226-
__long__ = make_proxy_method(long) # noqa
227-
228214
__float__ = make_proxy_method(float)
229215
__oct__ = make_proxy_method(oct)
230216
__hex__ = make_proxy_method(hex)
@@ -241,11 +227,6 @@ def __index__(self):
241227
__setitem__ = make_proxy_method(operator.setitem)
242228
__delitem__ = make_proxy_method(operator.delitem)
243229

244-
if PY2:
245-
__getslice__ = make_proxy_method(operator.getslice)
246-
__setslice__ = make_proxy_method(operator.setslice)
247-
__delslice__ = make_proxy_method(operator.delslice)
248-
249230
def __enter__(self):
250231
return self.__wrapped__.__enter__()
251232

src/lazy_object_proxy/slots.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import operator
22

3-
from .compat import PY2
4-
from .compat import PY3
53
from .compat import string_types
64
from .compat import with_metaclass
75
from .utils import await_
@@ -144,10 +142,8 @@ def __dir__(self):
144142
def __str__(self):
145143
return str(self.__wrapped__)
146144

147-
if PY3:
148-
149-
def __bytes__(self):
150-
return bytes(self.__wrapped__)
145+
def __bytes__(self):
146+
return bytes(self.__wrapped__)
151147

152148
def __repr__(self, __getattr__=object.__getattribute__):
153149
try:
@@ -173,10 +169,8 @@ def __fspath__(self):
173169
def __reversed__(self):
174170
return reversed(self.__wrapped__)
175171

176-
if PY3:
177-
178-
def __round__(self):
179-
return round(self.__wrapped__)
172+
def __round__(self):
173+
return round(self.__wrapped__)
180174

181175
def __lt__(self, other):
182176
return self.__wrapped__ < other
@@ -232,9 +226,6 @@ def __sub__(self, other):
232226
def __mul__(self, other):
233227
return self.__wrapped__ * other
234228

235-
def __div__(self, other):
236-
return operator.div(self.__wrapped__, other)
237-
238229
def __truediv__(self, other):
239230
return operator.truediv(self.__wrapped__, other)
240231

@@ -374,11 +365,6 @@ def __invert__(self):
374365
def __int__(self):
375366
return int(self.__wrapped__)
376367

377-
if PY2:
378-
379-
def __long__(self):
380-
return long(self.__wrapped__) # noqa
381-
382368
def __float__(self):
383369
return float(self.__wrapped__)
384370

tests/compat.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/test_lazy_object_proxy.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
from functools import partial
1414

1515
import pytest
16-
from compat import PY2
17-
from compat import PY3
18-
from compat import exec_
1916

2017
PYPY = '__pypy__' in sys.builtin_module_names
2118

@@ -32,7 +29,7 @@ def target():
3229
"""
3330

3431
objects = types.ModuleType('objects')
35-
exec_(OBJECTS_CODE, objects.__dict__, objects.__dict__)
32+
exec(OBJECTS_CODE, objects.__dict__, objects.__dict__)
3633

3734

3835
def test_round(lop):
@@ -72,8 +69,7 @@ def function1(*args, **kwargs):
7269
assert function2.__wrapped__ is function1
7370
assert function2.__name__ == function1.__name__
7471

75-
if PY3:
76-
assert function2.__qualname__ == function1.__qualname__
72+
assert function2.__qualname__ == function1.__qualname__
7773

7874
function2.__wrapped__ = None
7975

@@ -83,8 +79,7 @@ def function1(*args, **kwargs):
8379
assert function2.__wrapped__ is None
8480
assert not hasattr(function2, '__name__')
8581

86-
if PY3:
87-
assert not hasattr(function2, '__qualname__')
82+
assert not hasattr(function2, '__qualname__')
8883

8984
def function3(*args, **kwargs):
9085
return args, kwargs
@@ -95,8 +90,7 @@ def function3(*args, **kwargs):
9590
assert function2.__wrapped__ == function3
9691
assert function2.__name__ == function3.__name__
9792

98-
if PY3:
99-
assert function2.__qualname__ == function3.__qualname__
93+
assert function2.__qualname__ == function3.__qualname__
10094

10195

10296
def test_wrapped_attribute(lop):
@@ -884,9 +878,6 @@ def test_int(lop):
884878

885879
assert int(one) == 1
886880

887-
if not PY3:
888-
assert long(one) == 1 # noqa
889-
890881

891882
def test_float(lop):
892883
one = lop.Proxy(lambda: 1)
@@ -1556,17 +1547,15 @@ def test_callable_proxy_is_callable(lop):
15561547

15571548

15581549
def test_class_bytes(lop):
1559-
if PY3:
1560-
1561-
class Class(object):
1562-
def __bytes__(self):
1563-
return b'BYTES'
1550+
class Class(object):
1551+
def __bytes__(self):
1552+
return b'BYTES'
15641553

1565-
instance = Class()
1554+
instance = Class()
15661555

1567-
proxy = lop.Proxy(lambda: instance)
1556+
proxy = lop.Proxy(lambda: instance)
15681557

1569-
assert bytes(instance) == bytes(proxy)
1558+
assert bytes(instance) == bytes(proxy)
15701559

15711560

15721561
def test_str_format(lop):
@@ -1606,14 +1595,7 @@ def test_fractions_round(lop):
16061595

16071596

16081597
def test_readonly(lop):
1609-
class Foo(object):
1610-
if PY2:
1611-
1612-
@property
1613-
def __qualname__(self):
1614-
return 'object'
1615-
1616-
proxy = lop.Proxy(lambda: Foo() if PY2 else object)
1598+
proxy = lop.Proxy(lambda: object)
16171599
assert proxy.__qualname__ == 'object'
16181600

16191601

0 commit comments

Comments
 (0)