comparison mercurial/hgweb/hgwebdir_mod.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 24ee91ba9aa8
children
comparison
equal deleted inserted replaced
52668:5cc8deb96b48 52669:e627cc25b6f3
380 380
381 def run_wsgi(self, req, res): 381 def run_wsgi(self, req, res):
382 profile = self.ui.configbool(b'profiling', b'enabled') 382 profile = self.ui.configbool(b'profiling', b'enabled')
383 with profiling.profile(self.ui, enabled=profile): 383 with profiling.profile(self.ui, enabled=profile):
384 try: 384 try:
385 for r in self._runwsgi(req, res): 385 yield from self._runwsgi(req, res)
386 yield r
387 finally: 386 finally:
388 # There are known cycles in localrepository that prevent 387 # There are known cycles in localrepository that prevent
389 # those objects (and tons of held references) from being 388 # those objects (and tons of held references) from being
390 # collected through normal refcounting. 389 # collected through normal refcounting.
391 # In some cases, the resulting memory consumption can 390 # In some cases, the resulting memory consumption can
450 return self.makeindex(req, res, tmpl, subdir) 449 return self.makeindex(req, res, tmpl, subdir)
451 450
452 def _virtualdirs(): 451 def _virtualdirs():
453 # Check the full virtual path, and each parent 452 # Check the full virtual path, and each parent
454 yield virtual 453 yield virtual
455 for p in pathutil.finddirs(virtual): 454 yield from pathutil.finddirs(virtual)
456 yield p
457 455
458 for virtualrepo in _virtualdirs(): 456 for virtualrepo in _virtualdirs():
459 real = repos.get(virtualrepo) 457 real = repos.get(virtualrepo)
460 if real: 458 if real:
461 # Re-parse the WSGI environment to take into account our 459 # Re-parse the WSGI environment to take into account our