Skip to content

Commit 4a1b53d

Browse files
committed
Accept suggestions from new toolchain
1 parent 25972ea commit 4a1b53d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

impall/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_all(self) -> None:
150150
failed_to_fail = [m for m in successes if m in expected]
151151

152152
if failed_to_fail:
153-
print('Didn\'t fail when expected:', *sorted(failed_to_fail))
153+
print("Didn't fail when expected:", *sorted(failed_to_fail))
154154

155155
first = True
156156
for module, ex in failed:
@@ -171,7 +171,7 @@ def impall(self) -> t.Tuple[t.List[str], t.List[t.Tuple[str, str]]]:
171171
failures: t.List[t.Tuple[str, str]] = []
172172
paths = _split(self.PATHS or path_to_import(os.getcwd())[0])
173173

174-
warnings.simplefilter(self.WARNINGS_ACTION) # type: ignore[arg-type]
174+
warnings.simplefilter(self.WARNINGS_ACTION)
175175
for file in self._all_imports(paths):
176176
self._import(file, successes, failures)
177177

@@ -192,7 +192,12 @@ def _all_imports(self, paths: t.Sequence[str]) -> t.Iterator[str]:
192192
if f.endswith('.py') and not _is_ignored(f):
193193
yield os.path.join(directory, f)
194194

195-
def _import(self, file: str, successes: t.List[str], failures: t.List[t.Tuple[str, str]]) -> None:
195+
def _import(
196+
self,
197+
file: str,
198+
successes: t.List[str],
199+
failures: t.List[t.Tuple[str, str]],
200+
) -> None:
196201
root, module = path_to_import(file)
197202
path = file[:-3] if file.endswith('.py') else file
198203

@@ -230,7 +235,7 @@ def _accept_dir(self, directory: str) -> bool:
230235
return not _is_ignored(directory)
231236

232237

233-
@functools.lru_cache()
238+
@functools.lru_cache
234239
def path_to_import(path: str) -> t.Tuple[str, str]:
235240
"""
236241
Return a (path, module) pair that allows you to import the Python file or
@@ -332,7 +337,7 @@ def report() -> None:
332337
print()
333338

334339
if failures:
335-
fail = ['%s (%s)' % (m, e) for (m, e) in failures]
340+
fail = [f'{m} ({e})' for (m, e) in failures]
336341
print('Failures', *fail, sep='\n ', file=sys.stderr)
337342
print(file=sys.stderr)
338343

test/test_impall.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import impall
21
import os
32
import pathlib
43
import unittest
54

5+
import impall
6+
67

78
class PropertiesTest(impall.ImpAllTest):
89
PATHS = str(pathlib.Path(__file__).parent / 'edge' / 'edge')
@@ -41,7 +42,7 @@ def test_one(self):
4142
assert actual == ('test/edge', 'edge.yes')
4243

4344
def test_two(self):
44-
assert impall.path_to_import('impall.py') == ('', 'impall')
45+
assert impall.path_to_import('impall/__init__.py') == ('', 'impall.__init__')
4546

4647
def test_three(self):
4748
root = 'test/edge/deep/one/two/three/four/five/six.py'

0 commit comments

Comments
 (0)