Skip to content

Commit b8e223a

Browse files
committed
Fix a bunch of lint issues.
1 parent ff7459e commit b8e223a

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

pyproject.toml

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[build-system]
22
requires = [
3-
"setuptools>=30.3.0",
4-
"setuptools_scm>=3.3.1",
3+
"setuptools>=64",
4+
"setuptools_scm>=8",
55
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[tool.setuptools_scm]
69

710
[tool.ruff.per-file-ignores]
811
"ci/*" = ["S"]
@@ -14,6 +17,11 @@ ignore = [
1417
"S101", # flake8-bandit assert
1518
"S308", # flake8-bandit suspicious-mark-safe-usage
1619
"E501", # pycodestyle line-too-long
20+
"DTZ001",
21+
"PT011",
22+
"PT012",
23+
"B004",
24+
"S102",
1725
]
1826
line-length = 140
1927
select = [

src/lazy_object_proxy/slots.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def __wrapped__(self, __getattr__=object.__getattribute__, __setattr__=object.__
9898
except AttributeError:
9999
try:
100100
factory = __getattr__(self, '__factory__')
101-
except AttributeError:
102-
raise ValueError("Proxy hasn't been initiated: __factory__ is missing.")
101+
except AttributeError as exc:
102+
raise ValueError("Proxy hasn't been initiated: __factory__ is missing.") from exc
103103
target = factory()
104104
__setattr__(self, '__target__', target)
105105
return target

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FakeModule:
3030
else:
3131
raise RuntimeError('Unsupported param: %r.' % name)
3232

33-
Proxy
33+
Proxy # noqa: B018
3434

3535
return FakeModule
3636

@@ -63,7 +63,7 @@ class submod(lop_implementation):
6363
return lop_implementation
6464

6565

66-
@pytest.fixture(scope='function')
66+
@pytest.fixture
6767
def lop(request, lop_subclass):
6868
if request.node.get_closest_marker('xfail_subclass'):
6969
request.applymarker(

tests/test_async_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ async def foo():
249249
aw = coro.__await__()
250250
next(aw)
251251
with pytest.raises(ZeroDivisionError):
252-
aw.throw(ZeroDivisionError, None, None)
252+
aw.throw(ZeroDivisionError)
253253
assert N == 102
254254

255255

tests/test_lazy_object_proxy.py

+13-15
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ def test_iteration(lop):
771771

772772
wrapper = lop.Proxy(lambda: items)
773773

774-
result = [x for x in wrapper]
774+
result = [x for x in wrapper] # noqa: C416
775775

776776
assert result == items
777777

@@ -816,13 +816,11 @@ def function1(*args, **kwargs):
816816

817817
function2 = lop.Proxy(lambda: function1)
818818

819-
table = dict()
820-
table[function1] = True
819+
table = {function1: True}
821820

822821
assert table.get(function2)
823822

824-
table = dict()
825-
table[function2] = True
823+
table = {function2: True}
826824

827825
assert table.get(function1)
828826

@@ -1458,12 +1456,12 @@ def test_repr_doesnt_consume(lop):
14581456
def test_derived_new(lop):
14591457
class DerivedObjectProxy(lop.Proxy):
14601458
def __new__(cls, wrapped):
1461-
instance = super(DerivedObjectProxy, cls).__new__(cls)
1459+
instance = super().__new__(cls)
14621460
instance.__init__(wrapped)
14631461
return instance
14641462

14651463
def __init__(self, wrapped):
1466-
super(DerivedObjectProxy, self).__init__(wrapped)
1464+
super().__init__(wrapped)
14671465

14681466
def function():
14691467
return 123
@@ -1540,9 +1538,9 @@ class DerivedObjectProxy(lop.Proxy):
15401538
def __getattr__(self, name):
15411539
accessed.append(name)
15421540
try:
1543-
__getattr__ = super(DerivedObjectProxy, self).__getattr__
1541+
__getattr__ = super().__getattr__
15441542
except AttributeError as e:
1545-
raise RuntimeError(str(e))
1543+
raise RuntimeError(str(e)) from e
15461544
return __getattr__(name)
15471545

15481546
function.attribute = 1
@@ -1884,7 +1882,7 @@ class LazyProxy(lop.Proxy):
18841882
name = None
18851883

18861884
def __init__(self, func, **lazy_attr):
1887-
super(LazyProxy, self).__init__(func)
1885+
super().__init__(func)
18881886
for attr, val in lazy_attr.items():
18891887
setattr(self, attr, val)
18901888

@@ -1904,7 +1902,7 @@ class Foo:
19041902

19051903
class LazyProxy(lop.Proxy):
19061904
def __init__(self, func, **lazy_attr):
1907-
super(LazyProxy, self).__init__(func)
1905+
super().__init__(func)
19081906
for attr, val in lazy_attr.items():
19091907
object.__setattr__(self, attr, val)
19101908

@@ -1915,20 +1913,20 @@ def __init__(self, func, **lazy_attr):
19151913

19161914
class FSPathMock:
19171915
def __fspath__(self):
1918-
return '/tmp'
1916+
return '/foobar'
19191917

19201918

19211919
@pytest.mark.skipif(not hasattr(os, 'fspath'), reason='No os.fspath support.')
19221920
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'
19251923
with pytest.raises(TypeError) as excinfo:
19261924
os.fspath(lop.Proxy(lambda: None))
19271925
assert '__fspath__() to return str or bytes, not NoneType' in excinfo.value.args[0]
19281926

19291927

19301928
def test_fspath_method(lop):
1931-
assert lop.Proxy(FSPathMock).__fspath__() == '/tmp'
1929+
assert lop.Proxy(FSPathMock).__fspath__() == '/foobar'
19321930

19331931

19341932
def test_resolved_new(lop):

0 commit comments

Comments
 (0)