|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|