Mercurial > public > mercurial-scm > hg
comparison mercurial/smartset.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 | 5cc8deb96b48 |
children |
comparison
equal
deleted
inserted
replaced
52643:5cc8deb96b48 | 52644:e627cc25b6f3 |
---|---|
542 yield val1 | 542 yield val1 |
543 it = iter1 | 543 it = iter1 |
544 elif val2 is not None: | 544 elif val2 is not None: |
545 # might have been equality and both are empty | 545 # might have been equality and both are empty |
546 yield val2 | 546 yield val2 |
547 for val in it: | 547 yield from it |
548 yield val | |
549 | 548 |
550 | 549 |
551 class addset(abstractsmartset): | 550 class addset(abstractsmartset): |
552 """Represent the addition of two sets | 551 """Represent the addition of two sets |
553 | 552 |