Skip to content

Commit 217d808

Browse files
committed
Update message type to configparser.Error
1 parent 71c0fb0 commit 217d808

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/pip/_internal/exceptions.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
if MYPY_CHECK_RUNNING:
1212
from typing import Optional, List, Dict
1313
from pip._vendor.pkg_resources import Distribution
14+
from pip._vendor.six.moves import configparser
1415
from pip._internal.req.req_install import InstallRequirement
1516
from pip._vendor.six import PY3
1617
if PY3:
@@ -312,7 +313,7 @@ class ConfigurationFileCouldNotBeLoaded(ConfigurationError):
312313
"""
313314

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

0 commit comments

Comments
 (0)