Skip to content

Commit a7429ed

Browse files
[lint] PLW0108: lambda used to correctly get the mocked time via MockTiming
1 parent 45c926f commit a7429ed

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ lint.ignore = [
155155
"PLR2004", # Magic value used in comparison
156156
"PLR2044", # Line with empty comment
157157
"PLR5501", # Use `elif` instead of `else` then `if`
158-
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
159158
"PLW0120", # remove the else and dedent its contents
160159
"PLW0603", # Using the global statement
161160
"PLW1641", # Does not implement the __hash__ method

src/_pytest/timing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ class Instant:
3232

3333
# Creation time of this instant, using time.time(), to measure actual time.
3434
# Note: using a `lambda` to correctly get the mocked time via `MockTiming`.
35-
time: float = dataclasses.field(default_factory=lambda: time(), init=False)
35+
# pylint: disable-next=lambda-assignment
36+
time: float = dataclasses.field(default_factory=lambda: time(), init=False) # noqa: PLW0108
3637

3738
# Performance counter tick of the instant, used to measure precise elapsed time.
3839
# Note: using a `lambda` to correctly get the mocked time via `MockTiming`.
3940
perf_count: float = dataclasses.field(
40-
default_factory=lambda: perf_counter(), init=False
41+
default_factory=lambda: perf_counter(), # noqa: PLW0108
42+
init=False,
4143
)
4244

4345
def elapsed(self) -> Duration:

testing/_py/test_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ def test_stat_helpers(self, tmpdir, monkeypatch):
13881388

13891389
def test_stat_non_raising(self, tmpdir):
13901390
path1 = tmpdir.join("file")
1391-
pytest.raises(error.ENOENT, lambda: path1.stat())
1391+
pytest.raises(error.ENOENT, path1.stat)
13921392
res = path1.stat(raising=False)
13931393
assert res is None
13941394

0 commit comments

Comments
 (0)