@@ -771,7 +771,7 @@ def test_iteration(lop):
771
771
772
772
wrapper = lop .Proxy (lambda : items )
773
773
774
- result = [x for x in wrapper ]
774
+ result = [x for x in wrapper ] # noqa: C416
775
775
776
776
assert result == items
777
777
@@ -816,13 +816,11 @@ def function1(*args, **kwargs):
816
816
817
817
function2 = lop .Proxy (lambda : function1 )
818
818
819
- table = dict ()
820
- table [function1 ] = True
819
+ table = {function1 : True }
821
820
822
821
assert table .get (function2 )
823
822
824
- table = dict ()
825
- table [function2 ] = True
823
+ table = {function2 : True }
826
824
827
825
assert table .get (function1 )
828
826
@@ -1458,12 +1456,12 @@ def test_repr_doesnt_consume(lop):
1458
1456
def test_derived_new (lop ):
1459
1457
class DerivedObjectProxy (lop .Proxy ):
1460
1458
def __new__ (cls , wrapped ):
1461
- instance = super (DerivedObjectProxy , cls ).__new__ (cls )
1459
+ instance = super ().__new__ (cls )
1462
1460
instance .__init__ (wrapped )
1463
1461
return instance
1464
1462
1465
1463
def __init__ (self , wrapped ):
1466
- super (DerivedObjectProxy , self ).__init__ (wrapped )
1464
+ super ().__init__ (wrapped )
1467
1465
1468
1466
def function ():
1469
1467
return 123
@@ -1540,9 +1538,9 @@ class DerivedObjectProxy(lop.Proxy):
1540
1538
def __getattr__ (self , name ):
1541
1539
accessed .append (name )
1542
1540
try :
1543
- __getattr__ = super (DerivedObjectProxy , self ).__getattr__
1541
+ __getattr__ = super ().__getattr__
1544
1542
except AttributeError as e :
1545
- raise RuntimeError (str (e ))
1543
+ raise RuntimeError (str (e )) from e
1546
1544
return __getattr__ (name )
1547
1545
1548
1546
function .attribute = 1
@@ -1884,7 +1882,7 @@ class LazyProxy(lop.Proxy):
1884
1882
name = None
1885
1883
1886
1884
def __init__ (self , func , ** lazy_attr ):
1887
- super (LazyProxy , self ).__init__ (func )
1885
+ super ().__init__ (func )
1888
1886
for attr , val in lazy_attr .items ():
1889
1887
setattr (self , attr , val )
1890
1888
@@ -1904,7 +1902,7 @@ class Foo:
1904
1902
1905
1903
class LazyProxy (lop .Proxy ):
1906
1904
def __init__ (self , func , ** lazy_attr ):
1907
- super (LazyProxy , self ).__init__ (func )
1905
+ super ().__init__ (func )
1908
1906
for attr , val in lazy_attr .items ():
1909
1907
object .__setattr__ (self , attr , val )
1910
1908
@@ -1915,20 +1913,20 @@ def __init__(self, func, **lazy_attr):
1915
1913
1916
1914
class FSPathMock :
1917
1915
def __fspath__ (self ):
1918
- return '/tmp '
1916
+ return '/foobar '
1919
1917
1920
1918
1921
1919
@pytest .mark .skipif (not hasattr (os , 'fspath' ), reason = 'No os.fspath support.' )
1922
1920
def test_fspath (lop ):
1923
- assert os .fspath (lop .Proxy (lambda : '/tmp ' )) == '/tmp '
1924
- assert os .fspath (lop .Proxy (FSPathMock )) == '/tmp '
1921
+ assert os .fspath (lop .Proxy (lambda : '/foobar ' )) == '/foobar '
1922
+ assert os .fspath (lop .Proxy (FSPathMock )) == '/foobar '
1925
1923
with pytest .raises (TypeError ) as excinfo :
1926
1924
os .fspath (lop .Proxy (lambda : None ))
1927
1925
assert '__fspath__() to return str or bytes, not NoneType' in excinfo .value .args [0 ]
1928
1926
1929
1927
1930
1928
def test_fspath_method (lop ):
1931
- assert lop .Proxy (FSPathMock ).__fspath__ () == '/tmp '
1929
+ assert lop .Proxy (FSPathMock ).__fspath__ () == '/foobar '
1932
1930
1933
1931
1934
1932
def test_resolved_new (lop ):
0 commit comments