summaryrefslogtreecommitdiff
path: root/tests/functional/a/assignment_expression.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/a/assignment_expression.py')
-rw-r--r--tests/functional/a/assignment_expression.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/functional/a/assignment_expression.py b/tests/functional/a/assignment_expression.py
index aa6a27874..a2a586e53 100644
--- a/tests/functional/a/assignment_expression.py
+++ b/tests/functional/a/assignment_expression.py
@@ -1,5 +1,6 @@
"""Test assignment expressions"""
-# pylint: disable=missing-docstring,unused-argument,unused-import,invalid-name,blacklisted-name,unused-variable
+# pylint: disable=missing-docstring,unused-argument,unused-import,invalid-name
+# pylint: disable=blacklisted-name,unused-variable,pointless-statement
import re
if (a := True):
@@ -16,6 +17,15 @@ a = ["a ", "b ", "c "]
c = [text for el in a if (text := el.strip()) == "b"]
+# check wrong usage
+assert err_a, (err_a := 2) # [used-before-assignment]
+print(err_b and (err_b := 2)) # [used-before-assignment]
+values = (
+ err_c := err_d, # [used-before-assignment]
+ err_d := 2,
+)
+
+
# https://github.com/PyCQA/pylint/issues/3347
s = 'foo' if (fval := lambda: 1) is None else fval
@@ -53,7 +63,7 @@ print(function())
# https://github.com/PyCQA/pylint/issues/3763
-foo if (foo := 3 - 2) > 0 else 0 # [pointless-statement]
+foo if (foo := 3 - 2) > 0 else 0
# https://github.com/PyCQA/pylint/issues/4238
@@ -70,10 +80,7 @@ l3 += (
)
-# check wrong usage
-assert err_a, (err_a := 2) # [used-before-assignment]
-print(err_b and (err_b := 2)) # [used-before-assignment]
-values = (
- err_c := err_d, # [used-before-assignment]
- err_d := 2,
-)
+# https://github.com/PyCQA/pylint/issues/4301
+def func2():
+ return f'The number {(count := 4)} ' \
+ f'is equal to {count}'