summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2021-03-07 07:40:11 -0500
committerGitHub <noreply@github.com>2021-03-07 13:40:11 +0100
commit0a956d473d5c215c3248df98dc0272005116c55b (patch)
tree4ba0dada00f6ca49b57adb7a57561b62ef002adf
parent31b9eded5a8891406bd1a85a3e899d9ef30511c6 (diff)
downloadpylint-git-0a956d473d5c215c3248df98dc0272005116c55b.tar.gz
Print helpful error when toml decode fails (#4176)
* Print helpful error when toml decode fails If loading a TOML config file fails, print the issue with the TOML file rather than dumping stack. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--pylint/config/find_default_config_files.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index cad49c23c..9932c5553 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -455,6 +455,8 @@ contributors:
* Louis Sautier: contributor
+* Quentin Young: contributor
+
* Alexander Kapshuna: contributor
* Mark Byrne: contributor
diff --git a/pylint/config/find_default_config_files.py b/pylint/config/find_default_config_files.py
index 92d333f0f..126ac4a1e 100644
--- a/pylint/config/find_default_config_files.py
+++ b/pylint/config/find_default_config_files.py
@@ -5,11 +5,17 @@ import configparser
import os
import toml
+from toml.decoder import TomlDecodeError
def _toml_has_config(path):
with open(path) as toml_handle:
- content = toml.load(toml_handle)
+ try:
+ content = toml.load(toml_handle)
+ except TomlDecodeError as error:
+ print("Failed to load '{}': {}".format(path, str(error)))
+ return False
+
try:
content["tool"]["pylint"]
except KeyError: