Mercurial > public > mercurial-scm > hg-stable
diff mercurial/store.py @ 52669: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 | 5cc8deb96b48 |
children | 4cb75772818d |
line wrap: on
line diff
--- a/mercurial/store.py Sun Jan 05 22:23:31 2025 -0500 +++ b/mercurial/store.py Sun Jan 05 22:26:16 2025 -0500 @@ -126,12 +126,9 @@ these characters will be escaped by encodefunctions """ winreserved = [ord(x) for x in '\\:*?"<>|'] - for x in range(32): - yield x - for x in range(126, 256): - yield x - for x in winreserved: - yield x + yield from range(32) + yield from range(126, 256) + yield from winreserved def _buildencodefun(): @@ -928,10 +925,8 @@ are passed with matches the matcher """ # yield data files first - for x in self.data_entries(matcher): - yield x - for x in self.top_entries(phase=phase, obsolescence=obsolescence): - yield x + yield from self.data_entries(matcher) + yield from self.top_entries(phase=phase, obsolescence=obsolescence) def copylist(self): return _data