Nitpick logging calls

This commit is contained in:
Nguyễn Gia Phong 2020-06-10 23:11:28 +07:00
parent 2c8645276f
commit cb8d81d135
10 changed files with 10 additions and 25 deletions

View File

@ -12,7 +12,6 @@ pass on state. To be consistent, all options will follow this design.
from __future__ import absolute_import
import logging
import os
import textwrap
import warnings
@ -35,8 +34,6 @@ if MYPY_CHECK_RUNNING:
from optparse import OptionParser, Values
from pip._internal.cli.parser import ConfigOptionParser
logger = logging.getLogger(__name__)
def raise_option_error(parser, option, msg):
# type: (OptionParser, Option, str) -> None

View File

@ -266,10 +266,8 @@ class ConfigurationCommand(Command):
try:
self.configuration.save()
except Exception:
logger.error(
"Unable to save configuration. Please report this as a bug.",
exc_info=True
)
logger.exception("Unable to save configuration. "
"Please report this as a bug.")
raise PipError("Internal Error.")
def _determine_editor(self, options):

View File

@ -240,7 +240,7 @@ class InstallCommand(RequirementCommand):
install_options = options.install_options or []
logger.debug("Using {}".format(get_pip_version()))
logger.debug("Using %s", get_pip_version())
options.use_user_site = decide_user_install(
options.use_user_site,
prefix_path=options.prefix_path,
@ -509,10 +509,9 @@ class InstallCommand(RequirementCommand):
try:
return check_install_conflicts(to_install)
except Exception:
logger.error(
logger.exception(
"Error while checking for conflicts. Please file an issue on "
"pip's issue tracker: https://github.com/pypa/pip/issues/new",
exc_info=True
"pip's issue tracker: https://github.com/pypa/pip/issues/new"
)
return None

View File

@ -1,7 +1,6 @@
"""Metadata generation logic for source distributions.
"""
import logging
import os
from pip._internal.utils.subprocess import runner_with_spinner_message
@ -12,8 +11,6 @@ if MYPY_CHECK_RUNNING:
from pip._internal.build_env import BuildEnvironment
from pip._vendor.pep517.wrappers import Pep517HookCaller
logger = logging.getLogger(__name__)
def generate_metadata(build_env, backend):
# type: (BuildEnvironment, Pep517HookCaller) -> str

View File

@ -27,7 +27,7 @@ def build_wheel_pep517(
if build_options:
# PEP 517 does not support --build-options
logger.error('Cannot build wheel for %s using PEP 517 when '
'--build-option is present' % (name,))
'--build-option is present', name)
return None
try:
logger.debug('Destination directory: %s', tempd)

View File

@ -438,7 +438,7 @@ class Resolver(BaseResolver):
)
for missing in missing_requested:
logger.warning(
'%s does not provide the extra \'%s\'',
"%s does not provide the extra '%s'",
dist, missing
)

View File

@ -121,10 +121,8 @@ def str_to_display(data, desc=None):
try:
decoded_data = data.decode(encoding)
except UnicodeDecodeError:
if desc is None:
desc = 'Bytes object'
msg_format = '{} does not appear to be encoded as %s'.format(desc)
logger.warning(msg_format, encoding)
logger.warning('%s does not appear to be encoded as %s',
desc or 'Bytes object', encoding)
decoded_data = data.decode(encoding, errors=backslashreplace_decode)
# Make sure we can print the output, by encoding it to the output

View File

@ -3,7 +3,6 @@
from __future__ import absolute_import
import logging
import re
from pip._vendor.packaging.tags import (
@ -23,8 +22,6 @@ if MYPY_CHECK_RUNNING:
from pip._vendor.packaging.tags import PythonVersion
logger = logging.getLogger(__name__)
_osx_arch_pat = re.compile(r'(.+)_(\d+)_(\d+)_(.+)')

View File

@ -125,8 +125,7 @@ def test_console_to_str_warning(monkeypatch):
some_bytes = b"a\xE9b"
def check_warning(msg, *args, **kwargs):
assert msg.startswith(
"Subprocess output does not appear to be encoded as")
assert args[0] == 'Subprocess output'
monkeypatch.setattr(locale, 'getpreferredencoding', lambda: 'utf-8')
monkeypatch.setattr(pip_compat.logger, 'warning', check_warning)