From a9eee574c83811e67e11f0c1fd1986b90f6c69b1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 26 Apr 2024 21:08:49 -0700 Subject: [PATCH] [pyflakes] Improve invalid-print-syntax documentation This syntax wasn't "deprecated" in Python 3; it was removed. I started looking at this rule because I was curious how Ruff could even detect this without a Python 2 parser. Then I realized that "print >> f, x" is actually valid Python 3 syntax: it creates a tuple containing a right-shifted version of the print function. --- .../src/rules/pyflakes/rules/invalid_print_syntax.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs index 74acdca403167..b9cbe8cc26a8c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs @@ -11,8 +11,9 @@ use crate::checkers::ast::Checker; /// /// ## Why is this bad? /// In Python 2, the `print` statement can be used with the `>>` syntax to -/// print to a file-like object. This `print >> sys.stderr` syntax is -/// deprecated in Python 3. +/// print to a file-like object. This `print >> sys.stderr` syntax no +/// longer exists in Python 3, where `print` is only a function, not a +/// statement. /// /// Instead, use the `file` keyword argument to the `print` function, the /// `sys.stderr.write` function, or the `logging` module.