Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use ==/!= to compare constant literals (str, bytes, int, float, tuple) #16

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Aug 3, 2021

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

./BBTz/whoxy.py:15:4: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
if API_KEY is "":
   ^
./BBTz/gctexposer.py:62:9: F821 undefined name 'sys'
        sys.exit(parser.print_help())
        ^
1     F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
1     F821 undefined name 'sys'
2

$ python3

>>> "" == ""
True
>>> "" is ""
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> API_KEY = "API_"
>>> API_KEY += "KEY"
>>> API_KEY == "API_KEY"
True
>>> API_KEY is "API_KEY"
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False

$ `flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics`
```
./BBTz/whoxy.py:15:4: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
if API_KEY is "":
   ^
./BBTz/gctexposer.py:62:9: F821 undefined name 'sys'
        sys.exit(parser.print_help())
        ^
1     F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
1     F821 undefined name 'sys'
2
```

$ `python3`
```
>>> "" == ""
True
>>> "" is ""
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> API_KEY = "API_"
>>> API_KEY += "KEY"
>>> API_KEY == "API_KEY"
True
>>> API_KEY is "API_KEY"
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False
```
@m4ll0k m4ll0k merged commit 502abcb into m4ll0k:master Jan 5, 2022
@cclauss cclauss deleted the patch-3 branch January 5, 2022 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants