Skip to content

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 20, 2019

if data['state'] is not 'draft' or not 'pending':

The second half of this if statement is always False because:
python -c "print(not 'pending')" # --> False

The correct ways to write this line are:

if data['state'] != 'draft' or data['state'] != 'pending':
# or better yet...
if data['state'] not in ('draft', 'pending'):  # LOL, codacy-bot seems to like this one.

Fixes #

Short description of what this resolves:

Changes proposed in this pull request:

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

> if data['state'] is not 'draft' or not 'pending':
The second half of this if statement is __always__ False because __python -c "print(not 'pending')"__  # --> False

The correct ways to write this line are:
```python
if data['state'] != 'draft' or data['state'] != 'pending':
# or better yet...
if data['state'] not in ('draft', 'pending'):
```
@codecov
Copy link

codecov bot commented Jul 20, 2019

Codecov Report

Merging #6220 into development will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #6220   +/-   ##
============================================
  Coverage        65.93%   65.93%           
============================================
  Files              288      288           
  Lines            14552    14552           
============================================
  Hits              9595     9595           
  Misses            4957     4957
Impacted Files Coverage Δ
app/api/schema/sessions.py 86.84% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff408e5...2f49dc8. Read the comment docs.

@iamareebjamal iamareebjamal changed the title Fix logic error in sessions.py fix: state logic error in sessions.py Jul 20, 2019
@auto-label auto-label bot added the fix label Jul 20, 2019
@iamareebjamal iamareebjamal merged commit 027a2c9 into fossasia:development Jul 20, 2019
@cclauss cclauss deleted the patch-2 branch July 20, 2019 19:12
iamareebjamal pushed a commit to iamareebjamal/open-event-server that referenced this pull request Aug 2, 2019
> if data['state'] is not 'draft' or not 'pending':
The second half of this if statement is __always__ False because __python -c "print(not 'pending')"__  # --> False

The correct ways to write this line are:
```python
if data['state'] != 'draft' or data['state'] != 'pending':
# or better yet...
if data['state'] not in ('draft', 'pending'):
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants