summaryrefslogtreecommitdiff
path: root/sphinx/config.py
diff options
context:
space:
mode:
authorPaul Melnikow <email@paulmelnikow.com>2018-10-02 14:20:21 -0400
committerPaul Melnikow <email@paulmelnikow.com>2018-10-02 14:20:36 -0400
commite792279791b0ea2581859bfd8cd29656911ff097 (patch)
treec2501cb234bec6855cde3c78eb8cf390a92563e3 /sphinx/config.py
parentc206c02a57e70429f39c38953f56df05c47718f8 (diff)
downloadsphinx-git-e792279791b0ea2581859bfd8cd29656911ff097.tar.gz
Improve error message when config fails type check
The old message printed wrapped brackets around the type name, which would make you think it required an array.
Diffstat (limited to 'sphinx/config.py')
-rw-r--r--sphinx/config.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/sphinx/config.py b/sphinx/config.py
index 0c0cad1fc..daa81f17e 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -395,8 +395,8 @@ def convert_source_suffix(app, config):
# if dict, convert it to OrderedDict
config.source_suffix = OrderedDict(config.source_suffix) # type: ignore
else:
- logger.warning(__("The config value `source_suffix' expected to "
- "a string, list of strings or dictionary. "
+ logger.warning(__("The config value `source_suffix' expects "
+ "a string, list of strings, or dictionary. "
"But `%r' is given." % source_suffix))
@@ -463,11 +463,16 @@ def check_confval_types(app, config):
continue # at least we share a non-trivial base class
if annotations:
- msg = __("The config value `{name}' has type `{current.__name__}', "
- "expected to {permitted}.")
+ msg = __("The config value `{name}' has type `{current.__name__}'; "
+ "expected {permitted}.")
+ wrapped_annotations = ["`{}'".format(c.__name__) for c in annotations]
+ if len(wrapped_annotations) > 2:
+ permitted = ", ".join(wrapped_annotations[:-1]) + ", or " + wrapped_annotations[-1]
+ else:
+ permitted = " or ".join(wrapped_annotations)
logger.warning(msg.format(name=confval.name,
current=type(confval.value),
- permitted=str([c.__name__ for c in annotations])))
+ permitted=permitted))
else:
msg = __("The config value `{name}' has type `{current.__name__}', "
"defaults to `{default.__name__}'.")