diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-07-28 20:18:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 20:18:44 +0200 |
commit | a8b7dd7bffe343f00bcd6409534edcab530a4fc4 (patch) | |
tree | 5f1d6b315ca95634a9328eed70603cfcfbac4e1c /tests/functional/r | |
parent | c04f92ef68e5ea779a60bfddb91dc677c5470fd0 (diff) | |
download | pylint-git-a8b7dd7bffe343f00bcd6409534edcab530a4fc4.tar.gz |
Add unspecified-encoding checker #3826 (#4753)
* Add unspecified-encoding checker #3826
This adds an unspecified-encoding checker that adds a warning
whenever open() is called without an explicit encoding argument.
This closes #3826
* Update tests to conform to unspecified-encoding
With addition of the unspecified-encoding checker calls of open()
need an encoding argument.
Where necessary this argument has been added, or the message has been
disabled.
This also includes small linting changes to a small number
of tests. Their test-data has been updated to reflect new line numbers.
* Update scripts to conform to unspecified-encoding
With addition of the unspecified-encoding checker calls of open()
need an encoding argument.
Where necessary this argument has been added.
* Update pylint to conform to unspecified-encoding
With addition of the unspecified-encoding checker calls of open()
need an encoding argument.
Where necessary this argument has been added.
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'tests/functional/r')
3 files changed, 22 insertions, 20 deletions
diff --git a/tests/functional/r/redefined_argument_from_local.py b/tests/functional/r/redefined_argument_from_local.py index 820252781..7ccff1d18 100644 --- a/tests/functional/r/redefined_argument_from_local.py +++ b/tests/functional/r/redefined_argument_from_local.py @@ -1,31 +1,33 @@ # pylint: disable=missing-docstring, unused-variable, unused-argument # pylint: disable=redefined-outer-name, invalid-name + def test_redefined_in_with(name): - with open('something') as name: # [redefined-argument-from-local] + with open("something", encoding="utf-8") as name: # [redefined-argument-from-local] pass - with open('something') as (second, name): # [redefined-argument-from-local] + with open("something", encoding="utf-8") as (second, name): # [redefined-argument-from-local] pass - with open('something') as (second, (name, third)): # [redefined-argument-from-local] + with open("something", encoding="utf-8") as ( + second, + (name, third), # [redefined-argument-from-local] + ): pass other = None - with open('something') as other: + with open("something", encoding="utf-8") as other: pass - def test_not_redefined_in_with(name): - with open('something') as test_redefined_in_with: + with open("something", encoding="utf-8") as test_redefined_in_with: pass - def test_redefined_in_for(name): - for name in []: # [redefined-argument-from-local] + for name in []: # [redefined-argument-from-local] pass - for (name, is_) in []: # [redefined-argument-from-local] + for (name, is_) in []: # [redefined-argument-from-local] pass - for (is_, (name, _)) in []: # [redefined-argument-from-local] + for (is_, (name, _)) in []: # [redefined-argument-from-local] pass for _ in []: pass @@ -45,7 +47,7 @@ def test_not_redefined_in_for(name): def test_redefined_in_except_handler(name): try: 1 / 0 - except ZeroDivisionError as name: # [redefined-argument-from-local] + except ZeroDivisionError as name: # [redefined-argument-from-local] pass @@ -58,7 +60,7 @@ def test_not_redefined_in_except_handler(name): def test_not_redefined(name): if not name: - name = '' + name = "" def apply_filter(objects, filt=lambda obj: True): diff --git a/tests/functional/r/redefined_argument_from_local.txt b/tests/functional/r/redefined_argument_from_local.txt index 28ec50da1..b811971c6 100644 --- a/tests/functional/r/redefined_argument_from_local.txt +++ b/tests/functional/r/redefined_argument_from_local.txt @@ -1,7 +1,7 @@ -redefined-argument-from-local:5:30:test_redefined_in_with:Redefining argument with the local name 'name' -redefined-argument-from-local:7:39:test_redefined_in_with:Redefining argument with the local name 'name' -redefined-argument-from-local:9:40:test_redefined_in_with:Redefining argument with the local name 'name' -redefined-argument-from-local:24:8:test_redefined_in_for:Redefining argument with the local name 'name' -redefined-argument-from-local:26:9:test_redefined_in_for:Redefining argument with the local name 'name' -redefined-argument-from-local:28:15:test_redefined_in_for:Redefining argument with the local name 'name' -redefined-argument-from-local:48:4:test_redefined_in_except_handler:Redefining argument with the local name 'name' +redefined-argument-from-local:6:48:test_redefined_in_with:Redefining argument with the local name 'name' +redefined-argument-from-local:8:57:test_redefined_in_with:Redefining argument with the local name 'name' +redefined-argument-from-local:12:9:test_redefined_in_with:Redefining argument with the local name 'name' +redefined-argument-from-local:26:8:test_redefined_in_for:Redefining argument with the local name 'name' +redefined-argument-from-local:28:9:test_redefined_in_for:Redefining argument with the local name 'name' +redefined-argument-from-local:30:15:test_redefined_in_for:Redefining argument with the local name 'name' +redefined-argument-from-local:50:4:test_redefined_in_except_handler:Redefining argument with the local name 'name' diff --git a/tests/functional/r/regression/regression_4612_crash_pytest_fixture.py b/tests/functional/r/regression/regression_4612_crash_pytest_fixture.py index f0aa0f5d1..f7680f1fb 100644 --- a/tests/functional/r/regression/regression_4612_crash_pytest_fixture.py +++ b/tests/functional/r/regression/regression_4612_crash_pytest_fixture.py @@ -5,5 +5,5 @@ import pytest @pytest.fixture def qm_file(): - qm_file = open("src/test/resources/example_qm_file.csv").read() + qm_file = open("src/test/resources/example_qm_file.csv", encoding="utf-8").read() return qm_file |