Skip to content

Commit

Permalink
Update message type to configparser.Error
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshks committed May 23, 2020
1 parent 71c0fb0 commit 217d808
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
if MYPY_CHECK_RUNNING:
from typing import Optional, List, Dict
from pip._vendor.pkg_resources import Distribution
from pip._vendor.six.moves import configparser
from pip._internal.req.req_install import InstallRequirement
from pip._vendor.six import PY3
if PY3:
Expand Down Expand Up @@ -312,7 +313,7 @@ class ConfigurationFileCouldNotBeLoaded(ConfigurationError):
"""

def __init__(self, reason="could not be loaded", fname=None, error=None):
# type: (str, Optional[str], Optional[Exception]) -> None
# type: (str, Optional[str], Optional[configparser.Error]) -> None
super(ConfigurationFileCouldNotBeLoaded, self).__init__(error)
self.reason = reason
self.fname = fname
Expand All @@ -324,6 +325,7 @@ def __str__(self):
message_part = " in {}.".format(self.fname)
else:
assert self.error is not None
# message attribute for Exception is only available for Python 2
# configparser.Error is missing "message" attribute in typeshed
# for python 3 (https://github.com/python/typeshed/issues/4058)
message_part = ".\n{}\n".format(self.error.message) # type: ignore
return "Configuration file {}{}".format(self.reason, message_part)

0 comments on commit 217d808

Please sign in to comment.