lux-org / lux

Automatically visualize your pandas dataframe via a single print! 📊 💡
Apache License 2.0
5.15k stars 365 forks source link

SyntaxWarning: assertion is always true, perhaps remove parentheses? #430

Closed cclauss closed 9 months ago

cclauss commented 2 years ago

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.

cgarciae commented 2 years ago

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