Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pypi.py #1559

Closed
wants to merge 6 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,17 +450,17 @@ def _setup_logging(self) -> None:

# Sync pip's console handler stream with LogContext.stream
logger = logging.getLogger()
for handler in logger.handlers:
if handler.name == "console": # pragma: no branch
assert isinstance(handler, logging.StreamHandler)
handler.stream = log.stream
break
else: # pragma: no cover
logger_names = [x.name for x in logger.handlers]
if "console" not in logger_names: # pragma: no cover
# There is always a console handler. This warning would be a signal that
# this block should be removed/revisited, because of pip possibly
# refactored-out logging config.
log.warning("Couldn't find a 'console' logging handler")

else:
for handler in logger.handlers:
if isinstance(handler, logging.StreamHandler):
handler.stream = log.stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this is expected to suppress the error, this would lead to not assigning log.stream to the relevant handler anymore as it's now a different type

break
# Sync pip's progress bars stream with LogContext.stream
for bar_cls in itertools.chain(*BAR_TYPES.values()):
bar_cls.file = log.stream
Expand Down