-
-
Notifications
You must be signed in to change notification settings - Fork 954
Commit a36b8a5
committed
Always use a
This stops listing Ruff rule `E731` ("Do not assign a `lambda`
expression, use a `def`") as ignored, and fixes all occurrences of
it:
- Spacing is manually adjusted so that readability is not harmed,
while still satisfying the current formatting conventions.
- Although the affected test modules do not currently use type
annotations, the non-test modules do. Some of the lambdas already
had type annotations, by annotating the variable itself with an
expression formed by subscripting `Callable`. This change
preserves them, converting them to paramter and return type
annotations in the resulting `def`. Where such type annotations
were absent (in lambdas in non-test modules), or partly absent,
all missing annotations are added to the `def`.
- Unused paramters are prefixed with a `_`.
- `IndexFile.checkout` assigned a lambda to `make_exc`, whose body
was somewhat difficult to read. Separately from converting it to
a `def`, this refactors the expression in the `return` statement
to use code like `(x, *ys)` in place of `(x,) + tuple(ys)`.
This change does not appear to have introduced (nor fixed) any
`mypy` errors.
This only affects lambdas that were assigned directly to variables.
Other lambda expressions remain unchanged.def
instead of assigning a lambda
1 parent 6f4f7f5 commit a36b8a5
File tree
6 files changed
+36
-10
lines changed- git
- index
- objects
- test
6 files changed
+36
-10
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
530 | 530 |
| |
531 | 531 |
| |
532 | 532 |
| |
533 | - | ||
533 | + | ||
534 | + | ||
535 | + | ||
536 | + | ||
534 | 537 |
| |
535 | 538 |
| |
536 | 539 |
| |
| |||
690 | 693 |
| |
691 | 694 |
| |
692 | 695 |
| |
696 | + | ||
693 | 697 |
| |
694 | 698 |
| |
695 | 699 |
| |
696 | - | ||
700 | + | ||
701 | + | ||
697 | 702 |
| |
698 | - | ||
703 | + | ||
704 | + | ||
705 | + | ||
706 | + | ||
699 | 707 |
| |
700 | 708 |
| |
701 | 709 |
| |
| |||
1336 | 1344 |
| |
1337 | 1345 |
| |
1338 | 1346 |
| |
1347 | + | ||
1339 | 1348 |
| |
1340 | - | ||
1349 | + | ||
1350 | + | ||
1351 | + | ||
1341 | 1352 |
| |
1342 | 1353 |
| |
1343 | 1354 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 | - | ||
53 | + | ||
54 | + | ||
55 | + | ||
54 | 56 |
| |
55 | 57 |
| |
56 | 58 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
69 | - | ||
69 | + | ||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
246 | + | ||
246 | 247 |
| |
247 | 248 |
| |
248 | 249 |
| |
| |||
251 | 252 |
| |
252 | 253 |
| |
253 | 254 |
| |
254 | - | ||
255 | + | ||
256 | + | ||
257 | + | ||
258 | + | ||
255 | 259 |
| |
256 | 260 |
| |
257 | 261 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
330 | 330 |
| |
331 | 331 |
| |
332 | 332 |
| |
333 | - | ||
333 | + | ||
334 | + | ||
335 | + | ||
336 | + | ||
334 | 337 |
| |
335 | 338 |
| |
336 | 339 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
129 | - | ||
129 | + | ||
130 | + | ||
131 | + | ||
132 | + | ||
130 | 133 |
| |
131 | 134 |
| |
132 | 135 |
| |
133 | 136 |
| |
134 | - | ||
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | ||
135 | 141 |
| |
136 | 142 |
| |
137 | 143 |
| |
|
0 commit comments