-
Notifications
You must be signed in to change notification settings - Fork 305
Closed
Description
When the yamllint command is run using Python 3, the new-lines rule will always pass when set to 'unix' and always fail when set to 'dos'. This is because the builtin open() for Python 3 includes universal newline handling, so translates the line endings at file read time.
Steps to reproduce
$ echo ---^M > test.yaml
$ echo "---
rules:
new-lines:
type: dos
" > typedos.yaml
$ echo "---
rules:
new-lines:
type: unix
" > typeunix.yaml
$ python2 -m yamllint -c typeunix.yaml test.yaml
test.yaml
1:4 error wrong new line character: expected \n (new-lines)
$ python2 -m yamllint -c typedos.yaml test.yaml
$ python3 -m yamllint -c typeunix.yaml test.yaml
$ python3 -m yamllint -c typedos.yaml test.yaml
test.yaml
1:4 error wrong new line character: expected \r\n (new-lines)
Note behaviour is as expected on Python 2 but incorrect on Python 3.
Metadata
Metadata
Assignees
Labels
No labels