mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
Clarify documentation on the 'truthy' rule
I like the 'truthy' rule but its documentation and message have confused several of my colleagues. I've tried rewriting it to be clearer.
This commit is contained in:
parent
3bdc1b6e1b
commit
36b4776778
@ -15,11 +15,12 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
Use this rule to forbid truthy values that are not quoted nor explicitly typed.
|
||||
Use this rule to forbid non-explictly typed truthy values other than ``true``
|
||||
and ``false``, for example ``YES``, ``False`` and ``off``.
|
||||
|
||||
This would prevent YAML parsers from transforming ``[yes, FALSE, Off]`` into
|
||||
``[true, false, false]`` or ``{y: 1, yes: 2, on: 3, true: 4, True: 5}`` into
|
||||
``{y: 1, true: 5}``.
|
||||
This can be useful to prevent surprises from YAML parsers transforming
|
||||
``[yes, FALSE, Off]`` into ``[true, false, false]`` or
|
||||
``{y: 1, yes: 2, on: 3, true: 4, True: 5}`` into ``{y: 1, true: 5}``.
|
||||
|
||||
.. rubric:: Examples
|
||||
|
||||
@ -34,8 +35,7 @@ This would prevent YAML parsers from transforming ``[yes, FALSE, Off]`` into
|
||||
|
||||
"yes": 1
|
||||
"on": 2
|
||||
"true": 3
|
||||
"True": 4
|
||||
"True": 3
|
||||
|
||||
explicit:
|
||||
string1: !!str True
|
||||
@ -62,8 +62,7 @@ This would prevent YAML parsers from transforming ``[yes, FALSE, Off]`` into
|
||||
|
||||
yes: 1
|
||||
on: 2
|
||||
true: 3
|
||||
True: 4
|
||||
True: 3
|
||||
"""
|
||||
|
||||
import yaml
|
||||
@ -90,4 +89,4 @@ def check(conf, token, prev, next, nextnext, context):
|
||||
if token.value in TRUTHY and token.style is None:
|
||||
yield LintProblem(token.start_mark.line + 1,
|
||||
token.start_mark.column + 1,
|
||||
"truthy value is not quoted")
|
||||
"truthy value should be true or false")
|
||||
|
Loading…
Reference in New Issue
Block a user