comparison mercurial/templateutil.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
comparison
equal deleted inserted replaced
52668:5cc8deb96b48 52669:e627cc25b6f3
869 elif i is None: 869 elif i is None:
870 pass 870 pass
871 elif not hasattr(i, '__iter__'): 871 elif not hasattr(i, '__iter__'):
872 yield pycompat.bytestr(i) 872 yield pycompat.bytestr(i)
873 else: 873 else:
874 for j in flatten(context, mapping, i): 874 yield from flatten(context, mapping, i)
875 yield j
876 875
877 876
878 def stringify(context, mapping, thing): 877 def stringify(context, mapping, thing):
879 """Turn values into bytes by converting into text and concatenating them""" 878 """Turn values into bytes by converting into text and concatenating them"""
880 if isinstance(thing, bytes): 879 if isinstance(thing, bytes):