Skip to content

Commit 604d4fc

Browse files
authored
Merge pull request #364 from jelmer/ruff
Various linting cleanups
2 parents 87ab359 + df1883a commit 604d4fc

File tree

17 files changed

+34
-56
lines changed

17 files changed

+34
-56
lines changed

doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# All configuration values have a default; values that are commented out
1111
# serve to show the default.
1212

13-
import sys, os
1413

1514
# If extensions (or modules to document with autodoc) are in another directory,
1615
# add these directories to sys.path here. If the directory is relative to the

testtools/content.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ def content_from_stream(stream, content_type=None,
302302
"""
303303
if content_type is None:
304304
content_type = UTF8_TEXT
305-
reader = lambda: _iter_chunks(stream, chunk_size, seek_offset, seek_whence)
305+
def reader():
306+
return _iter_chunks(stream, chunk_size, seek_offset, seek_whence)
306307
return content_from_reader(reader, content_type, buffer_now)
307308

308309

@@ -319,7 +320,8 @@ def content_from_reader(reader, content_type, buffer_now):
319320
content_type = UTF8_TEXT
320321
if buffer_now:
321322
contents = list(reader())
322-
reader = lambda: contents
323+
def reader():
324+
return contents
323325
return Content(content_type, reader)
324326

325327

testtools/deferredruntest.py

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

testtools/matchers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128

129129
# XXX: These are not explicitly included in __all__. It's unclear how much of
130130
# the public interface they really are.
131-
from ._impl import (
131+
from ._impl import ( # noqa: F401
132132
Matcher,
133133
Mismatch,
134134
MismatchError,

testtools/matchers/_filesystem.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, filenames=None, matcher=None):
7171
:param matcher: If specified, match the sorted directory listing
7272
against this matcher.
7373
"""
74-
if filenames == matcher == None:
74+
if filenames == matcher is None:
7575
raise AssertionError(
7676
"Must provide one of `filenames` or `matcher`.")
7777
if None not in (filenames, matcher):
@@ -105,7 +105,7 @@ def __init__(self, contents=None, matcher=None):
105105
:param matcher: If specified, match the contents of the file against
106106
this matcher.
107107
"""
108-
if contents == matcher == None:
108+
if contents == matcher is None:
109109
raise AssertionError(
110110
"Must provide one of `contents` or `matcher`.")
111111
if None not in (contents, matcher):
@@ -163,7 +163,8 @@ def __init__(self, path):
163163
self.path = path
164164

165165
def match(self, other_path):
166-
f = lambda x: os.path.abspath(os.path.realpath(x))
166+
def f(x):
167+
return os.path.abspath(os.path.realpath(x))
167168
return Equals(f(self.path)).match(f(other_path))
168169

169170

testtools/matchers/_warnings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from ._higherorder import (
1414
AfterPreprocessing,
1515
Annotate,
16-
MatchesAll,
17-
Not,
1816
)
1917
from ._impl import Mismatch
2018

testtools/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
$ python -m testtools.run testtools.tests.test_suite
99
"""
1010

11-
import argparse
1211
from functools import partial
1312
import os.path
1413
import sys
@@ -253,7 +252,7 @@ def _get_runner(self):
253252
################
254253

255254
def main(argv, stdout):
256-
program = TestProgram(argv=argv, testRunner=partial(TestToolsTestRunner, stdout=stdout),
255+
TestProgram(argv=argv, testRunner=partial(TestToolsTestRunner, stdout=stdout),
257256
stdout=stdout)
258257

259258
if __name__ == '__main__':

testtools/testcase.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def _copy_content(content_object):
142142
``content_object`` and a non-volatile copy of its content.
143143
"""
144144
content_bytes = list(content_object.iter_bytes())
145-
content_callback = lambda: content_bytes
145+
def content_callback():
146+
return content_bytes
146147
return content.Content(content_object.content_type, content_callback)
147148

148149

testtools/tests/matchers/test_filesystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class TestTarballContains(TestCase, PathHelpers):
179179

180180
def test_match(self):
181181
tempdir = self.mkdtemp()
182-
in_temp_dir = lambda x: os.path.join(tempdir, x)
182+
def in_temp_dir(x):
183+
return os.path.join(tempdir, x)
183184
self.touch(in_temp_dir('a'))
184185
self.touch(in_temp_dir('b'))
185186
tarball = tarfile.open(in_temp_dir('foo.tar.gz'), 'w')
@@ -191,7 +192,8 @@ def test_match(self):
191192

192193
def test_mismatch(self):
193194
tempdir = self.mkdtemp()
194-
in_temp_dir = lambda x: os.path.join(tempdir, x)
195+
def in_temp_dir(x):
196+
return os.path.join(tempdir, x)
195197
self.touch(in_temp_dir('a'))
196198
self.touch(in_temp_dir('b'))
197199
tarball = tarfile.open(in_temp_dir('foo.tar.gz'), 'w')

testtools/tests/test_content.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tempfile
66
import unittest
77

8-
from testtools import TestCase, skipUnless
8+
from testtools import TestCase
99
from testtools.compat import (
1010
_b,
1111
)
@@ -55,8 +55,10 @@ def test___init___sets_ivars(self):
5555

5656
def test___eq__(self):
5757
content_type = ContentType("foo", "bar")
58-
one_chunk = lambda: [_b("bytes")]
59-
two_chunk = lambda: [_b("by"), _b("tes")]
58+
def one_chunk():
59+
return [_b("bytes")]
60+
def two_chunk():
61+
return [_b("by"), _b("tes")]
6062
content1 = Content(content_type, one_chunk)
6163
content2 = Content(content_type, one_chunk)
6264
content3 = Content(content_type, two_chunk)

0 commit comments

Comments
 (0)