lux icon indicating copy to clipboard operation
lux copied to clipboard

SyntaxWarning: assertion is always true, perhaps remove parentheses?

Open cclauss opened this issue 2 years ago • 1 comments

Overview

assert is not a function in Python and parentheses can create assert statements that are always True.

% python3.10

>>> assert True is False, "Did you know that True is False?"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError: Did you know that True is False?
>>> assert (True is False, "Did you know that True is False?")
<stdin>:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?

% flake8 . --count --select=E9,F63,F7,F82,Y --show-source --statistics

./lux/tests/test_action.py:60:9: F631 assertion is always true, perhaps remove parentheses?
        assert ("Temporal" in df.recommendation, "Temporal visualizations should be generated.")
        ^
./lux/tests/test_action.py:62:9: F631 assertion is always true, perhaps remove parentheses?
        assert (len(recommended) == num_vis, "Incorrect number of temporal visualizations generated.")
        ^
./lux/tests/test_config.py:72:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:83:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:126:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:130:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:136:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:170:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
./lux/tests/test_config.py:178:5: F631 assertion is always true, perhaps remove parentheses?
    assert (
    ^
9     F631 assertion is always true, perhaps remove parentheses?
9

Changes

Describe the changes that your code introduces to Lux. Have you made corresponding tests and added the appropriate documentation for your changes? Do the commits pass the tests and follow the guidelines described here?

Example Output

Describe the expected behavior of your changes. If applicable, please include a screenshot.

cclauss avatar Nov 07 '21 10:11 cclauss

@cclauss thanks for looking in to this! Indeed, current assertions are wrong.

To fix the lint error take a look at my comment in #429.

cgarciae avatar Nov 09 '21 20:11 cgarciae