Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97d9b65

Browse files
committed
Apply intended suppression in Tree.traverse
The superclass _traverse method call in Tree.traverse appears tohave once had a working suppression for the incompatbile types oftwo arguments, `predicate` and `prune`, as well as for an argumentthat required (and requires) no suppression, `depth`. These threearguments were written on the same line, which bad a `type: ignore`comment on it. But when black formatting was applied in21ec529(#1442), that comment moved so that it was on a line with just the`depth` call that didn't need it, rather than the others that did.Since then, mypy has reported errors, which further seem intendedto suppress based on the surrounding context and the use of `cast`to deal with the static type incompatibilities going the other way.This misplaced suppression was one of the ones I very recentlyremoved in84fc806. But really there should be a suppression forthose arguments (at least for now, while the code remains writtenthat way, given that a suppression is intended).This suppresses the error effectively by inserting two suppressioncomments, one for each of the two arguments. This is more specificthan a single suppression applying to the whole call, and keepingthe arguments on separate lines both makes black happy and makesclear that it is not by coincidence that the error is suppressedfor both of them. The new suppressions are also written for thespecific mypy error at issue, rather than fully general as before.This change decreases the number of mypy errors by two.
1 parent96ecc2e commit97d9b65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎git/objects/tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def traverse(
329329
returncast(
330330
Union[Iterator[IndexObjUnion],Iterator[TraversedTreeTup]],
331331
super()._traverse(
332-
predicate,
333-
prune,
332+
predicate,# type: ignore[arg-type]
333+
prune,# type: ignore[arg-type]
334334
depth,
335335
branch_first,
336336
visit_once,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp