From 9865035944f4a4d2c9cf3dc6ba9c77a98e9fc989 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Sat, 25 Apr 2020 10:28:12 +0700 Subject: [PATCH] Refactor to for-else block (#1117) --- piptools/repositories/pypi.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/piptools/repositories/pypi.py b/piptools/repositories/pypi.py index 9c4bff01b..76a1fd89c 100644 --- a/piptools/repositories/pypi.py +++ b/piptools/repositories/pypi.py @@ -440,11 +440,10 @@ def _setup_logging(self): # Sync pip's console handler stream with LogContext.stream logger = logging.getLogger() - console_handlers = [ - handler for handler in logger.handlers if handler.name == "console" - ] - if console_handlers: # pragma: no branch - console_handlers[0].stream = log.stream + for handler in logger.handlers: + if handler.name == "console": # pragma: no branch + handler.stream = log.stream + break else: # 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