Mercurial > public > mercurial-scm > hg
comparison mercurial/logexchange.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 | f4733654f144 |
children |
comparison
equal
deleted
inserted
replaced
52643:5cc8deb96b48 | 52644:e627cc25b6f3 |
---|---|
56 yields a tuple (node, remotepath, name). It does not yields information | 56 yields a tuple (node, remotepath, name). It does not yields information |
57 about whether an entry yielded is branch or bookmark. To get that | 57 about whether an entry yielded is branch or bookmark. To get that |
58 information, call the respective functions. | 58 information, call the respective functions. |
59 """ | 59 """ |
60 | 60 |
61 for bmentry in readremotenamefile(repo, b'bookmarks'): | 61 yield from readremotenamefile(repo, b'bookmarks') |
62 yield bmentry | 62 yield from readremotenamefile(repo, b'branches') |
63 for branchentry in readremotenamefile(repo, b'branches'): | |
64 yield branchentry | |
65 | 63 |
66 | 64 |
67 def writeremotenamefile(repo, remotepath, names, nametype): | 65 def writeremotenamefile(repo, remotepath, names, nametype): |
68 vfs = vfsmod.vfs(repo.vfs.join(remotenamedir)) | 66 vfs = vfsmod.vfs(repo.vfs.join(remotenamedir)) |
69 f = vfs(nametype, b'w', atomictemp=True) | 67 f = vfs(nametype, b'w', atomictemp=True) |