---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
unspecified_encoding.py:8:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
 7 | # Errors.
 8 | open("test.txt")
   | ^^^^ PLW1514
 9 | io.TextIOWrapper(io.FileIO("test.txt"))
10 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8     |-open("test.txt")
   9  |+open("test.txt", encoding=locale.getpreferredencoding(False))
9  10 | io.TextIOWrapper(io.FileIO("test.txt"))
10 11 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 12 | tempfile.NamedTemporaryFile("w")

unspecified_encoding.py:9:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument
   |
 7 | # Errors.
 8 | open("test.txt")
 9 | io.TextIOWrapper(io.FileIO("test.txt"))
   | ^^^^^^^^^^^^^^^^ PLW1514
10 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 | tempfile.NamedTemporaryFile("w")
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
9     |-io.TextIOWrapper(io.FileIO("test.txt"))
   10 |+io.TextIOWrapper(io.FileIO("test.txt"), encoding=locale.getpreferredencoding(False))
10 11 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 12 | tempfile.NamedTemporaryFile("w")
12 13 | tempfile.TemporaryFile("w")

unspecified_encoding.py:10:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument
   |
 8 | open("test.txt")
 9 | io.TextIOWrapper(io.FileIO("test.txt"))
10 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
   | ^^^^^^^^^^^^^^^^^^ PLW1514
11 | tempfile.NamedTemporaryFile("w")
12 | tempfile.TemporaryFile("w")
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
9  10 | io.TextIOWrapper(io.FileIO("test.txt"))
10    |-hugo.TextIOWrapper(hugo.FileIO("test.txt"))
   11 |+hugo.TextIOWrapper(hugo.FileIO("test.txt"), encoding=locale.getpreferredencoding(False))
11 12 | tempfile.NamedTemporaryFile("w")
12 13 | tempfile.TemporaryFile("w")
13 14 | codecs.open("test.txt")

unspecified_encoding.py:11:1: PLW1514 [*] `tempfile.NamedTemporaryFile` in text mode without explicit `encoding` argument
   |
 9 | io.TextIOWrapper(io.FileIO("test.txt"))
10 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 | tempfile.NamedTemporaryFile("w")
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514
12 | tempfile.TemporaryFile("w")
13 | codecs.open("test.txt")
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
9  10 | io.TextIOWrapper(io.FileIO("test.txt"))
10 11 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11    |-tempfile.NamedTemporaryFile("w")
   12 |+tempfile.NamedTemporaryFile("w", encoding=locale.getpreferredencoding(False))
12 13 | tempfile.TemporaryFile("w")
13 14 | codecs.open("test.txt")
14 15 | tempfile.SpooledTemporaryFile(0, "w")

unspecified_encoding.py:12:1: PLW1514 [*] `tempfile.TemporaryFile` in text mode without explicit `encoding` argument
   |
10 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 | tempfile.NamedTemporaryFile("w")
12 | tempfile.TemporaryFile("w")
   | ^^^^^^^^^^^^^^^^^^^^^^ PLW1514
13 | codecs.open("test.txt")
14 | tempfile.SpooledTemporaryFile(0, "w")
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
9  10 | io.TextIOWrapper(io.FileIO("test.txt"))
10 11 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 12 | tempfile.NamedTemporaryFile("w")
12    |-tempfile.TemporaryFile("w")
   13 |+tempfile.TemporaryFile("w", encoding=locale.getpreferredencoding(False))
13 14 | codecs.open("test.txt")
14 15 | tempfile.SpooledTemporaryFile(0, "w")
15 16 | 

unspecified_encoding.py:13:1: PLW1514 [*] `codecs.open` in text mode without explicit `encoding` argument
   |
11 | tempfile.NamedTemporaryFile("w")
12 | tempfile.TemporaryFile("w")
13 | codecs.open("test.txt")
   | ^^^^^^^^^^^ PLW1514
14 | tempfile.SpooledTemporaryFile(0, "w")
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
10 11 | hugo.TextIOWrapper(hugo.FileIO("test.txt"))
11 12 | tempfile.NamedTemporaryFile("w")
12 13 | tempfile.TemporaryFile("w")
13    |-codecs.open("test.txt")
   14 |+codecs.open("test.txt", encoding=locale.getpreferredencoding(False))
14 15 | tempfile.SpooledTemporaryFile(0, "w")
15 16 | 
16 17 | # Non-errors.

unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in text mode without explicit `encoding` argument
   |
12 | tempfile.TemporaryFile("w")
13 | codecs.open("test.txt")
14 | tempfile.SpooledTemporaryFile(0, "w")
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514
15 | 
16 | # Non-errors.
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
11 12 | tempfile.NamedTemporaryFile("w")
12 13 | tempfile.TemporaryFile("w")
13 14 | codecs.open("test.txt")
14    |-tempfile.SpooledTemporaryFile(0, "w")
   15 |+tempfile.SpooledTemporaryFile(0, "w", encoding=locale.getpreferredencoding(False))
15 16 | 
16 17 | # Non-errors.
17 18 | open("test.txt", encoding="utf-8")

unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
44 | tempfile.SpooledTemporaryFile(0, )
45 | 
46 | open("test.txt",)
   | ^^^^ PLW1514
47 | open()
48 | open(
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
43 44 | tempfile.SpooledTemporaryFile(0, "wb")
44 45 | tempfile.SpooledTemporaryFile(0, )
45 46 | 
46    |-open("test.txt",)
   47 |+open("test.txt", encoding=locale.getpreferredencoding(False),)
47 48 | open()
48 49 | open(
49 50 |     "test.txt",  # comment

unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
46 | open("test.txt",)
47 | open()
   | ^^^^ PLW1514
48 | open(
49 |     "test.txt",  # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
44 45 | tempfile.SpooledTemporaryFile(0, )
45 46 | 
46 47 | open("test.txt",)
47    |-open()
   48 |+open(encoding=locale.getpreferredencoding(False))
48 49 | open(
49 50 |     "test.txt",  # comment
50 51 | )

unspecified_encoding.py:48:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
46 | open("test.txt",)
47 | open()
48 | open(
   | ^^^^ PLW1514
49 |     "test.txt",  # comment
50 | )
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
46 47 | open("test.txt",)
47 48 | open()
48 49 | open(
49    |-    "test.txt",  # comment
   50 |+    "test.txt", encoding=locale.getpreferredencoding(False),  # comment
50 51 | )
51 52 | open(
52 53 |     "test.txt",

unspecified_encoding.py:51:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
49 |     "test.txt",  # comment
50 | )
51 | open(
   | ^^^^ PLW1514
52 |     "test.txt",
53 |     # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
49 50 |     "test.txt",  # comment
50 51 | )
51 52 | open(
52    |-    "test.txt",
   53 |+    "test.txt", encoding=locale.getpreferredencoding(False),
53 54 |     # comment
54 55 | )
55 56 | open(("test.txt"),)

unspecified_encoding.py:55:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
53 |     # comment
54 | )
55 | open(("test.txt"),)
   | ^^^^ PLW1514
56 | open(
57 |     ("test.txt"),  # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
52 53 |     "test.txt",
53 54 |     # comment
54 55 | )
55    |-open(("test.txt"),)
   56 |+open(("test.txt"), encoding=locale.getpreferredencoding(False),)
56 57 | open(
57 58 |     ("test.txt"),  # comment
58 59 | )

unspecified_encoding.py:56:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
54 | )
55 | open(("test.txt"),)
56 | open(
   | ^^^^ PLW1514
57 |     ("test.txt"),  # comment
58 | )
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
54 55 | )
55 56 | open(("test.txt"),)
56 57 | open(
57    |-    ("test.txt"),  # comment
   58 |+    ("test.txt"), encoding=locale.getpreferredencoding(False),  # comment
58 59 | )
59 60 | open(
60 61 |     ("test.txt"),

unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
57 |     ("test.txt"),  # comment
58 | )
59 | open(
   | ^^^^ PLW1514
60 |     ("test.txt"),
61 |     # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
57 58 |     ("test.txt"),  # comment
58 59 | )
59 60 | open(
60    |-    ("test.txt"),
   61 |+    ("test.txt"), encoding=locale.getpreferredencoding(False),
61 62 |     # comment
62 63 | )
63 64 | 

unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
62 | )
63 | 
64 | open((("test.txt")),)
   | ^^^^ PLW1514
65 | open(
66 |     (("test.txt")),  # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
61 62 |     # comment
62 63 | )
63 64 | 
64    |-open((("test.txt")),)
   65 |+open((("test.txt")), encoding=locale.getpreferredencoding(False),)
65 66 | open(
66 67 |     (("test.txt")),  # comment
67 68 | )

unspecified_encoding.py:65:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
64 | open((("test.txt")),)
65 | open(
   | ^^^^ PLW1514
66 |     (("test.txt")),  # comment
67 | )
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
63 64 | 
64 65 | open((("test.txt")),)
65 66 | open(
66    |-    (("test.txt")),  # comment
   67 |+    (("test.txt")), encoding=locale.getpreferredencoding(False),  # comment
67 68 | )
68 69 | open(
69 70 |     (("test.txt")),

unspecified_encoding.py:68:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument
   |
66 |     (("test.txt")),  # comment
67 | )
68 | open(
   | ^^^^ PLW1514
69 |     (("test.txt")),
70 |     # comment
   |
   = help: Add explicit `encoding` argument

ℹ Unsafe fix
3  3  | import tempfile
4  4  | import io as hugo
5  5  | import codecs
   6  |+import locale
6  7  | 
7  8  | # Errors.
8  9  | open("test.txt")
--------------------------------------------------------------------------------
66 67 |     (("test.txt")),  # comment
67 68 | )
68 69 | open(
69    |-    (("test.txt")),
   70 |+    (("test.txt")), encoding=locale.getpreferredencoding(False),
70 71 |     # comment
71 72 | )


