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

Added while-used message example #6562

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/data/messages/w/while-used/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import requests


def fetch_data():
i = 1
while i < 6: # [while-used]
print(f'Attempt {i}...')
try:
return requests.get('https://example.com/data')
except requests.exceptions.RequestException:
pass
i += 1
10 changes: 10 additions & 0 deletions doc/data/messages/w/while-used/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import requests


def fetch_data():
for i in range(1, 6):
print(f'Attempt {i}...')
try:
return requests.get('https://example.com/data')
except requests.exceptions.RequestException:
pass
2 changes: 2 additions & 0 deletions doc/data/messages/w/while-used/pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[master]
load-plugins=pylint.extensions.while_used
1 change: 1 addition & 0 deletions doc/data/messages/w/while-used/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `Stackoverflow discussion <https://stackoverflow.com/questions/920645/when-to-use-while-or-for-in-python>`_