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 bad-format-string, consider-using-sys-exit, global-statement examples #6472

Merged
merged 3 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions doc/data/messages/b/bad-format-string/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('{a[0] + a[1]}'.format(a=[0, 1])) # [bad-format-string]
1 change: 1 addition & 0 deletions doc/data/messages/b/bad-format-string/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('{a[0]} + {a[1]}'.format(a=[0, 1]))
2 changes: 2 additions & 0 deletions doc/data/messages/b/bad-format-string/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `Format String Syntax <https://docs.python.org/3/library/string.html#formatstrings>`_
- `PyFormat <https://pyformat.info/>`_
4 changes: 4 additions & 0 deletions doc/data/messages/c/consider-using-sys-exit/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if __name__ == '__main__':
user = input('Enter user name: ')
print(f'Hello, {user}')
exit(0) # [consider-using-sys-exit]
MalanB marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions doc/data/messages/c/consider-using-sys-exit/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

if __name__ == '__main__':
user = input('Enter user name: ')
print(f'Hello, {user}')
sys.exit(0)
MalanB marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions doc/data/messages/g/global-statement/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var = 1

def foo():
global var # [global-statement]
var = 10
print(var)

foo()
print(var)
8 changes: 8 additions & 0 deletions doc/data/messages/g/global-statement/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var = 1

def foo(x):
print(var)
return 10

var = foo()
print(var)
MalanB marked this conversation as resolved.
Show resolved Hide resolved