comparison mercurial/store.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 4cb75772818d
comparison
equal deleted inserted replaced
52643:5cc8deb96b48 52644:e627cc25b6f3
124 * windows specials 124 * windows specials
125 125
126 these characters will be escaped by encodefunctions 126 these characters will be escaped by encodefunctions
127 """ 127 """
128 winreserved = [ord(x) for x in '\\:*?"<>|'] 128 winreserved = [ord(x) for x in '\\:*?"<>|']
129 for x in range(32): 129 yield from range(32)
130 yield x 130 yield from range(126, 256)
131 for x in range(126, 256): 131 yield from winreserved
132 yield x
133 for x in winreserved:
134 yield x
135 132
136 133
137 def _buildencodefun(): 134 def _buildencodefun():
138 """ 135 """
139 >>> enc, dec = _buildencodefun() 136 >>> enc, dec = _buildencodefun()
926 923
927 if a matcher is passed, storage files of only those tracked paths 924 if a matcher is passed, storage files of only those tracked paths
928 are passed with matches the matcher 925 are passed with matches the matcher
929 """ 926 """
930 # yield data files first 927 # yield data files first
931 for x in self.data_entries(matcher): 928 yield from self.data_entries(matcher)
932 yield x 929 yield from self.top_entries(phase=phase, obsolescence=obsolescence)
933 for x in self.top_entries(phase=phase, obsolescence=obsolescence):
934 yield x
935 930
936 def copylist(self): 931 def copylist(self):
937 return _data 932 return _data
938 933
939 def write(self, tr): 934 def write(self, tr):