diff --git a/doc/data/messages/b/bad-format-string/bad.py b/doc/data/messages/b/bad-format-string/bad.py new file mode 100644 index 0000000000..523b8fba8e --- /dev/null +++ b/doc/data/messages/b/bad-format-string/bad.py @@ -0,0 +1 @@ +print('{a[0] + a[1]}'.format(a=[0, 1])) # [bad-format-string] diff --git a/doc/data/messages/b/bad-format-string/good.py b/doc/data/messages/b/bad-format-string/good.py new file mode 100644 index 0000000000..f2d8919b09 --- /dev/null +++ b/doc/data/messages/b/bad-format-string/good.py @@ -0,0 +1 @@ +print('{a[0]} + {a[1]}'.format(a=[0, 1])) diff --git a/doc/data/messages/b/bad-format-string/related.rst b/doc/data/messages/b/bad-format-string/related.rst new file mode 100644 index 0000000000..b6aadf541e --- /dev/null +++ b/doc/data/messages/b/bad-format-string/related.rst @@ -0,0 +1,2 @@ +- `Format String Syntax `_ +- `PyFormat `_ diff --git a/doc/data/messages/c/consider-using-sys-exit/bad.py b/doc/data/messages/c/consider-using-sys-exit/bad.py new file mode 100644 index 0000000000..1acc22a158 --- /dev/null +++ b/doc/data/messages/c/consider-using-sys-exit/bad.py @@ -0,0 +1,4 @@ +if __name__ == "__main__": + user = input("Enter user name: ") + print(f"Hello, {user}") + exit(0) # [consider-using-sys-exit] diff --git a/doc/data/messages/c/consider-using-sys-exit/good.py b/doc/data/messages/c/consider-using-sys-exit/good.py new file mode 100644 index 0000000000..acacd343a6 --- /dev/null +++ b/doc/data/messages/c/consider-using-sys-exit/good.py @@ -0,0 +1,6 @@ +import sys + +if __name__ == "__main__": + user = input("Enter user name: ") + print(f"Hello, {user}") + sys.exit(0) diff --git a/doc/data/messages/g/global-statement/bad.py b/doc/data/messages/g/global-statement/bad.py new file mode 100644 index 0000000000..aca1dabd24 --- /dev/null +++ b/doc/data/messages/g/global-statement/bad.py @@ -0,0 +1,11 @@ +var = 1 + + +def foo(): + global var # [global-statement] + var = 10 + print(var) + + +foo() +print(var) diff --git a/doc/data/messages/g/global-statement/good.py b/doc/data/messages/g/global-statement/good.py new file mode 100644 index 0000000000..34958b5fe1 --- /dev/null +++ b/doc/data/messages/g/global-statement/good.py @@ -0,0 +1,10 @@ +var = 1 + + +def foo(): + print(var) + return 10 + + +var = foo() +print(var)