diff --git a/doc/data/messages/b/bad-open-mode/bad.py b/doc/data/messages/b/bad-open-mode/bad.py new file mode 100644 index 0000000000..28cfb62283 --- /dev/null +++ b/doc/data/messages/b/bad-open-mode/bad.py @@ -0,0 +1,3 @@ +def foo(file_path): + with open(file_path, "rwx") as file: # [bad-open-mode] + contents = file.read() diff --git a/doc/data/messages/b/bad-open-mode/good.py b/doc/data/messages/b/bad-open-mode/good.py new file mode 100644 index 0000000000..64a853b38c --- /dev/null +++ b/doc/data/messages/b/bad-open-mode/good.py @@ -0,0 +1,3 @@ +def foo(file_path): + with open(file_path, "r") as file: + contents = file.read() diff --git a/doc/data/messages/u/unspecified-encoding/bad.py b/doc/data/messages/u/unspecified-encoding/bad.py new file mode 100644 index 0000000000..4645923c58 --- /dev/null +++ b/doc/data/messages/u/unspecified-encoding/bad.py @@ -0,0 +1,3 @@ +def foo(file_path): + with open(file_path) as file: # [unspecified-encoding] + contents = file.read() diff --git a/doc/data/messages/u/unspecified-encoding/good.py b/doc/data/messages/u/unspecified-encoding/good.py new file mode 100644 index 0000000000..a267a36070 --- /dev/null +++ b/doc/data/messages/u/unspecified-encoding/good.py @@ -0,0 +1,3 @@ +def foo(file_path): + with open(file_path, encoding="utf-8") as file: + contents = file.read() diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index 5b4670803e..5d3ef41b5b 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -363,7 +363,7 @@ class StdlibChecker(DeprecatedMixin, BaseChecker): "bad-open-mode", "Python supports: r, w, a[, x] modes with b, +, " "and U (only with r) options. " - "See https://docs.python.org/2/library/functions.html#open", + "See https://docs.python.org/3/library/functions.html#open", ), "W1502": ( "Using datetime.time in a boolean context.",