diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2023-02-05 22:27:57 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2023-02-05 23:16:59 +0100 |
commit | cc76aa52d17a1675d48c31de1cab8903e8c698af (patch) | |
tree | 08f85a980aa494e197cd4315bad21593f94ce7f1 /doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py | |
parent | 3f51941560b0d45f40757af116c9044cf1fe3eae (diff) | |
download | pylint-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.
Diffstat (limited to 'doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py')
-rw-r--r-- | doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py | 8 |
1 files changed, 8 insertions, 0 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!") |