Skip to content

Commit

Permalink
Evade tqdm/tqdm#1517 on Py3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Oct 11, 2023
1 parent 7fc7aeb commit a7b53a2
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions venvs/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from importlib import metadata
import subprocess
import sys
import warnings

from filesystems.exceptions import FileExists, FileNotFound
from tqdm import tqdm
Expand Down Expand Up @@ -113,21 +114,26 @@ def main(filesystem, locator, link_dir, handle_error, venvs):

def _loop(filesystem, locator, handle_error):
config = Config.from_locator(filesystem=filesystem, locator=locator)
progress = tqdm(iterable=config, total=len(config), unit="venv")
iterable = iter(progress)
while True:
try:
venv_config = next(iterable)
except StopIteration:
return
except Exception:
handle_error(virtualenv=None, name=None)
else:
progress.set_description(venv_config.name)
venv = locator.for_name(name=venv_config.name)
if venv_config.matches_existing(venv, filesystem=filesystem):
continue
yield venv_config, venv

# REMOVEME: When tqdm/tqdm#1517 is closed.
with warnings.catch_warnings():
warnings.simplefilter("ignore")
progress = tqdm(iterable=config, total=len(config), unit="venv")

iterable = iter(progress)
while True:
try:
venv_config = next(iterable)
except StopIteration:
return
except Exception:
handle_error(virtualenv=None, name=None)
else:
progress.set_description(venv_config.name)
venv = locator.for_name(name=venv_config.name)
if venv_config.matches_existing(venv, filesystem=filesystem):
continue
yield venv_config, venv


def _link(source, to, filesystem):
Expand Down

0 comments on commit a7b53a2

Please sign in to comment.