Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotoserver.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 | 1938d72e7a16 |
children |
comparison
equal
deleted
inserted
replaced
52643:5cc8deb96b48 | 52644:e627cc25b6f3 |
---|---|
285 name = engine.wireprotosupport().name | 285 name = engine.wireprotosupport().name |
286 assert 0 < len(name) < 256 | 286 assert 0 < len(name) < 256 |
287 yield struct.pack(b'B', len(name)) | 287 yield struct.pack(b'B', len(name)) |
288 yield name | 288 yield name |
289 | 289 |
290 for chunk in gen: | 290 yield from gen |
291 yield chunk | |
292 | 291 |
293 def setresponse(code, contenttype, bodybytes=None, bodygen=None): | 292 def setresponse(code, contenttype, bodybytes=None, bodygen=None): |
294 if code == HTTP_OK: | 293 if code == HTTP_OK: |
295 res.status = b'200 Script output follows' | 294 res.status = b'200 Script output follows' |
296 else: | 295 else: |