diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 48819fe3bf..6b20db830e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,6 +52,27 @@ repos: - id: black args: [--safe, --quiet] exclude: *fixtures + - id: black + name: black-doc + args: [--safe, --quiet] + files: doc/data/messages/ + exclude: | + (?x)^( + doc/data/messages/b/bad-indentation/bad.py| + doc/data/messages/i/inconsistent-quotes/bad.py| + doc/data/messages/i/invalid-format-index/bad.py| + doc/data/messages/l/line-too-long/bad.py| + doc/data/messages/m/missing-final-newline/bad.py| + doc/data/messages/m/multiple-statements/bad.py| + doc/data/messages/r/redundant-u-string-prefix/bad.py| + doc/data/messages/s/superfluous-parens/bad.py| + doc/data/messages/s/syntax-error/bad.py| + doc/data/messages/t/too-many-ancestors/bad.py| + doc/data/messages/t/trailing-comma-tuple/bad.py| + doc/data/messages/t/trailing-newlines/bad.py| + doc/data/messages/t/trailing-whitespace/bad.py| + doc/data/messages/u/unnecessary-semicolon/bad.py + )$ - repo: https://github.com/Pierre-Sassoulas/black-disable-checker rev: v1.1.3 hooks: diff --git a/doc/data/messages/a/arguments-renamed/bad.py b/doc/data/messages/a/arguments-renamed/bad.py index 87b45a0d5b..c9d7853209 100644 --- a/doc/data/messages/a/arguments-renamed/bad.py +++ b/doc/data/messages/a/arguments-renamed/bad.py @@ -2,12 +2,15 @@ class Fruit: def brew(self, ingredient_name: str): print(f"Brewing a {type(self)} with {ingredient_name}") + class Apple(Fruit): ... + class Orange(Fruit): def brew(self, flavor: str): # [arguments-renamed] print(f"Brewing an orange with {flavor}") + for fruit, ingredient_name in [[Orange(), "thyme"], [Apple(), "cinnamon"]]: fruit.brew(ingredient_name=ingredient_name) diff --git a/doc/data/messages/a/arguments-renamed/good.py b/doc/data/messages/a/arguments-renamed/good.py index 0cd1db7560..de6583806b 100644 --- a/doc/data/messages/a/arguments-renamed/good.py +++ b/doc/data/messages/a/arguments-renamed/good.py @@ -2,12 +2,15 @@ class Fruit: def brew(self, ingredient_name: str): print(f"Brewing a {type(self)} with {ingredient_name}") + class Apple(Fruit): ... + class Orange(Fruit): def brew(self, ingredient_name: str): print(f"Brewing an orange with {ingredient_name}") + for fruit, ingredient_name in [[Orange(), "thyme"], [Apple(), "cinnamon"]]: fruit.brew(ingredient_name=ingredient_name) diff --git a/doc/data/messages/a/assigning-non-slot/bad.py b/doc/data/messages/a/assigning-non-slot/bad.py index a1a658ba29..506ad42cd0 100644 --- a/doc/data/messages/a/assigning-non-slot/bad.py +++ b/doc/data/messages/a/assigning-non-slot/bad.py @@ -1,5 +1,5 @@ class Student: - __slots__ = ('name',) + __slots__ = ("name",) def __init__(self, name, surname): self.name = name diff --git a/doc/data/messages/a/assigning-non-slot/good.py b/doc/data/messages/a/assigning-non-slot/good.py index feb5a10fa1..733728618c 100644 --- a/doc/data/messages/a/assigning-non-slot/good.py +++ b/doc/data/messages/a/assigning-non-slot/good.py @@ -1,5 +1,5 @@ class Student: - __slots__ = ('name', 'surname') + __slots__ = ("name", "surname") def __init__(self, name, surname): self.name = name diff --git a/doc/data/messages/b/bad-chained-comparison/bad.py b/doc/data/messages/b/bad-chained-comparison/bad.py index eeca75f13e..09e3ab627c 100644 --- a/doc/data/messages/b/bad-chained-comparison/bad.py +++ b/doc/data/messages/b/bad-chained-comparison/bad.py @@ -1,3 +1,5 @@ def xor_check(*, left=None, right=None): if left is None != right is None: # [bad-chained-comparison] - raise ValueError('Either both left= and right= need to be provided or none should.') + raise ValueError( + "Either both left= and right= need to be provided or none should." + ) diff --git a/doc/data/messages/b/bad-chained-comparison/good.py b/doc/data/messages/b/bad-chained-comparison/good.py index 115f4a9db0..79bb641513 100644 --- a/doc/data/messages/b/bad-chained-comparison/good.py +++ b/doc/data/messages/b/bad-chained-comparison/good.py @@ -1,3 +1,5 @@ def xor_check(*, left=None, right=None): if (left is None) != (right is None): - raise ValueError('Either both left= and right= need to be provided or none should.') + raise ValueError( + "Either both left= and right= need to be provided or none should." + ) diff --git a/doc/data/messages/b/bad-classmethod-argument/bad.py b/doc/data/messages/b/bad-classmethod-argument/bad.py index 7e43001b59..b8c6d02a0d 100644 --- a/doc/data/messages/b/bad-classmethod-argument/bad.py +++ b/doc/data/messages/b/bad-classmethod-argument/bad.py @@ -1,5 +1,4 @@ class Klass: - @classmethod def get_instance(self): # [bad-classmethod-argument] return self() diff --git a/doc/data/messages/b/bad-classmethod-argument/good.py b/doc/data/messages/b/bad-classmethod-argument/good.py index 3d4decea36..6097f1e362 100644 --- a/doc/data/messages/b/bad-classmethod-argument/good.py +++ b/doc/data/messages/b/bad-classmethod-argument/good.py @@ -1,5 +1,4 @@ class Klass: - @classmethod def get_instance(cls): return cls() diff --git a/doc/data/messages/b/bad-docstring-quotes/bad.py b/doc/data/messages/b/bad-docstring-quotes/bad.py index 561921db00..bd800a40cc 100644 --- a/doc/data/messages/b/bad-docstring-quotes/bad.py +++ b/doc/data/messages/b/bad-docstring-quotes/bad.py @@ -1,3 +1,3 @@ def foo(): # [bad-docstring-quotes] - 'Docstring.' + "Docstring." return diff --git a/doc/data/messages/b/bad-format-string/bad.py b/doc/data/messages/b/bad-format-string/bad.py index 523b8fba8e..4cb811261d 100644 --- a/doc/data/messages/b/bad-format-string/bad.py +++ b/doc/data/messages/b/bad-format-string/bad.py @@ -1 +1 @@ -print('{a[0] + a[1]}'.format(a=[0, 1])) # [bad-format-string] +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 index f2d8919b09..10475fd67f 100644 --- a/doc/data/messages/b/bad-format-string/good.py +++ b/doc/data/messages/b/bad-format-string/good.py @@ -1 +1 @@ -print('{a[0]} + {a[1]}'.format(a=[0, 1])) +print("{a[0]} + {a[1]}".format(a=[0, 1])) diff --git a/doc/data/messages/b/bad-indentation/good.py b/doc/data/messages/b/bad-indentation/good.py index 1a1f33c117..e7ba80a569 100644 --- a/doc/data/messages/b/bad-indentation/good.py +++ b/doc/data/messages/b/bad-indentation/good.py @@ -1,2 +1,2 @@ if input(): - print('yes') + print("yes") diff --git a/doc/data/messages/b/bad-thread-instantiation/bad.py b/doc/data/messages/b/bad-thread-instantiation/bad.py index 580786d853..20fa72f5a7 100644 --- a/doc/data/messages/b/bad-thread-instantiation/bad.py +++ b/doc/data/messages/b/bad-thread-instantiation/bad.py @@ -2,7 +2,7 @@ def thread_target(n): - print(n ** 2) + print(n**2) thread = threading.Thread(lambda: None) # [bad-thread-instantiation] diff --git a/doc/data/messages/b/bad-thread-instantiation/good.py b/doc/data/messages/b/bad-thread-instantiation/good.py index 735fa4da13..0dce7c342c 100644 --- a/doc/data/messages/b/bad-thread-instantiation/good.py +++ b/doc/data/messages/b/bad-thread-instantiation/good.py @@ -2,7 +2,7 @@ def thread_target(n): - print(n ** 2) + print(n**2) thread = threading.Thread(target=thread_target, args=(10,)) diff --git a/doc/data/messages/c/cell-var-from-loop/bad.py b/doc/data/messages/c/cell-var-from-loop/bad.py index 9dbd43880d..b319341894 100644 --- a/doc/data/messages/c/cell-var-from-loop/bad.py +++ b/doc/data/messages/c/cell-var-from-loop/bad.py @@ -1,5 +1,7 @@ def foo(numbers): for i in numbers: + def bar(): print(i) # [cell-var-from-loop] + bar() diff --git a/doc/data/messages/c/class-variable-slots-conflict/good.py b/doc/data/messages/c/class-variable-slots-conflict/good.py index b5324bff0f..2428f78662 100644 --- a/doc/data/messages/c/class-variable-slots-conflict/good.py +++ b/doc/data/messages/c/class-variable-slots-conflict/good.py @@ -1,5 +1,5 @@ class Person: - __slots__ = ("_age", "name",) + __slots__ = ("_age", "name") def __init__(self, age, name): self._age = age diff --git a/doc/data/messages/c/compare-to-zero/bad.py b/doc/data/messages/c/compare-to-zero/bad.py index a6b64a4079..c987403a40 100644 --- a/doc/data/messages/c/compare-to-zero/bad.py +++ b/doc/data/messages/c/compare-to-zero/bad.py @@ -1,8 +1,8 @@ x = 0 y = 1 -if x == 0: # [compare-to-zero] +if x == 0: # [compare-to-zero] print("x is equal to zero") -if y != 0: # [compare-to-zero] +if y != 0: # [compare-to-zero] print("y is not equal to zero") diff --git a/doc/data/messages/c/comparison-with-callable/bad.py b/doc/data/messages/c/comparison-with-callable/bad.py index 9dc5ecd921..1dbdad07c7 100644 --- a/doc/data/messages/c/comparison-with-callable/bad.py +++ b/doc/data/messages/c/comparison-with-callable/bad.py @@ -1,6 +1,7 @@ def function_returning_a_fruit() -> str: return "orange" + def is_an_orange(fruit: str = "apple"): # apple == return fruit == function_returning_a_fruit # [comparison-with-callable] diff --git a/doc/data/messages/c/comparison-with-callable/good.py b/doc/data/messages/c/comparison-with-callable/good.py index 587cf1b98c..a490071284 100644 --- a/doc/data/messages/c/comparison-with-callable/good.py +++ b/doc/data/messages/c/comparison-with-callable/good.py @@ -1,6 +1,7 @@ def function_returning_a_fruit() -> str: return "orange" + def is_an_orange(fruit: str = "apple"): # apple == orange return fruit == function_returning_a_fruit() diff --git a/doc/data/messages/c/confusing-with-statement/bad.py b/doc/data/messages/c/confusing-with-statement/bad.py index d842880580..e6570a5aa1 100644 --- a/doc/data/messages/c/confusing-with-statement/bad.py +++ b/doc/data/messages/c/confusing-with-statement/bad.py @@ -1,2 +1,2 @@ -with open('file.txt', 'w') as fh1, fh2: # [confusing-with-statement] +with open("file.txt", "w") as fh1, fh2: # [confusing-with-statement] pass diff --git a/doc/data/messages/c/confusing-with-statement/good.py b/doc/data/messages/c/confusing-with-statement/good.py index e8b39d5001..bcedaafa6f 100644 --- a/doc/data/messages/c/confusing-with-statement/good.py +++ b/doc/data/messages/c/confusing-with-statement/good.py @@ -1,3 +1,3 @@ -with open('file.txt', 'w', encoding="utf8") as fh1: - with open('file.txt', 'w', encoding="utf8") as fh2: +with open("file.txt", "w", encoding="utf8") as fh1: + with open("file.txt", "w", encoding="utf8") as fh2: pass diff --git a/doc/data/messages/c/consider-merging-isinstance/bad.py b/doc/data/messages/c/consider-merging-isinstance/bad.py index dca0ecf05b..c7b059cb46 100644 --- a/doc/data/messages/c/consider-merging-isinstance/bad.py +++ b/doc/data/messages/c/consider-merging-isinstance/bad.py @@ -2,4 +2,5 @@ def is_number(value: Any) -> bool: - return isinstance(value, int) or isinstance(value, float) # [consider-merging-isinstance] + # +1: [consider-merging-isinstance] + return isinstance(value, int) or isinstance(value, float) diff --git a/doc/data/messages/c/consider-using-any-or-all/good.py b/doc/data/messages/c/consider-using-any-or-all/good.py index 5acf18e745..71a727e57d 100644 --- a/doc/data/messages/c/consider-using-any-or-all/good.py +++ b/doc/data/messages/c/consider-using-any-or-all/good.py @@ -1,8 +1,8 @@ - def any_even(items): """Return True if the list contains any even numbers""" return any(item % 2 == 0 for item in items) + def all_even(items): """Return True if the list contains all even numbers""" return all(item % 2 == 0 for item in items) diff --git a/doc/data/messages/c/consider-using-enumerate/bad.py b/doc/data/messages/c/consider-using-enumerate/bad.py index 25d7cbf6b5..0beee2ecd5 100644 --- a/doc/data/messages/c/consider-using-enumerate/bad.py +++ b/doc/data/messages/c/consider-using-enumerate/bad.py @@ -1,4 +1,4 @@ -seasons = ['Spring', 'Summer', 'Fall', 'Winter'] +seasons = ["Spring", "Summer", "Fall", "Winter"] for i in range(len(seasons)): # [consider-using-enumerate] print(i, seasons[i]) diff --git a/doc/data/messages/c/consider-using-enumerate/good.py b/doc/data/messages/c/consider-using-enumerate/good.py index c52c270664..b078e48cb3 100644 --- a/doc/data/messages/c/consider-using-enumerate/good.py +++ b/doc/data/messages/c/consider-using-enumerate/good.py @@ -1,4 +1,4 @@ -seasons = ['Spring', 'Summer', 'Fall', 'Winter'] +seasons = ["Spring", "Summer", "Fall", "Winter"] for i, season in enumerate(seasons): print(i, season) diff --git a/doc/data/messages/c/consider-using-f-string/good.py b/doc/data/messages/c/consider-using-f-string/good.py index eec5abf0fe..f7913fa44d 100644 --- a/doc/data/messages/c/consider-using-f-string/good.py +++ b/doc/data/messages/c/consider-using-f-string/good.py @@ -1,3 +1,3 @@ -menu = ('eggs', 'spam', 42.4) +menu = ("eggs", "spam", 42.4) f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤" diff --git a/doc/data/messages/c/consider-using-in/bad.py b/doc/data/messages/c/consider-using-in/bad.py index 7199c1d825..81eddb7f36 100644 --- a/doc/data/messages/c/consider-using-in/bad.py +++ b/doc/data/messages/c/consider-using-in/bad.py @@ -1,2 +1,3 @@ def fruit_is_round(fruit): - return fruit == "apple" or fruit == "orange" or fruit == "melon" # [consider-using-in] + # +1: [consider-using-in] + return fruit == "apple" or fruit == "orange" or fruit == "melon" diff --git a/doc/data/messages/c/consider-using-join/bad.py b/doc/data/messages/c/consider-using-join/bad.py index c77b6f767b..5d5a32fb78 100644 --- a/doc/data/messages/c/consider-using-join/bad.py +++ b/doc/data/messages/c/consider-using-join/bad.py @@ -4,4 +4,5 @@ def fruits_to_string(fruits): formatted_fruit += fruit # [consider-using-join] return formatted_fruit + print(fruits_to_string(["apple", "pear", "peach"])) diff --git a/doc/data/messages/d/deprecated-method/bad.py b/doc/data/messages/d/deprecated-method/bad.py index dd75a258a9..78870f3c39 100644 --- a/doc/data/messages/d/deprecated-method/bad.py +++ b/doc/data/messages/d/deprecated-method/bad.py @@ -1,3 +1,3 @@ import logging -logging.warn("I'm coming, world !") # [deprecated-method] +logging.warn("I'm coming, world !") # [deprecated-method] diff --git a/doc/data/messages/d/dict-init-mutate/bad.py b/doc/data/messages/d/dict-init-mutate/bad.py index d6d1cfe189..d7db9c5286 100644 --- a/doc/data/messages/d/dict-init-mutate/bad.py +++ b/doc/data/messages/d/dict-init-mutate/bad.py @@ -1,3 +1,3 @@ fruit_prices = {} # [dict-init-mutate] -fruit_prices['apple'] = 1 -fruit_prices['banana'] = 10 +fruit_prices["apple"] = 1 +fruit_prices["banana"] = 10 diff --git a/doc/data/messages/d/dict-iter-missing-items/bad.py b/doc/data/messages/d/dict-iter-missing-items/bad.py index ec9dbd9244..52efa3ad79 100644 --- a/doc/data/messages/d/dict-iter-missing-items/bad.py +++ b/doc/data/messages/d/dict-iter-missing-items/bad.py @@ -1,3 +1,3 @@ -data = {'Paris': 2_165_423, 'New York City': 8_804_190, 'Tokyo': 13_988_129} +data = {"Paris": 2_165_423, "New York City": 8_804_190, "Tokyo": 13_988_129} for city, population in data: # [dict-iter-missing-items] print(f"{city} has population {population}.") diff --git a/doc/data/messages/d/dict-iter-missing-items/good.py b/doc/data/messages/d/dict-iter-missing-items/good.py index b94f125a33..3eb97f9e21 100644 --- a/doc/data/messages/d/dict-iter-missing-items/good.py +++ b/doc/data/messages/d/dict-iter-missing-items/good.py @@ -1,3 +1,3 @@ -data = {'Paris': 2_165_423, 'New York City': 8_804_190, 'Tokyo': 13_988_129} +data = {"Paris": 2_165_423, "New York City": 8_804_190, "Tokyo": 13_988_129} for city, population in data.items(): print(f"{city} has population {population}.") diff --git a/doc/data/messages/d/duplicate-code/bad/orange.py b/doc/data/messages/d/duplicate-code/bad/orange.py index faafce747f..9be3c7b404 100644 --- a/doc/data/messages/d/duplicate-code/bad/orange.py +++ b/doc/data/messages/d/duplicate-code/bad/orange.py @@ -1,4 +1,4 @@ -class Orange: # [duplicate-code] +class Orange: # [duplicate-code] def __init__(self): self.remaining_bites = 3 diff --git a/doc/data/messages/d/duplicate-value/bad.py b/doc/data/messages/d/duplicate-value/bad.py index bf6f8ad005..975eebdaea 100644 --- a/doc/data/messages/d/duplicate-value/bad.py +++ b/doc/data/messages/d/duplicate-value/bad.py @@ -1 +1 @@ -incorrect_set = {'value1', 23, 5, 'value1'} # [duplicate-value] +incorrect_set = {"value1", 23, 5, "value1"} # [duplicate-value] diff --git a/doc/data/messages/d/duplicate-value/good.py b/doc/data/messages/d/duplicate-value/good.py index c30cd78213..beeeb39b9b 100644 --- a/doc/data/messages/d/duplicate-value/good.py +++ b/doc/data/messages/d/duplicate-value/good.py @@ -1 +1 @@ -correct_set = {'value1', 23, 5} +correct_set = {"value1", 23, 5} diff --git a/doc/data/messages/e/exec-used/good.py b/doc/data/messages/e/exec-used/good.py index ef9b17f3f3..f3e1dd7b7f 100644 --- a/doc/data/messages/e/exec-used/good.py +++ b/doc/data/messages/e/exec-used/good.py @@ -1,8 +1,9 @@ def get_user_code(name): - return input(f'Enter code to be executed please, {name}: ') + return input(f"Enter code to be executed please, {name}: ") username = "Ada" -allowed_globals = {'__builtins__' : None} -allowed_locals = {'print': print} -exec(get_user_code(username), allowed_globals, allowed_locals) # pylint: disable=exec-used +allowed_globals = {"__builtins__": None} +allowed_locals = {"print": print} +# pylint: disable-next=exec-used +exec(get_user_code(username), allowed_globals, allowed_locals) diff --git a/doc/data/messages/f/forgotten-debug-statement/bad.py b/doc/data/messages/f/forgotten-debug-statement/bad.py index 6a2a34580a..e37185371b 100644 --- a/doc/data/messages/f/forgotten-debug-statement/bad.py +++ b/doc/data/messages/f/forgotten-debug-statement/bad.py @@ -3,10 +3,15 @@ def find_the_treasure(clues): for clue in clues: - pdb.set_trace() # [forgotten-debug-statement] + pdb.set_trace() # [forgotten-debug-statement] if "treasure" in clue: return True return False -treasure_hunt = ["Dead Man's Chest", "X marks the spot", "The treasure is buried near the palm tree"] + +treasure_hunt = [ + "Dead Man's Chest", + "X marks the spot", + "The treasure is buried near the palm tree", +] find_the_treasure(treasure_hunt) diff --git a/doc/data/messages/f/forgotten-debug-statement/good.py b/doc/data/messages/f/forgotten-debug-statement/good.py index 21132cb472..7896ff50eb 100644 --- a/doc/data/messages/f/forgotten-debug-statement/good.py +++ b/doc/data/messages/f/forgotten-debug-statement/good.py @@ -4,5 +4,10 @@ def find_the_treasure(clues): return True return False -treasure_hunt = ["Dead Man's Chest", "X marks the spot", "The treasure is buried near the palm tree"] + +treasure_hunt = [ + "Dead Man's Chest", + "X marks the spot", + "The treasure is buried near the palm tree", +] find_the_treasure(treasure_hunt) diff --git a/doc/data/messages/f/format-combined-specification/bad.py b/doc/data/messages/f/format-combined-specification/bad.py index 6a6a051f21..f530aa0d58 100644 --- a/doc/data/messages/f/format-combined-specification/bad.py +++ b/doc/data/messages/f/format-combined-specification/bad.py @@ -1 +1 @@ -print('{} {1}'.format('hello', 'world')) # [format-combined-specification] +print("{} {1}".format("hello", "world")) # [format-combined-specification] diff --git a/doc/data/messages/f/format-combined-specification/good.py b/doc/data/messages/f/format-combined-specification/good.py index 542b775076..8aaab67f22 100644 --- a/doc/data/messages/f/format-combined-specification/good.py +++ b/doc/data/messages/f/format-combined-specification/good.py @@ -1,3 +1,3 @@ -print('{0} {1}'.format('hello', 'world')) +print("{0} {1}".format("hello", "world")) # or -print('{} {}'.format('hello', 'world')) +print("{} {}".format("hello", "world")) diff --git a/doc/data/messages/i/import-outside-toplevel/bad.py b/doc/data/messages/i/import-outside-toplevel/bad.py index 54db8840db..5262ba7709 100644 --- a/doc/data/messages/i/import-outside-toplevel/bad.py +++ b/doc/data/messages/i/import-outside-toplevel/bad.py @@ -1,3 +1,4 @@ def print_python_version(): import sys # [import-outside-toplevel] + print(sys.version_info) diff --git a/doc/data/messages/i/import-private-name/bad.py b/doc/data/messages/i/import-private-name/bad.py index 96a2a9fc99..e562e49289 100644 --- a/doc/data/messages/i/import-private-name/bad.py +++ b/doc/data/messages/i/import-private-name/bad.py @@ -2,6 +2,7 @@ attr_holder = _AttributeHolder() + def add_sub_parser(sub_parsers: _SubParsersAction): - sub_parsers.add_parser('my_subparser') + sub_parsers.add_parser("my_subparser") # ... diff --git a/doc/data/messages/i/import-private-name/good.py b/doc/data/messages/i/import-private-name/good.py index 3a5599cfbf..810005feab 100644 --- a/doc/data/messages/i/import-private-name/good.py +++ b/doc/data/messages/i/import-private-name/good.py @@ -4,5 +4,5 @@ def add_sub_parser(sub_parsers: _SubParsersAction): - sub_parsers.add_parser('my_subparser') + sub_parsers.add_parser("my_subparser") # ... diff --git a/doc/data/messages/i/init-is-generator/bad.py b/doc/data/messages/i/init-is-generator/bad.py index 37c204ab24..415b94c4dd 100644 --- a/doc/data/messages/i/init-is-generator/bad.py +++ b/doc/data/messages/i/init-is-generator/bad.py @@ -2,4 +2,5 @@ class Fruit: def __init__(self, worms): # [init-is-generator] yield from worms + apple = Fruit(["Fahad", "Anisha", "Tabatha"]) diff --git a/doc/data/messages/i/init-is-generator/good.py b/doc/data/messages/i/init-is-generator/good.py index 483cd46c18..1f5bf0047d 100644 --- a/doc/data/messages/i/init-is-generator/good.py +++ b/doc/data/messages/i/init-is-generator/good.py @@ -5,6 +5,7 @@ def __init__(self, worms): def worms(self): yield from self.__worms + apple = Fruit(["Fahad", "Anisha", "Tabatha"]) for worm in apple.worms(): pass diff --git a/doc/data/messages/i/invalid-all-format/bad.py b/doc/data/messages/i/invalid-all-format/bad.py index 9559869a99..c891377344 100644 --- a/doc/data/messages/i/invalid-all-format/bad.py +++ b/doc/data/messages/i/invalid-all-format/bad.py @@ -1,3 +1,3 @@ -__all__ = ("CONST") # [invalid-all-format] +__all__ = "CONST" # [invalid-all-format] CONST = 42 diff --git a/doc/data/messages/i/invalid-all-object/bad.py b/doc/data/messages/i/invalid-all-object/bad.py index 74cf738dce..04509727b8 100644 --- a/doc/data/messages/i/invalid-all-object/bad.py +++ b/doc/data/messages/i/invalid-all-object/bad.py @@ -4,8 +4,10 @@ Worm, ) + class Fruit: pass + class Worm: pass diff --git a/doc/data/messages/i/invalid-all-object/good.py b/doc/data/messages/i/invalid-all-object/good.py index db5879cf39..351cfa1c64 100644 --- a/doc/data/messages/i/invalid-all-object/good.py +++ b/doc/data/messages/i/invalid-all-object/good.py @@ -1,7 +1,9 @@ -__all__ = ['Fruit', 'Worm'] +__all__ = ["Fruit", "Worm"] + class Fruit: pass + class Worm: pass diff --git a/doc/data/messages/i/invalid-character-backspace/bad.py b/doc/data/messages/i/invalid-character-backspace/bad.py index a41d6b2bc5..ac9ed67a36 100644 --- a/doc/data/messages/i/invalid-character-backspace/bad.py +++ b/doc/data/messages/i/invalid-character-backspace/bad.py @@ -1 +1 @@ -STRING = "Invalid character backspace " # [invalid-character-backspace] +STRING = "Invalid character backspace " # [invalid-character-backspace] diff --git a/doc/data/messages/i/invalid-character-esc/bad.py b/doc/data/messages/i/invalid-character-esc/bad.py index 24c6a79ea1..0d50cab427 100644 --- a/doc/data/messages/i/invalid-character-esc/bad.py +++ b/doc/data/messages/i/invalid-character-esc/bad.py @@ -1 +1 @@ -STRING = "Invalid escape character " # [invalid-character-esc] +STRING = "Invalid escape character " # [invalid-character-esc] diff --git a/doc/data/messages/i/invalid-character-sub/bad.py b/doc/data/messages/i/invalid-character-sub/bad.py index 96f8c06fe3..313066d3b8 100644 --- a/doc/data/messages/i/invalid-character-sub/bad.py +++ b/doc/data/messages/i/invalid-character-sub/bad.py @@ -1 +1 @@ -STRING = "Invalid character sub " # [invalid-character-sub] +STRING = "Invalid character sub " # [invalid-character-sub] diff --git a/doc/data/messages/i/invalid-character-zero-width-space/bad.py b/doc/data/messages/i/invalid-character-zero-width-space/bad.py index 1854893b49..99160fc8f8 100644 --- a/doc/data/messages/i/invalid-character-zero-width-space/bad.py +++ b/doc/data/messages/i/invalid-character-zero-width-space/bad.py @@ -1 +1 @@ -STRING = "Invalid character zero-width-space ​" # [invalid-character-zero-width-space] +STRING = "Invalid character zero-width-space ​" # [invalid-character-zero-width-space] diff --git a/doc/data/messages/i/invalid-envvar-default/bad.py b/doc/data/messages/i/invalid-envvar-default/bad.py index 8d66765ee7..9b564b9c8c 100644 --- a/doc/data/messages/i/invalid-envvar-default/bad.py +++ b/doc/data/messages/i/invalid-envvar-default/bad.py @@ -1,3 +1,3 @@ import os -env = os.getenv('SECRET_KEY', 1) # [invalid-envvar-default] +env = os.getenv("SECRET_KEY", 1) # [invalid-envvar-default] diff --git a/doc/data/messages/i/invalid-envvar-default/good.py b/doc/data/messages/i/invalid-envvar-default/good.py index 67656d04a2..103925941e 100644 --- a/doc/data/messages/i/invalid-envvar-default/good.py +++ b/doc/data/messages/i/invalid-envvar-default/good.py @@ -1,3 +1,3 @@ import os -env = os.getenv('SECRET_KEY', '1') +env = os.getenv("SECRET_KEY", "1") diff --git a/doc/data/messages/i/invalid-envvar-value/good.py b/doc/data/messages/i/invalid-envvar-value/good.py index 0b510db39f..fd082ecfd8 100644 --- a/doc/data/messages/i/invalid-envvar-value/good.py +++ b/doc/data/messages/i/invalid-envvar-value/good.py @@ -1,3 +1,3 @@ import os -os.getenv('1') +os.getenv("1") diff --git a/doc/data/messages/i/invalid-format-index/good.py b/doc/data/messages/i/invalid-format-index/good.py index 37129745b0..69557980bc 100644 --- a/doc/data/messages/i/invalid-format-index/good.py +++ b/doc/data/messages/i/invalid-format-index/good.py @@ -1,2 +1,2 @@ enough_fruits = ["apple", "banana"] -print('The second fruit is a {fruits[1]}'.format(fruits=enough_fruits)) +print("The second fruit is a {fruits[1]}".format(fruits=enough_fruits)) diff --git a/doc/data/messages/i/invalid-length-returned/bad.py b/doc/data/messages/i/invalid-length-returned/bad.py index 0dcac176c6..2ae1396c38 100644 --- a/doc/data/messages/i/invalid-length-returned/bad.py +++ b/doc/data/messages/i/invalid-length-returned/bad.py @@ -3,4 +3,4 @@ def __init__(self, fruits): self.fruits = ["Apple", "Banana", "Orange"] def __len__(self): # [invalid-length-returned] - return - len(self.fruits) + return -len(self.fruits) diff --git a/doc/data/messages/i/invalid-metaclass/good.py b/doc/data/messages/i/invalid-metaclass/good.py index e8b90fc01c..07c907f10c 100644 --- a/doc/data/messages/i/invalid-metaclass/good.py +++ b/doc/data/messages/i/invalid-metaclass/good.py @@ -1,5 +1,6 @@ class Plant: pass + class Apple(Plant): pass diff --git a/doc/data/messages/i/invalid-name/bad.py b/doc/data/messages/i/invalid-name/bad.py index fac9b49472..b40ee47469 100644 --- a/doc/data/messages/i/invalid-name/bad.py +++ b/doc/data/messages/i/invalid-name/bad.py @@ -1,5 +1,4 @@ class cat: # [invalid-name] - def Meow(self, NUMBER_OF_MEOW): # [invalid-name, invalid-name] print("Meow" * NUMBER_OF_MEOW) return NUMBER_OF_MEOW diff --git a/doc/data/messages/i/invalid-name/good.py b/doc/data/messages/i/invalid-name/good.py index 3decdb3e4a..d747a72f0f 100644 --- a/doc/data/messages/i/invalid-name/good.py +++ b/doc/data/messages/i/invalid-name/good.py @@ -1,5 +1,4 @@ class Cat: - def meow(self, number_of_meow): print("Meow" * number_of_meow) return number_of_meow diff --git a/doc/data/messages/i/invalid-overridden-method/bad.py b/doc/data/messages/i/invalid-overridden-method/bad.py index 379f7c0a1b..c7e250fb59 100644 --- a/doc/data/messages/i/invalid-overridden-method/bad.py +++ b/doc/data/messages/i/invalid-overridden-method/bad.py @@ -2,6 +2,7 @@ class Fruit: async def bore(self, insect): insect.eat(self) + class Apple(Fruit): def bore(self, insect): # [invalid-overridden-method] insect.eat(self) diff --git a/doc/data/messages/i/invalid-overridden-method/good.py b/doc/data/messages/i/invalid-overridden-method/good.py index f5b56308f8..3206637787 100644 --- a/doc/data/messages/i/invalid-overridden-method/good.py +++ b/doc/data/messages/i/invalid-overridden-method/good.py @@ -2,6 +2,7 @@ class Fruit: async def bore(self, insect): insect.eat(self) + class Apple(Fruit): async def bore(self, insect): insect.eat(self) diff --git a/doc/data/messages/i/invalid-sequence-index/bad.py b/doc/data/messages/i/invalid-sequence-index/bad.py index f153503b95..c13a3742a4 100644 --- a/doc/data/messages/i/invalid-sequence-index/bad.py +++ b/doc/data/messages/i/invalid-sequence-index/bad.py @@ -1,2 +1,2 @@ -fruits = ['apple', 'banana', 'orange'] -print(fruits['apple']) # [invalid-sequence-index] +fruits = ["apple", "banana", "orange"] +print(fruits["apple"]) # [invalid-sequence-index] diff --git a/doc/data/messages/i/invalid-sequence-index/good.py b/doc/data/messages/i/invalid-sequence-index/good.py index 04bdf3ffd1..840f3c3f33 100644 --- a/doc/data/messages/i/invalid-sequence-index/good.py +++ b/doc/data/messages/i/invalid-sequence-index/good.py @@ -1,2 +1,2 @@ -fruits = ['apple', 'banana', 'orange'] +fruits = ["apple", "banana", "orange"] print(fruits[0]) diff --git a/doc/data/messages/i/invalid-slots-object/bad.py b/doc/data/messages/i/invalid-slots-object/bad.py index 41baaa54f4..03690cf36b 100644 --- a/doc/data/messages/i/invalid-slots-object/bad.py +++ b/doc/data/messages/i/invalid-slots-object/bad.py @@ -1,2 +1,2 @@ class Person: - __slots__ = ('name', 3) # [invalid-slots-object] + __slots__ = ("name", 3) # [invalid-slots-object] diff --git a/doc/data/messages/i/invalid-slots-object/good.py b/doc/data/messages/i/invalid-slots-object/good.py index e8eec69491..823a971f1d 100644 --- a/doc/data/messages/i/invalid-slots-object/good.py +++ b/doc/data/messages/i/invalid-slots-object/good.py @@ -1,2 +1,2 @@ class Person: - __slots__ = ('name', 'surname') + __slots__ = ("name", "surname") diff --git a/doc/data/messages/i/invalid-slots/good.py b/doc/data/messages/i/invalid-slots/good.py index 0cb4d1b1e3..b7881356c9 100644 --- a/doc/data/messages/i/invalid-slots/good.py +++ b/doc/data/messages/i/invalid-slots/good.py @@ -1,2 +1,2 @@ class Person: - __slots__ = ("name", "age",) + __slots__ = ("name", "age") diff --git a/doc/data/messages/i/invalid-star-assignment-target/bad.py b/doc/data/messages/i/invalid-star-assignment-target/bad.py index fc69dc7e62..476928560d 100644 --- a/doc/data/messages/i/invalid-star-assignment-target/bad.py +++ b/doc/data/messages/i/invalid-star-assignment-target/bad.py @@ -1 +1 @@ -*fruit = ['apple', 'banana', 'orange'] # [invalid-star-assignment-target] +*fruit = ["apple", "banana", "orange"] # [invalid-star-assignment-target] diff --git a/doc/data/messages/i/invalid-star-assignment-target/good.py b/doc/data/messages/i/invalid-star-assignment-target/good.py index 74cf088e27..b174bcd208 100644 --- a/doc/data/messages/i/invalid-star-assignment-target/good.py +++ b/doc/data/messages/i/invalid-star-assignment-target/good.py @@ -1 +1 @@ -fruit = ['apple', 'banana', 'orange'] +fruit = ["apple", "banana", "orange"] diff --git a/doc/data/messages/i/invalid-unary-operand-type/bad.py b/doc/data/messages/i/invalid-unary-operand-type/bad.py index 77391c3d9e..b011951941 100644 --- a/doc/data/messages/i/invalid-unary-operand-type/bad.py +++ b/doc/data/messages/i/invalid-unary-operand-type/bad.py @@ -1,3 +1,3 @@ cherries = 10 eaten_cherries = int -cherries = - eaten_cherries # [invalid-unary-operand-type] +cherries = -eaten_cherries # [invalid-unary-operand-type] diff --git a/doc/data/messages/l/locally-disabled/bad.py b/doc/data/messages/l/locally-disabled/bad.py index 5bfbd58f88..1a33078567 100644 --- a/doc/data/messages/l/locally-disabled/bad.py +++ b/doc/data/messages/l/locally-disabled/bad.py @@ -3,5 +3,6 @@ def wizard_spells(spell_book): for spell in spell_book: print(f"Abracadabra! {spell}.") + spell_list = ["Levitation", "Invisibility", "Fireball", "Teleportation"] wizard_spells(spell_list) diff --git a/doc/data/messages/l/locally-disabled/good.py b/doc/data/messages/l/locally-disabled/good.py index 322a78f27e..1bf60bca03 100644 --- a/doc/data/messages/l/locally-disabled/good.py +++ b/doc/data/messages/l/locally-disabled/good.py @@ -2,5 +2,6 @@ def wizard_spells(spell_book): for spell in spell_book: print(f"Abracadabra! {spell}.") + spell_list = ["Levitation", "Invisibility", "Fireball", "Teleportation"] wizard_spells(spell_list) diff --git a/doc/data/messages/l/logging-format-interpolation/bad.py b/doc/data/messages/l/logging-format-interpolation/bad.py index 0cef831d20..dd828e1f91 100644 --- a/doc/data/messages/l/logging-format-interpolation/bad.py +++ b/doc/data/messages/l/logging-format-interpolation/bad.py @@ -1,4 +1,5 @@ import logging import sys -logging.error('Python version: {}'.format(sys.version)) # [logging-format-interpolation] +# +1: [logging-format-interpolation] +logging.error("Python version: {}".format(sys.version)) diff --git a/doc/data/messages/l/logging-format-interpolation/good.py b/doc/data/messages/l/logging-format-interpolation/good.py index 7f54cebfb3..a993d0dd81 100644 --- a/doc/data/messages/l/logging-format-interpolation/good.py +++ b/doc/data/messages/l/logging-format-interpolation/good.py @@ -1,4 +1,4 @@ import logging import sys -logging.error('Python version: %s', sys.version) +logging.error("Python version: %s", sys.version) diff --git a/doc/data/messages/l/logging-fstring-interpolation/bad.py b/doc/data/messages/l/logging-fstring-interpolation/bad.py index dfee6d4c6c..773435fb41 100644 --- a/doc/data/messages/l/logging-fstring-interpolation/bad.py +++ b/doc/data/messages/l/logging-fstring-interpolation/bad.py @@ -1,4 +1,4 @@ import logging import sys -logging.error(f'Python version: {sys.version}') # [logging-fstring-interpolation] +logging.error(f"Python version: {sys.version}") # [logging-fstring-interpolation] diff --git a/doc/data/messages/l/logging-fstring-interpolation/good.py b/doc/data/messages/l/logging-fstring-interpolation/good.py index 7f54cebfb3..a993d0dd81 100644 --- a/doc/data/messages/l/logging-fstring-interpolation/good.py +++ b/doc/data/messages/l/logging-fstring-interpolation/good.py @@ -1,4 +1,4 @@ import logging import sys -logging.error('Python version: %s', sys.version) +logging.error("Python version: %s", sys.version) diff --git a/doc/data/messages/l/logging-not-lazy/bad.py b/doc/data/messages/l/logging-not-lazy/bad.py index cb6bc3d840..7ba0631db9 100644 --- a/doc/data/messages/l/logging-not-lazy/bad.py +++ b/doc/data/messages/l/logging-not-lazy/bad.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('Error occurred: %s' % e) # [logging-not-lazy] + logging.error("Error occurred: %s" % e) # [logging-not-lazy] raise diff --git a/doc/data/messages/l/logging-not-lazy/good.py b/doc/data/messages/l/logging-not-lazy/good.py index c61704872f..ede0050cbc 100644 --- a/doc/data/messages/l/logging-not-lazy/good.py +++ b/doc/data/messages/l/logging-not-lazy/good.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('Error occurred: %s', e) + logging.error("Error occurred: %s", e) raise diff --git a/doc/data/messages/l/logging-too-few-args/bad.py b/doc/data/messages/l/logging-too-few-args/bad.py index 66d88d0b35..a20b83b12b 100644 --- a/doc/data/messages/l/logging-too-few-args/bad.py +++ b/doc/data/messages/l/logging-too-few-args/bad.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('%s error occurred: %s', e) # [logging-too-few-args] + logging.error("%s error occurred: %s", e) # [logging-too-few-args] raise diff --git a/doc/data/messages/l/logging-too-few-args/good.py b/doc/data/messages/l/logging-too-few-args/good.py index 4b34b58b9e..4812aec01a 100644 --- a/doc/data/messages/l/logging-too-few-args/good.py +++ b/doc/data/messages/l/logging-too-few-args/good.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('%s error occurred: %s', type(e), e) + logging.error("%s error occurred: %s", type(e), e) raise diff --git a/doc/data/messages/l/logging-too-many-args/bad.py b/doc/data/messages/l/logging-too-many-args/bad.py index 45f485d935..03753f607e 100644 --- a/doc/data/messages/l/logging-too-many-args/bad.py +++ b/doc/data/messages/l/logging-too-many-args/bad.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('Error occurred: %s', type(e), e) # [logging-too-many-args] + logging.error("Error occurred: %s", type(e), e) # [logging-too-many-args] raise diff --git a/doc/data/messages/l/logging-too-many-args/good.py b/doc/data/messages/l/logging-too-many-args/good.py index 4b34b58b9e..4812aec01a 100644 --- a/doc/data/messages/l/logging-too-many-args/good.py +++ b/doc/data/messages/l/logging-too-many-args/good.py @@ -3,5 +3,5 @@ try: function() except Exception as e: - logging.error('%s error occurred: %s', type(e), e) + logging.error("%s error occurred: %s", type(e), e) raise diff --git a/doc/data/messages/l/logging-unsupported-format/bad.py b/doc/data/messages/l/logging-unsupported-format/bad.py index 5b5ea5a5f7..1f36a0d342 100644 --- a/doc/data/messages/l/logging-unsupported-format/bad.py +++ b/doc/data/messages/l/logging-unsupported-format/bad.py @@ -1,3 +1,3 @@ import logging -logging.info("%s %y !", "Hello", "World") # [logging-unsupported-format] +logging.info("%s %y !", "Hello", "World") # [logging-unsupported-format] diff --git a/doc/data/messages/m/magic-value-comparison/bad.py b/doc/data/messages/m/magic-value-comparison/bad.py index 536659abe7..eef9e5d27b 100644 --- a/doc/data/messages/m/magic-value-comparison/bad.py +++ b/doc/data/messages/m/magic-value-comparison/bad.py @@ -3,8 +3,8 @@ measurement = random.randint(0, 200) above_threshold = False i = 0 -while i < 5: # [magic-value-comparison] - above_threshold = measurement > 100 # [magic-value-comparison] +while i < 5: # [magic-value-comparison] + above_threshold = measurement > 100 # [magic-value-comparison] if above_threshold: break measurement = random.randint(0, 200) diff --git a/doc/data/messages/m/misplaced-format-function/bad.py b/doc/data/messages/m/misplaced-format-function/bad.py index 0bd1723696..bc40bba4d3 100644 --- a/doc/data/messages/m/misplaced-format-function/bad.py +++ b/doc/data/messages/m/misplaced-format-function/bad.py @@ -1 +1 @@ -print('Value: {}').format('Car') # [misplaced-format-function] +print("Value: {}").format("Car") # [misplaced-format-function] diff --git a/doc/data/messages/m/misplaced-format-function/good.py b/doc/data/messages/m/misplaced-format-function/good.py index 809dcf9744..8b31d5cf56 100644 --- a/doc/data/messages/m/misplaced-format-function/good.py +++ b/doc/data/messages/m/misplaced-format-function/good.py @@ -1 +1 @@ -print('Value: {}'.format('Car')) +print("Value: {}".format("Car")) diff --git a/doc/data/messages/m/missing-any-param-doc/bad.py b/doc/data/messages/m/missing-any-param-doc/bad.py index ca92793f5c..bf5f232ce3 100644 --- a/doc/data/messages/m/missing-any-param-doc/bad.py +++ b/doc/data/messages/m/missing-any-param-doc/bad.py @@ -1,3 +1,3 @@ -def puppies(head, tail): #[missing-any-param-doc] +def puppies(head, tail): # [missing-any-param-doc] """Print puppy's details.""" print(head, tail) diff --git a/doc/data/messages/m/missing-any-param-doc/good.py b/doc/data/messages/m/missing-any-param-doc/good.py index 238ea1bce5..6fa9622eee 100644 --- a/doc/data/messages/m/missing-any-param-doc/good.py +++ b/doc/data/messages/m/missing-any-param-doc/good.py @@ -1,7 +1,7 @@ def puppies(head: str, tail: str): """Print puppy's details. - :param head: description of the head of the dog - :param tail: description of the tail of the dog + :param head: description of the head of the dog + :param tail: description of the tail of the dog """ print(head, tail) diff --git a/doc/data/messages/m/missing-class-docstring/bad.py b/doc/data/messages/m/missing-class-docstring/bad.py index 1d0f79c751..e3e1ddbf56 100644 --- a/doc/data/messages/m/missing-class-docstring/bad.py +++ b/doc/data/messages/m/missing-class-docstring/bad.py @@ -1,5 +1,4 @@ class Person: # [missing-class-docstring] - def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name diff --git a/doc/data/messages/m/missing-final-newline/good.py b/doc/data/messages/m/missing-final-newline/good.py index fa1e5072e8..02d068916e 100644 --- a/doc/data/messages/m/missing-final-newline/good.py +++ b/doc/data/messages/m/missing-final-newline/good.py @@ -1,6 +1,6 @@ # using LF -eat("apple", "candy") # \n +eat("apple", "candy") # \n print(123) # \nEOF # using CRLF diff --git a/doc/data/messages/m/missing-kwoa/bad.py b/doc/data/messages/m/missing-kwoa/bad.py index 4039c8ff28..2b8deabdfa 100644 --- a/doc/data/messages/m/missing-kwoa/bad.py +++ b/doc/data/messages/m/missing-kwoa/bad.py @@ -1,5 +1,6 @@ def target(pos, *, keyword): return pos + keyword + def not_forwarding_kwargs(*args, **kwargs): - target(*args) # [missing-kwoa] + target(*args) # [missing-kwoa] diff --git a/doc/data/messages/m/missing-kwoa/good.py b/doc/data/messages/m/missing-kwoa/good.py index abb80a1185..c212deb987 100644 --- a/doc/data/messages/m/missing-kwoa/good.py +++ b/doc/data/messages/m/missing-kwoa/good.py @@ -1,5 +1,6 @@ def target(pos, *, keyword): return pos + keyword + def not_forwarding_kwargs(*args, **kwargs): target(*args, **kwargs) diff --git a/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py b/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py index 3f67322dc2..e4a7172a4e 100644 --- a/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py +++ b/doc/data/messages/m/missing-parentheses-for-call-in-test/bad.py @@ -4,5 +4,6 @@ def is_it_a_good_day(): return random.choice([True, False]) + if is_it_a_good_day: # [missing-parentheses-for-call-in-test] print("Today is a good day!") diff --git a/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py b/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py index 63c8ccc893..80afd77696 100644 --- a/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py +++ b/doc/data/messages/m/missing-parentheses-for-call-in-test/good.py @@ -4,5 +4,6 @@ def is_it_a_good_day(): return random.choice([True, False]) + if is_it_a_good_day(): print("Today is a good day!") diff --git a/doc/data/messages/m/missing-raises-doc/bad.py b/doc/data/messages/m/missing-raises-doc/bad.py index 9a59fea88b..51efd39108 100644 --- a/doc/data/messages/m/missing-raises-doc/bad.py +++ b/doc/data/messages/m/missing-raises-doc/bad.py @@ -4,5 +4,5 @@ def integer_sum(a: int, b: int): # [missing-raises-doc] :param b: second integer """ if not (isinstance(a, int) and isinstance(b, int)): - raise ValueError('Function supports only integer parameters.') + raise ValueError("Function supports only integer parameters.") return a + b diff --git a/doc/data/messages/m/missing-raises-doc/good.py b/doc/data/messages/m/missing-raises-doc/good.py index c274493ea6..6ca44d0fdb 100644 --- a/doc/data/messages/m/missing-raises-doc/good.py +++ b/doc/data/messages/m/missing-raises-doc/good.py @@ -5,5 +5,5 @@ def integer_sum(a: int, b: int): :raises ValueError: One of the parameters is not an integer. """ if not (isinstance(a, int) and isinstance(b, int)): - raise ValueError('Function supports only integer parameters.') + raise ValueError("Function supports only integer parameters.") return a + b diff --git a/doc/data/messages/n/named-expr-without-context/good.py b/doc/data/messages/n/named-expr-without-context/good.py index 50f6b26210..fb088bb992 100644 --- a/doc/data/messages/n/named-expr-without-context/good.py +++ b/doc/data/messages/n/named-expr-without-context/good.py @@ -1,2 +1,2 @@ -if (a := 42): - print('Success') +if a := 42: + print("Success") diff --git a/doc/data/messages/n/no-else-continue/bad.py b/doc/data/messages/n/no-else-continue/bad.py index 5e3172947a..a561f93cc1 100644 --- a/doc/data/messages/n/no-else-continue/bad.py +++ b/doc/data/messages/n/no-else-continue/bad.py @@ -1,6 +1,6 @@ def even_number_under(n: int): for i in range(n): - if i%2 == 1: # [no-else-continue] + if i % 2 == 1: # [no-else-continue] continue else: yield i diff --git a/doc/data/messages/n/no-else-continue/good.py b/doc/data/messages/n/no-else-continue/good.py index 8aaef70140..e73e0e21cc 100644 --- a/doc/data/messages/n/no-else-continue/good.py +++ b/doc/data/messages/n/no-else-continue/good.py @@ -1,5 +1,5 @@ def even_number_under(n: int): for i in range(n): - if i%2 == 1: + if i % 2 == 1: continue yield i diff --git a/doc/data/messages/n/no-else-raise/bad.py b/doc/data/messages/n/no-else-raise/bad.py index d2f590ab80..c5fdf996e6 100644 --- a/doc/data/messages/n/no-else-raise/bad.py +++ b/doc/data/messages/n/no-else-raise/bad.py @@ -1,5 +1,5 @@ def integer_sum(a: int, b: int) -> int: - if not (isinstance(a, int) and isinstance(b, int)): # [no-else-raise] - raise ValueError('Function supports only integer parameters.') + if not (isinstance(a, int) and isinstance(b, int)): # [no-else-raise] + raise ValueError("Function supports only integer parameters.") else: return a + b diff --git a/doc/data/messages/n/no-else-raise/good.py b/doc/data/messages/n/no-else-raise/good.py index c0d577cfac..bf29181488 100644 --- a/doc/data/messages/n/no-else-raise/good.py +++ b/doc/data/messages/n/no-else-raise/good.py @@ -1,4 +1,4 @@ def integer_sum(a: int, b: int) -> int: if not (isinstance(a, int) and isinstance(b, int)): - raise ValueError('Function supports only integer parameters.') + raise ValueError("Function supports only integer parameters.") return a + b diff --git a/doc/data/messages/n/no-self-use/bad.py b/doc/data/messages/n/no-self-use/bad.py index 8c44a3c1e9..07ab6f3ab1 100644 --- a/doc/data/messages/n/no-self-use/bad.py +++ b/doc/data/messages/n/no-self-use/bad.py @@ -1,5 +1,4 @@ class Person: - def developer_greeting(self): # [no-self-use] print("Greetings developer!") diff --git a/doc/data/messages/n/no-value-for-parameter/bad.py b/doc/data/messages/n/no-value-for-parameter/bad.py index cf10d9a57c..31b08a16a4 100644 --- a/doc/data/messages/n/no-value-for-parameter/bad.py +++ b/doc/data/messages/n/no-value-for-parameter/bad.py @@ -1,4 +1,5 @@ def add(x, y): return x + y + add(1) # [no-value-for-parameter] diff --git a/doc/data/messages/n/no-value-for-parameter/good.py b/doc/data/messages/n/no-value-for-parameter/good.py index e14c45c21c..068b525279 100644 --- a/doc/data/messages/n/no-value-for-parameter/good.py +++ b/doc/data/messages/n/no-value-for-parameter/good.py @@ -1,4 +1,5 @@ def add(x, y): return x + y + add(1, 2) diff --git a/doc/data/messages/o/overlapping-except/good.py b/doc/data/messages/o/overlapping-except/good.py index 41a727545c..0cace420e6 100644 --- a/doc/data/messages/o/overlapping-except/good.py +++ b/doc/data/messages/o/overlapping-except/good.py @@ -7,10 +7,14 @@ def divide_x_by_y(x: float, y: float): # FloatingPointError were already caught at this point print(f"There was an OverflowError or a ZeroDivisionError: {e}") + # Or: + def divide_x_by_y(x: float, y: float): try: print(x / y) except ArithmeticError as e: - print(f"There was an OverflowError, a ZeroDivisionError or a FloatingPointError: {e}") + print( + f"There was an OverflowError, a ZeroDivisionError or a FloatingPointError: {e}" + ) diff --git a/doc/data/messages/p/positional-only-arguments-expected/bad.py b/doc/data/messages/p/positional-only-arguments-expected/bad.py index 30720555aa..75e63e5727 100644 --- a/doc/data/messages/p/positional-only-arguments-expected/bad.py +++ b/doc/data/messages/p/positional-only-arguments-expected/bad.py @@ -2,4 +2,5 @@ def cube(n, /): """Takes in a number n, returns the cube of n""" return n**3 -cube(n=2) # [positional-only-arguments-expected] + +cube(n=2) # [positional-only-arguments-expected] diff --git a/doc/data/messages/p/positional-only-arguments-expected/good.py b/doc/data/messages/p/positional-only-arguments-expected/good.py index ca734e546d..77cdc80a42 100644 --- a/doc/data/messages/p/positional-only-arguments-expected/good.py +++ b/doc/data/messages/p/positional-only-arguments-expected/good.py @@ -2,4 +2,5 @@ def cube(n, /): """Takes in a number n, returns the cube of n""" return n**3 + cube(2) diff --git a/doc/data/messages/r/redefined-argument-from-local/bad.py b/doc/data/messages/r/redefined-argument-from-local/bad.py index 24d441219d..733f307b3a 100644 --- a/doc/data/messages/r/redefined-argument-from-local/bad.py +++ b/doc/data/messages/r/redefined-argument-from-local/bad.py @@ -1,3 +1,4 @@ def show(host_id=10.11): - for host_id, host in [[12.13, 'Venus'], [14.15, 'Mars']]: # [redefined-argument-from-local] + # +1: [redefined-argument-from-local] + for host_id, host in [[12.13, "Venus"], [14.15, "Mars"]]: print(host_id, host) diff --git a/doc/data/messages/r/redefined-argument-from-local/good.py b/doc/data/messages/r/redefined-argument-from-local/good.py index 330f94f454..fd7c081ac1 100644 --- a/doc/data/messages/r/redefined-argument-from-local/good.py +++ b/doc/data/messages/r/redefined-argument-from-local/good.py @@ -1,3 +1,3 @@ def show(host_id=10.11): - for inner_host_id, host in [[12.13, 'Venus'], [14.15, 'Mars']]: + for inner_host_id, host in [[12.13, "Venus"], [14.15, "Mars"]]: print(host_id, inner_host_id, host) diff --git a/doc/data/messages/r/return-in-init/bad.py b/doc/data/messages/r/return-in-init/bad.py index 70fc2d0fde..044174e0af 100644 --- a/doc/data/messages/r/return-in-init/bad.py +++ b/doc/data/messages/r/return-in-init/bad.py @@ -1,4 +1,3 @@ class Sum: - def __init__(self, a, b): # [return-in-init] return a + b diff --git a/doc/data/messages/r/return-in-init/good.py b/doc/data/messages/r/return-in-init/good.py index ef8e6e09b7..0efe05af4d 100644 --- a/doc/data/messages/r/return-in-init/good.py +++ b/doc/data/messages/r/return-in-init/good.py @@ -1,4 +1,3 @@ class Sum: - def __init__(self, a, b) -> None: self.result = a + b diff --git a/doc/data/messages/s/self-cls-assignment/bad.py b/doc/data/messages/s/self-cls-assignment/bad.py index 64541405fe..50fe890159 100644 --- a/doc/data/messages/s/self-cls-assignment/bad.py +++ b/doc/data/messages/s/self-cls-assignment/bad.py @@ -1,7 +1,7 @@ class Fruit: @classmethod def list_fruits(cls): - cls = 'apple' # [self-cls-assignment] + cls = "apple" # [self-cls-assignment] def print_color(self, *colors): self = "red" # [self-cls-assignment] diff --git a/doc/data/messages/s/self-cls-assignment/good.py b/doc/data/messages/s/self-cls-assignment/good.py index ae8b172fa9..d1960f2516 100644 --- a/doc/data/messages/s/self-cls-assignment/good.py +++ b/doc/data/messages/s/self-cls-assignment/good.py @@ -1,7 +1,7 @@ class Fruit: @classmethod def list_fruits(cls): - fruit = 'apple' + fruit = "apple" print(fruit) def print_color(self, *colors): diff --git a/doc/data/messages/s/simplifiable-if-statement/bad.py b/doc/data/messages/s/simplifiable-if-statement/bad.py index 0c9fb317fe..1a8d6f0f78 100644 --- a/doc/data/messages/s/simplifiable-if-statement/bad.py +++ b/doc/data/messages/s/simplifiable-if-statement/bad.py @@ -2,7 +2,8 @@ def is_flying_animal(an_object): - if isinstance(an_object, Animal) and an_object in FLYING_THINGS: # [simplifiable-if-statement] + # +1: [simplifiable-if-statement] + if isinstance(an_object, Animal) and an_object in FLYING_THINGS: is_flying = True else: is_flying = False diff --git a/doc/data/messages/s/subprocess-popen-preexec-fn/bad.py b/doc/data/messages/s/subprocess-popen-preexec-fn/bad.py index c0d3f7bfab..6be75e4722 100644 --- a/doc/data/messages/s/subprocess-popen-preexec-fn/bad.py +++ b/doc/data/messages/s/subprocess-popen-preexec-fn/bad.py @@ -5,4 +5,4 @@ def foo(): pass -subprocess.Popen(preexec_fn=foo) # [subprocess-popen-preexec-fn] +subprocess.Popen(preexec_fn=foo) # [subprocess-popen-preexec-fn] diff --git a/doc/data/messages/s/syntax-error/good.py b/doc/data/messages/s/syntax-error/good.py index eccab87464..10a644f1b6 100644 --- a/doc/data/messages/s/syntax-error/good.py +++ b/doc/data/messages/s/syntax-error/good.py @@ -1,5 +1 @@ -fruit_stock = { - 'apple': 42, - 'orange': 21, - 'banana': 12 -} +fruit_stock = {"apple": 42, "orange": 21, "banana": 12} diff --git a/doc/data/messages/t/too-few-public-methods/good.py b/doc/data/messages/t/too-few-public-methods/good.py index ca4b5b6fb3..b0de1ef750 100644 --- a/doc/data/messages/t/too-few-public-methods/good.py +++ b/doc/data/messages/t/too-few-public-methods/good.py @@ -12,17 +12,22 @@ def bore(self): def wiggle(self): print(f"{self.name} wiggle around wormily.") + # or + @dataclasses.dataclass class Worm: - name:str + name: str fruit_of_residence: Fruit + def bore(worm: Worm): print(f"{worm.name} is boring into {worm.fruit_of_residence}") + # or + def bore(fruit: Fruit, worm_name: str): print(f"{worm_name} is boring into {fruit}") diff --git a/doc/data/messages/t/too-many-boolean-expressions/good.py b/doc/data/messages/t/too-many-boolean-expressions/good.py index 1da0254600..8405d4f29a 100644 --- a/doc/data/messages/t/too-many-boolean-expressions/good.py +++ b/doc/data/messages/t/too-many-boolean-expressions/good.py @@ -1,3 +1,3 @@ def can_be_divided_by_two_and_are_not_zero(x, y, z): - if all(i and i%2==0 for i in [x, y, z]): + if all(i and i % 2 == 0 for i in [x, y, z]): pass diff --git a/doc/data/messages/t/too-many-locals/bad.py b/doc/data/messages/t/too-many-locals/bad.py index dae054ed8d..d2a762b498 100644 --- a/doc/data/messages/t/too-many-locals/bad.py +++ b/doc/data/messages/t/too-many-locals/bad.py @@ -20,7 +20,9 @@ def handle_sweets(infos): # [too-many-locals] # Calculate remaining money remaining_money = money - cost_of_children # Calculate time it took - time_it_took_assuming_parallel_eating = time_to_eat_sweet * number_of_sweet_per_child + time_it_took_assuming_parallel_eating = ( + time_to_eat_sweet * number_of_sweet_per_child + ) print( f"{children} ate {cost_of_children}¤ of sweets in {time_it_took_assuming_parallel_eating}, " f"you still have {remaining_money}" diff --git a/doc/data/messages/t/too-many-return-statements/bad.py b/doc/data/messages/t/too-many-return-statements/bad.py index e421d29a7e..827177f1b2 100644 --- a/doc/data/messages/t/too-many-return-statements/bad.py +++ b/doc/data/messages/t/too-many-return-statements/bad.py @@ -1,16 +1,16 @@ def to_string(x): # [too-many-return-statements] # max of 6 by default, can be configured if x == 1: - return 'This is one.' + return "This is one." if x == 2: - return 'This is two.' + return "This is two." if x == 3: - return 'This is three.' + return "This is three." if x == 4: - return 'This is four.' + return "This is four." if x == 5: - return 'This is five.' + return "This is five." if x == 6: - return 'This is six.' + return "This is six." if x == 7: - return 'This is seven.' + return "This is seven." diff --git a/doc/data/messages/t/too-many-return-statements/good.py b/doc/data/messages/t/too-many-return-statements/good.py index 0c4032f53e..80ae2ac199 100644 --- a/doc/data/messages/t/too-many-return-statements/good.py +++ b/doc/data/messages/t/too-many-return-statements/good.py @@ -1,13 +1,13 @@ NUMBERS_TO_STRINGS = { - 1: 'one', - 2: 'two', - 3: 'three', - 4: 'four', - 5: 'five', - 6: 'six', - 7: 'seven' + 1: "one", + 2: "two", + 3: "three", + 4: "four", + 5: "five", + 6: "six", + 7: "seven", } def to_string(x): - return f'This is {NUMBERS_TO_STRINGS.get(x)}.' + return f"This is {NUMBERS_TO_STRINGS.get(x)}." diff --git a/doc/data/messages/t/truncated-format-string/bad.py b/doc/data/messages/t/truncated-format-string/bad.py index 961582bff5..a44bca2f31 100644 --- a/doc/data/messages/t/truncated-format-string/bad.py +++ b/doc/data/messages/t/truncated-format-string/bad.py @@ -1,3 +1,3 @@ PARG_2 = 1 -print("strange format %2" % PARG_2) # [truncated-format-string] +print("strange format %2" % PARG_2) # [truncated-format-string] diff --git a/doc/data/messages/u/undefined-all-variable/bad.py b/doc/data/messages/u/undefined-all-variable/bad.py index dd7bef8cb8..3168018d52 100644 --- a/doc/data/messages/u/undefined-all-variable/bad.py +++ b/doc/data/messages/u/undefined-all-variable/bad.py @@ -1,4 +1,5 @@ __all__ = ["get_fruit_colour"] # [undefined-all-variable] + def get_fruit_color(): pass diff --git a/doc/data/messages/u/undefined-all-variable/good.py b/doc/data/messages/u/undefined-all-variable/good.py index 3fb85e824c..950222b56f 100644 --- a/doc/data/messages/u/undefined-all-variable/good.py +++ b/doc/data/messages/u/undefined-all-variable/good.py @@ -1,4 +1,5 @@ __all__ = ["get_fruit_color"] + def get_fruit_color(): pass diff --git a/doc/data/messages/u/unnecessary-direct-lambda-call/bad.py b/doc/data/messages/u/unnecessary-direct-lambda-call/bad.py index 1057f8be6b..280fb3b75c 100644 --- a/doc/data/messages/u/unnecessary-direct-lambda-call/bad.py +++ b/doc/data/messages/u/unnecessary-direct-lambda-call/bad.py @@ -1 +1 @@ -y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] +y = (lambda x: x**2 + 2 * x + 1)(a) # [unnecessary-direct-lambda-call] diff --git a/doc/data/messages/u/unnecessary-direct-lambda-call/good.py b/doc/data/messages/u/unnecessary-direct-lambda-call/good.py index 1fe996f695..5870a4a231 100644 --- a/doc/data/messages/u/unnecessary-direct-lambda-call/good.py +++ b/doc/data/messages/u/unnecessary-direct-lambda-call/good.py @@ -1 +1 @@ -y = a**2 + 2*a + 1 +y = a**2 + 2 * a + 1 diff --git a/doc/data/messages/u/unnecessary-dunder-call/bad.py b/doc/data/messages/u/unnecessary-dunder-call/bad.py index 66149d7725..49405d47b6 100644 --- a/doc/data/messages/u/unnecessary-dunder-call/bad.py +++ b/doc/data/messages/u/unnecessary-dunder-call/bad.py @@ -1,4 +1,4 @@ -three = 3.0.__str__() # [unnecessary-dunder-call] +three = (3.0).__str__() # [unnecessary-dunder-call] twelve = "1".__add__("2") # [unnecessary-dunder-call] diff --git a/doc/data/messages/u/unnecessary-lambda-assignment/bad.py b/doc/data/messages/u/unnecessary-lambda-assignment/bad.py index b31553e4a3..87e7ccdbaf 100644 --- a/doc/data/messages/u/unnecessary-lambda-assignment/bad.py +++ b/doc/data/messages/u/unnecessary-lambda-assignment/bad.py @@ -1 +1 @@ -foo = lambda x: x**2 + 2*x + 1 # [unnecessary-lambda-assignment] +foo = lambda x: x**2 + 2 * x + 1 # [unnecessary-lambda-assignment] diff --git a/doc/data/messages/u/unnecessary-lambda-assignment/good.py b/doc/data/messages/u/unnecessary-lambda-assignment/good.py index 19c0a07d56..5c7da57a00 100644 --- a/doc/data/messages/u/unnecessary-lambda-assignment/good.py +++ b/doc/data/messages/u/unnecessary-lambda-assignment/good.py @@ -1,2 +1,2 @@ def foo(x): - return x**2 + 2*x + 1 + return x**2 + 2 * x + 1 diff --git a/doc/data/messages/u/unnecessary-list-index-lookup/bad.py b/doc/data/messages/u/unnecessary-list-index-lookup/bad.py index d312d36a03..b671b3add7 100644 --- a/doc/data/messages/u/unnecessary-list-index-lookup/bad.py +++ b/doc/data/messages/u/unnecessary-list-index-lookup/bad.py @@ -1,4 +1,4 @@ -letters = ['a', 'b', 'c'] +letters = ["a", "b", "c"] for index, letter in enumerate(letters): print(letters[index]) # [unnecessary-list-index-lookup] diff --git a/doc/data/messages/u/unnecessary-list-index-lookup/good.py b/doc/data/messages/u/unnecessary-list-index-lookup/good.py index 5d3370c0e2..2d1a3425c9 100644 --- a/doc/data/messages/u/unnecessary-list-index-lookup/good.py +++ b/doc/data/messages/u/unnecessary-list-index-lookup/good.py @@ -1,4 +1,4 @@ -letters = ['a', 'b', 'c'] +letters = ["a", "b", "c"] for index, letter in enumerate(letters): print(letter) diff --git a/doc/data/messages/u/unnecessary-pass/bad.py b/doc/data/messages/u/unnecessary-pass/bad.py index 32eee7f943..c22786f63d 100644 --- a/doc/data/messages/u/unnecessary-pass/bad.py +++ b/doc/data/messages/u/unnecessary-pass/bad.py @@ -1,3 +1,4 @@ class Foo: """Foo docstring.""" + pass # [unnecessary-pass] diff --git a/doc/data/messages/u/unsupported-binary-operation/good.py b/doc/data/messages/u/unsupported-binary-operation/good.py index 8dc2893c39..6a6be9a72d 100644 --- a/doc/data/messages/u/unsupported-binary-operation/good.py +++ b/doc/data/messages/u/unsupported-binary-operation/good.py @@ -1,2 +1,2 @@ masked = 0b111111 & 0b001100 -result = 0xaeff | 0x0b99 +result = 0xAEFF | 0x0B99 diff --git a/doc/data/messages/u/unsupported-membership-test/good.py b/doc/data/messages/u/unsupported-membership-test/good.py index 96b96d4d56..a5af58d5db 100644 --- a/doc/data/messages/u/unsupported-membership-test/good.py +++ b/doc/data/messages/u/unsupported-membership-test/good.py @@ -1,5 +1,6 @@ class Fruit: FRUITS = ["apple", "orange"] + def __contains__(self, name): return name in self.FRUITS diff --git a/doc/data/messages/u/unused-format-string-key/bad.py b/doc/data/messages/u/unused-format-string-key/bad.py index b4c518fc30..7a326da280 100644 --- a/doc/data/messages/u/unused-format-string-key/bad.py +++ b/doc/data/messages/u/unused-format-string-key/bad.py @@ -1,2 +1,5 @@ -"The quick %(color)s fox jumps over the lazy dog." % {"color": "brown", "action": "hops"} -# -1: [unused-format-string-key] +"The quick %(color)s fox jumps over the lazy dog." % { + "color": "brown", + "action": "hops", +} +# -4: [unused-format-string-key] diff --git a/doc/data/messages/u/unused-format-string-key/good.py b/doc/data/messages/u/unused-format-string-key/good.py index 5e45475fd3..9347a3d8f2 100644 --- a/doc/data/messages/u/unused-format-string-key/good.py +++ b/doc/data/messages/u/unused-format-string-key/good.py @@ -1 +1,4 @@ -"The quick %(color)s fox %(action)s over the lazy dog." % {"color": "brown", "action": "hops"} +"The quick %(color)s fox %(action)s over the lazy dog." % { + "color": "brown", + "action": "hops", +} diff --git a/doc/data/messages/u/unused-wildcard-import/bad.py b/doc/data/messages/u/unused-wildcard-import/bad.py index 8d48581612..74e052c842 100644 --- a/doc/data/messages/u/unused-wildcard-import/bad.py +++ b/doc/data/messages/u/unused-wildcard-import/bad.py @@ -1,4 +1,5 @@ from abc import * # [unused-wildcard-import] -class Animal(ABC): ... +class Animal(ABC): + ... diff --git a/doc/data/messages/u/unused-wildcard-import/good.py b/doc/data/messages/u/unused-wildcard-import/good.py index 961af99158..46fab6d4cf 100644 --- a/doc/data/messages/u/unused-wildcard-import/good.py +++ b/doc/data/messages/u/unused-wildcard-import/good.py @@ -1,4 +1,5 @@ from abc import ABC -class Animal(ABC): ... +class Animal(ABC): + ... diff --git a/doc/data/messages/u/useless-parent-delegation/bad.py b/doc/data/messages/u/useless-parent-delegation/bad.py index 9010c9ea9b..5132e358cc 100644 --- a/doc/data/messages/u/useless-parent-delegation/bad.py +++ b/doc/data/messages/u/useless-parent-delegation/bad.py @@ -1,10 +1,8 @@ class Animal: - def eat(self, food): print(f"Eating {food}") class Human(Animal): - def eat(self, food): # [useless-parent-delegation] super(Human, self).eat(food) diff --git a/doc/data/messages/u/useless-parent-delegation/good.py b/doc/data/messages/u/useless-parent-delegation/good.py index d463b45641..890a431164 100644 --- a/doc/data/messages/u/useless-parent-delegation/good.py +++ b/doc/data/messages/u/useless-parent-delegation/good.py @@ -1,5 +1,4 @@ class Animal: - def eat(self, food): print(f"Eating {food}") diff --git a/doc/data/messages/u/using-constant-test/bad.py b/doc/data/messages/u/using-constant-test/bad.py index aee0b407c2..a995d78047 100644 --- a/doc/data/messages/u/using-constant-test/bad.py +++ b/doc/data/messages/u/using-constant-test/bad.py @@ -1,4 +1,4 @@ if 0: # [using-constant-test] - print('This code is never executed.') + print("This code is never executed.") if 1: # [using-constant-test] - print('This code is always executed.') + print("This code is always executed.") diff --git a/doc/data/messages/u/using-constant-test/good.py b/doc/data/messages/u/using-constant-test/good.py index 151e1d518d..c8441a9240 100644 --- a/doc/data/messages/u/using-constant-test/good.py +++ b/doc/data/messages/u/using-constant-test/good.py @@ -1 +1 @@ -print('This code is always executed.') +print("This code is always executed.") diff --git a/doc/data/messages/w/while-used/bad.py b/doc/data/messages/w/while-used/bad.py index 8839b1a830..44e8df8540 100644 --- a/doc/data/messages/w/while-used/bad.py +++ b/doc/data/messages/w/while-used/bad.py @@ -4,9 +4,9 @@ def fetch_data(): i = 1 while i < 6: # [while-used] - print(f'Attempt {i}...') + print(f"Attempt {i}...") try: - return requests.get('https://example.com/data') + return requests.get("https://example.com/data") except requests.exceptions.RequestException: pass i += 1 diff --git a/doc/data/messages/w/while-used/good.py b/doc/data/messages/w/while-used/good.py index 3f2be4860a..762d738404 100644 --- a/doc/data/messages/w/while-used/good.py +++ b/doc/data/messages/w/while-used/good.py @@ -3,8 +3,8 @@ def fetch_data(): for i in range(1, 6): - print(f'Attempt {i}...') + print(f"Attempt {i}...") try: - return requests.get('https://example.com/data') + return requests.get("https://example.com/data") except requests.exceptions.RequestException: pass diff --git a/doc/data/messages/w/wrong-exception-operation/bad.py b/doc/data/messages/w/wrong-exception-operation/bad.py index 20fcc2aab4..e4aff5d8b2 100644 --- a/doc/data/messages/w/wrong-exception-operation/bad.py +++ b/doc/data/messages/w/wrong-exception-operation/bad.py @@ -1,4 +1,4 @@ try: - 1/0 -except (ValueError + TypeError): # [wrong-exception-operation] + 1 / 0 +except ValueError + TypeError: # [wrong-exception-operation] pass diff --git a/doc/data/messages/w/wrong-exception-operation/good.py b/doc/data/messages/w/wrong-exception-operation/good.py index 4171dbb600..b5170dd0e4 100644 --- a/doc/data/messages/w/wrong-exception-operation/good.py +++ b/doc/data/messages/w/wrong-exception-operation/good.py @@ -1,4 +1,4 @@ try: - 1/0 + 1 / 0 except (ValueError, TypeError): pass diff --git a/doc/data/messages/w/wrong-import-position/bad.py b/doc/data/messages/w/wrong-import-position/bad.py index f5162adebd..38e442e975 100644 --- a/doc/data/messages/w/wrong-import-position/bad.py +++ b/doc/data/messages/w/wrong-import-position/bad.py @@ -1,7 +1,7 @@ import os -home = os.environ['HOME'] +home = os.environ["HOME"] import sys # [wrong-import-position] -print(f'Home directory is {home}', file=sys.stderr) +print(f"Home directory is {home}", file=sys.stderr) diff --git a/doc/data/messages/w/wrong-import-position/good.py b/doc/data/messages/w/wrong-import-position/good.py index 413e1944e2..37330eb23b 100644 --- a/doc/data/messages/w/wrong-import-position/good.py +++ b/doc/data/messages/w/wrong-import-position/good.py @@ -1,5 +1,5 @@ import os import sys -home = os.environ['HOME'] -print(f'Home directory is {home}', file=sys.stderr) +home = os.environ["HOME"] +print(f"Home directory is {home}", file=sys.stderr)