From afde7114186bd43aad28a83b5d65a973b0b5e374 Mon Sep 17 00:00:00 2001 From: qdegraaf Date: Fri, 1 Dec 2023 18:02:52 +0100 Subject: [PATCH] Add no arg fixture --- .../fixtures/pylint/unspecified_encoding.py | 1 + ...ests__PLW1514_unspecified_encoding.py.snap | 17 ++++++++++++++ ...nspecified_encoding_python39_or_lower.snap | 22 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/crates/ruff_linter/resources/test/fixtures/pylint/unspecified_encoding.py b/crates/ruff_linter/resources/test/fixtures/pylint/unspecified_encoding.py index c3a35921c024b..e6a9a65269d94 100644 --- a/crates/ruff_linter/resources/test/fixtures/pylint/unspecified_encoding.py +++ b/crates/ruff_linter/resources/test/fixtures/pylint/unspecified_encoding.py @@ -44,3 +44,4 @@ def func(*args, **kwargs): tempfile.SpooledTemporaryFile(0, ) open("test.txt",) +open() diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap index c687d72efada3..20399c78210bd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap @@ -152,6 +152,7 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` 45 | 46 | open("test.txt",) | ^^^^ PLW1514 +47 | open() | = help: Add explicit `encoding` argument @@ -161,5 +162,21 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` 45 45 | 46 |-open("test.txt",) 46 |+open("test.txt",encoding="locale") +47 47 | open() + +unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument + | +46 | open("test.txt",) +47 | open() + | ^^^^ PLW1514 + | + = help: Add explicit `encoding` argument + +ℹ Unsafe fix +44 44 | tempfile.SpooledTemporaryFile(0, ) +45 45 | +46 46 | open("test.txt",) +47 |-open() + 47 |+open(encoding="locale") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__unspecified_encoding_python39_or_lower.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__unspecified_encoding_python39_or_lower.snap index 75df31df15ea4..ec231166bfde0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__unspecified_encoding_python39_or_lower.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__unspecified_encoding_python39_or_lower.snap @@ -187,6 +187,7 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` 45 | 46 | open("test.txt",) | ^^^^ PLW1514 +47 | open() | = help: Add explicit `encoding` argument @@ -201,5 +202,26 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` 45 46 | 46 |-open("test.txt",) 47 |+open("test.txt",encoding=locale.getpreferredencoding(False)) +47 48 | open() + +unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument + | +46 | open("test.txt",) +47 | open() + | ^^^^ PLW1514 + | + = help: Add explicit `encoding` argument + +ℹ Unsafe fix + 1 |+import locale +1 2 | import io +2 3 | import sys +3 4 | import tempfile +-------------------------------------------------------------------------------- +44 45 | tempfile.SpooledTemporaryFile(0, ) +45 46 | +46 47 | open("test.txt",) +47 |-open() + 48 |+open(encoding=locale.getpreferredencoding(False))