Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.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 | f071b18e1382 |
comparison
equal
deleted
inserted
replaced
52668:5cc8deb96b48 | 52669:e627cc25b6f3 |
---|---|
1532 def ancestor(self, c2): | 1532 def ancestor(self, c2): |
1533 """return the "best" ancestor context of self and c2""" | 1533 """return the "best" ancestor context of self and c2""" |
1534 return self._parents[0].ancestor(c2) # punt on two parents for now | 1534 return self._parents[0].ancestor(c2) # punt on two parents for now |
1535 | 1535 |
1536 def ancestors(self): | 1536 def ancestors(self): |
1537 for p in self._parents: | 1537 yield from self._parents |
1538 yield p | |
1539 for a in self._repo.changelog.ancestors( | 1538 for a in self._repo.changelog.ancestors( |
1540 [p.rev() for p in self._parents] | 1539 [p.rev() for p in self._parents] |
1541 ): | 1540 ): |
1542 yield self._repo[a] | 1541 yield self._repo[a] |
1543 | 1542 |