summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-02-05 22:27:57 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2023-02-05 23:16:59 +0100
commitcc76aa52d17a1675d48c31de1cab8903e8c698af (patch)
tree08f85a980aa494e197cd4315bad21593f94ce7f1
parent3f51941560b0d45f40757af116c9044cf1fe3eae (diff)
downloadpylint-git-cc76aa52d17a1675d48c31de1cab8903e8c698af.tar.gz
missing-parentheses-for-call-in-test] Generate imaginative example with GhatGPT
Prompt: Could you give me an example of bad code raising a 'missing-parentheses-for-call-in-test' message in pylint Could you make it more lively, the name is very generic ? That's kinda expected and boring, could you be more imaginative ? Also I don't think it should return a string, it's supposed to return a boolean. You need to add a ``# [missing-parentheses-for-call-in-test]`` on the line the actual message would be raised, could you update the bad example, please ? Final result: def is_it_a_good_day(): import random return random.choice([True, False]) if is_it_a_good_day: # [missing-parentheses-for-call-in-test] print("Today is a good day!") In this code, the line if is_it_a_good_day: would raise the "missing-parentheses-for-call-in-test" message, because Pylint is expecting to see a function call in the test expression of an if statement, but there are no parentheses after is_it_a_good_day. To correct this, you can add parentheses to make it a function call, as shown in the corrected code in my previous answer.
-rw-r--r--doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py8
-rw-r--r--doc/data/messages/m/missing-parentheses-for-call-in-test/details.rst1
-rw-r--r--doc/data/messages/m/missing-parentheses-for-call-in-test/good.py9
3 files changed, 16 insertions, 2 deletions
diff --git a/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py b/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py
new file mode 100644
index 000000000..3f67322dc
--- /dev/null
+++ b/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py
@@ -0,0 +1,8 @@
+import random
+
+
+def is_it_a_good_day():
+ return random.choice([True, False])
+
+if is_it_a_good_day: # [missing-parentheses-for-call-in-test]
+ print("Today is a good day!")
diff --git a/doc/data/messages/m/missing-parentheses-for-call-in-test/details.rst b/doc/data/messages/m/missing-parentheses-for-call-in-test/details.rst
deleted file mode 100644
index ab8204529..000000000
--- a/doc/data/messages/m/missing-parentheses-for-call-in-test/details.rst
+++ /dev/null
@@ -1 +0,0 @@
-You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !
diff --git a/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py b/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py
index c40beb573..63c8ccc89 100644
--- a/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py
+++ b/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py
@@ -1 +1,8 @@
-# This is a placeholder for correct code for this message.
+import random
+
+
+def is_it_a_good_day():
+ return random.choice([True, False])
+
+if is_it_a_good_day():
+ print("Today is a good day!")