diff options
author | Tanvi Moharir <74228962+tanvimoharir@users.noreply.github.com> | 2021-11-13 17:36:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-13 13:06:01 +0100 |
commit | 1a20bc5c50a7c73abaad8b364f78055d4e60146d (patch) | |
tree | cb00f346a16230cfcb960c4e3a900513e3d09210 /tests/config | |
parent | 8e15c1dd9d0dc07cb9794353a32cd37d57f2d569 (diff) | |
download | pylint-git-1a20bc5c50a7c73abaad8b364f78055d4e60146d.tar.gz |
Pylint fix for invalid TOML config (#4720)
* Fix crashes during toml configuration parsing
Add test for current 'pyproject.toml' issues. Add a 'bad-configuration-section'
message for bad toml configuration
We can detect bad top level option when reading the toml but we do not catch
all the problem in toml because we don't know what is expected so we can't
recommend. See #5259
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/config')
12 files changed, 48 insertions, 0 deletions
diff --git a/tests/config/functional/toml/issue_4580/correct_basic_name_group.toml b/tests/config/functional/toml/issue_4580/correct_basic_name_group.toml new file mode 100644 index 000000000..845f5e8bb --- /dev/null +++ b/tests/config/functional/toml/issue_4580/correct_basic_name_group.toml @@ -0,0 +1,2 @@ +[tool.pylint.basic] +name-group = { "a"="b" } diff --git a/tests/config/functional/toml/issue_4580/correct_import_preferred_module.toml b/tests/config/functional/toml/issue_4580/correct_import_preferred_module.toml new file mode 100644 index 000000000..2f8fdb555 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/correct_import_preferred_module.toml @@ -0,0 +1,2 @@ +[tool.pylint.imports] +preferred-modules = { "a"="b" } diff --git a/tests/config/functional/toml/issue_4580/empty_list.out b/tests/config/functional/toml/issue_4580/empty_list.out new file mode 100644 index 000000000..c25f99b30 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/empty_list.out @@ -0,0 +1,2 @@ +************* Module {abspath} +{relpath}:1:0: E0014: Out-of-place setting encountered in top level configuration-section 'load-plugins' : '[]' (bad-configuration-section) diff --git a/tests/config/functional/toml/issue_4580/empty_list.toml b/tests/config/functional/toml/issue_4580/empty_list.toml new file mode 100644 index 000000000..28bd65c60 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/empty_list.toml @@ -0,0 +1,3 @@ +[tool.pylint] +# load-plugins does not belong in top level section +load-plugins = [] diff --git a/tests/config/functional/toml/issue_4580/invalid_data_for_basic.out b/tests/config/functional/toml/issue_4580/invalid_data_for_basic.out new file mode 100644 index 000000000..2654d87f0 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/invalid_data_for_basic.out @@ -0,0 +1,3 @@ +************* Module {abspath} +{relpath}:1:0: E0014: Out-of-place setting encountered in top level configuration-section 'load-plugins' : '[]' (bad-configuration-section) +{relpath}:1:0: E0014: Out-of-place setting encountered in top level configuration-section 'disable' : 'logging-not-lazy,logging-format-interpolation' (bad-configuration-section) diff --git a/tests/config/functional/toml/issue_4580/invalid_data_for_basic.toml b/tests/config/functional/toml/issue_4580/invalid_data_for_basic.toml new file mode 100644 index 000000000..b2e4fe927 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/invalid_data_for_basic.toml @@ -0,0 +1,4 @@ +[tool.pylint] +# Both disable and load-plugins do not belong in the top level section +load-plugins = [] +disable = "logging-not-lazy,logging-format-interpolation" diff --git a/tests/config/functional/toml/issue_4580/invalid_data_for_import.result.json b/tests/config/functional/toml/issue_4580/invalid_data_for_import.result.json new file mode 100644 index 000000000..4805c7e54 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/invalid_data_for_import.result.json @@ -0,0 +1,5 @@ +{ + "functional_append": { + "disable": [["logging-not-lazy"], ["logging-format-interpolation"]] + } +} diff --git a/tests/config/functional/toml/issue_4580/invalid_data_for_import.toml b/tests/config/functional/toml/issue_4580/invalid_data_for_import.toml new file mode 100644 index 000000000..60af90624 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/invalid_data_for_import.toml @@ -0,0 +1,8 @@ +# Both disable and load-plugins do not belong in the imports section +# TODO This should be fixed in #5259 +[tool.pylint."imports"] +disable = [ + "logging-not-lazy", + "logging-format-interpolation", +] +preferred-modules = { "a"="b" } diff --git a/tests/config/functional/toml/issue_4580/rich_types.result.json b/tests/config/functional/toml/issue_4580/rich_types.result.json new file mode 100644 index 000000000..21938c319 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/rich_types.result.json @@ -0,0 +1,7 @@ +{ + "functional_append": { + "disable": [["logging-not-lazy"], ["logging-format-interpolation"]] + }, + "jobs": 10, + "reports": true +} diff --git a/tests/config/functional/toml/issue_4580/rich_types.toml b/tests/config/functional/toml/issue_4580/rich_types.toml new file mode 100644 index 000000000..ff46db0f5 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/rich_types.toml @@ -0,0 +1,7 @@ +[tool.pylint."messages control"] +disable = [ + "logging-not-lazy", + "logging-format-interpolation", +] +jobs = 10 +reports = true diff --git a/tests/config/functional/toml/issue_4580/top_level_disable.out b/tests/config/functional/toml/issue_4580/top_level_disable.out new file mode 100644 index 000000000..a63759758 --- /dev/null +++ b/tests/config/functional/toml/issue_4580/top_level_disable.out @@ -0,0 +1,2 @@ +************* Module {abspath} +{relpath}:1:0: E0014: Out-of-place setting encountered in top level configuration-section 'disable' : 'logging-not-lazy,logging-format-interpolation' (bad-configuration-section) diff --git a/tests/config/functional/toml/issue_4580/top_level_disable.toml b/tests/config/functional/toml/issue_4580/top_level_disable.toml new file mode 100644 index 000000000..b2f392b7a --- /dev/null +++ b/tests/config/functional/toml/issue_4580/top_level_disable.toml @@ -0,0 +1,3 @@ +[tool.pylint] +# disable does not belong in top level section +disable = "logging-not-lazy,logging-format-interpolation" |