Mercurial > public > mercurial-scm > hg
comparison hgext/git/manifest.py @ 52644:e627cc25b6f3
pyupgrade: rewrite `yield` statements in a loop to `yield from`
This is the `legacy` fixer in `pyupgrade`, with the `yield` statement yielding
loop commented back in. This seems to help pytype in some cases, and hurt it in
others. But that can be manually fixed later.
Note that it's possibly buggy in that it aggressively changed `import-checker.py`
to `yield from 'fcntl', 'grp', 'pwd', 'select', 'termios': # Unix only`, which
is invalid syntax. Possibly it needed help from the token fixer that I've
disabled locally (because that wants to make a bunch of unrelated changes).
Just change those few places to yield from a list, to avoid having to constantly
revert that.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 05 Jan 2025 22:26:16 -0500 |
parents | 2b65c9228dc0 |
children | 4cb75772818d |
comparison
equal
deleted
inserted
replaced
52643:5cc8deb96b48 | 52644:e627cc25b6f3 |
---|---|
275 def _walkonetree(self, tree, match, subdir): | 275 def _walkonetree(self, tree, match, subdir): |
276 for te in tree: | 276 for te in tree: |
277 # TODO: can we prune dir walks with the matcher? | 277 # TODO: can we prune dir walks with the matcher? |
278 realname = subdir + pycompat.fsencode(te.name) | 278 realname = subdir + pycompat.fsencode(te.name) |
279 if te.type == pygit2.GIT_OBJ_TREE: | 279 if te.type == pygit2.GIT_OBJ_TREE: |
280 for inner in self._walkonetree( | 280 yield from self._walkonetree( |
281 self._git_repo[te.id], match, realname + b'/' | 281 self._git_repo[te.id], match, realname + b'/' |
282 ): | 282 ) |
283 yield inner | |
284 elif match(realname): | 283 elif match(realname): |
285 yield pycompat.fsencode(realname) | 284 yield pycompat.fsencode(realname) |
286 | 285 |
287 def walk(self, match: matchmod.basematcher) -> Iterator[bytes]: | 286 def walk(self, match: matchmod.basematcher) -> Iterator[bytes]: |
288 # TODO: this is a very lazy way to merge in the pending | 287 # TODO: this is a very lazy way to merge in the pending |