Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[New Rule] Use comparision directly instead of bool(comparison) #88

Closed
martin-thoma opened this issue Jan 18, 2022 · 2 comments · Fixed by #90
Closed

[New Rule] Use comparision directly instead of bool(comparison) #88

martin-thoma opened this issue Jan 18, 2022 · 2 comments · Fixed by #90
Assignees
Labels
enhancement New feature or request

Comments

@martin-thoma
Copy link

Explanation

Comparisons return boolean values. No need to wrap it in a bool-call

Example

# Bad
bool(a == b)

# Good
a == b
@martin-thoma martin-thoma added the enhancement New feature or request label Jan 18, 2022
@MartinThoma
Copy link
Owner

  • Experimental number: SIM901
  • Permanent number: SIM224
  • Release: not released so far
  • End of trial period: 6 months after the release

@MartinThoma
Copy link
Owner

$ astpretty --no-show-offsets /dev/stdin <<< `cat /home/moose/example.py`

astpretty --no-show-offsets /dev/stdin <<< `cat /home/moose/example.py`
Module(
    body=[
        Expr(
            value=Call(
                func=Name(id='bool', ctx=Load()),
                args=[
                    Compare(
                        left=Name(id='a', ctx=Load()),
                        ops=[Eq()],
                        comparators=[Name(id='b', ctx=Load())],
                    ),
                ],
                keywords=[],
            ),
        ),
    ],
    type_ignores=[],
)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants