From 0da8d0b37c31f7aee38cb8912385807d14b80a1b Mon Sep 17 00:00:00 2001 From: Gil Forcada Date: Fri, 18 Aug 2017 13:08:46 +0200 Subject: [PATCH] Change error codes from B00X to A00X Fixes https://github.com/gforcada/flake8-builtins/issues/7 --- CHANGES.rst | 7 ++++--- README.rst | 12 ++++++------ flake8_builtins.py | 6 +++--- run_tests.py | 18 +++++++++--------- setup.py | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 06ba0a7..570f532 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,11 +3,12 @@ Changelog ========= -0.5 (unreleased) +1.0 (unreleased) ---------------- -- Nothing changed yet. - +- BREAKING CHANGE: error codes have been changed from B00X to A00X to not clash with flake8-bugbear, + see https://github.com/gforcada/flake8-builtins/issues/7 + [gforcada] 0.4 (2017-05-29) ---------------- diff --git a/README.rst b/README.rst index 8657a7c..64b05ed 100644 --- a/README.rst +++ b/README.rst @@ -56,12 +56,12 @@ Given the following code:: The following warnings are shown (via flake8):: - test.py:1:15: B002 "object" is used as an argument and thus shadows a python builtin, consider renaming the argument - test.py:1:23: B002 "list" is used as an argument and thus shadows a python builtin, consider renaming the argument - test.py:1:29: B002 "dict" is used as an argument and thus shadows a python builtin, consider renaming the argument - test.py:2:5: B001 "max" is a python builtin and is being shadowed, consider renaming the variable - test.py:3:5: B001 "min" is a python builtin and is being shadowed, consider renaming the variable - test.py:4:5: B001 "zip" is a python builtin and is being shadowed, consider renaming the variable + test.py:1:15: A002 "object" is used as an argument and thus shadows a python builtin, consider renaming the argument + test.py:1:23: A002 "list" is used as an argument and thus shadows a python builtin, consider renaming the argument + test.py:1:29: A002 "dict" is used as an argument and thus shadows a python builtin, consider renaming the argument + test.py:2:5: A001 "max" is a python builtin and is being shadowed, consider renaming the variable + test.py:3:5: A001 "min" is a python builtin and is being shadowed, consider renaming the variable + test.py:4:5: A001 "zip" is a python builtin and is being shadowed, consider renaming the variable Install ------- diff --git a/flake8_builtins.py b/flake8_builtins.py index 488b622..aeb4423 100644 --- a/flake8_builtins.py +++ b/flake8_builtins.py @@ -35,11 +35,11 @@ class BuiltinsChecker(object): name = 'flake8_builtins' version = '0.3' - assign_msg = 'B001 "{0}" is a python builtin and is being shadowed, ' \ + assign_msg = 'A001 "{0}" is a python builtin and is being shadowed, ' \ 'consider renaming the variable' - argument_msg = 'B002 "{0}" is used as an argument and thus shadows a ' \ + argument_msg = 'A002 "{0}" is used as an argument and thus shadows a ' \ 'python builtin, consider renaming the argument' - class_attribute_msg = 'B003 "{0}" is a python builtin, consider ' \ + class_attribute_msg = 'A003 "{0}" is a python builtin, consider ' \ 'renaming the class attribute' def __init__(self, tree, filename): diff --git a/run_tests.py b/run_tests.py index 25e96e1..2a74a64 100644 --- a/run_tests.py +++ b/run_tests.py @@ -17,7 +17,7 @@ def test_builtin_top_level(self): tree = ast.parse('max = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B001']) + self.assert_codes(ret, ['A001']) def test_nested(self): tree = ast.parse( @@ -26,7 +26,7 @@ def test_nested(self): ) checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B001']) + self.assert_codes(ret, ['A001']) def test_more_nested(self): tree = ast.parse( @@ -36,7 +36,7 @@ def test_more_nested(self): ) checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B001']) + self.assert_codes(ret, ['A001']) def test_line_number(self): tree = ast.parse( @@ -60,25 +60,25 @@ def test_assign_message(self): tree = ast.parse('def bla():\n object = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B001']) + self.assert_codes(ret, ['A001']) def test_class_attribute_message(self): tree = ast.parse('class TestClass():\n object = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B003']) + self.assert_codes(ret, ['A003']) def test_argument_message(self): tree = ast.parse('def bla(list):\n a = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B002']) + self.assert_codes(ret, ['A002']) def test_keyword_argument_message(self): tree = ast.parse('def bla(dict=3):\n b = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B002']) + self.assert_codes(ret, ['A002']) def test_no_error(self): tree = ast.parse('def bla(first):\n b = 4') @@ -102,13 +102,13 @@ def test_report_all_arguments(self): tree = ast.parse('def bla(zip, object=4):\n b = 4') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B002', 'B002']) + self.assert_codes(ret, ['A002', 'A002']) def test_report_all_variables_within_a_line(self): tree = ast.parse('def bla():\n object = 4; zip = 3') checker = BuiltinsChecker(tree, '/home/script.py') ret = [c for c in checker.run()] - self.assert_codes(ret, ['B001', 'B001']) + self.assert_codes(ret, ['A001', 'A001']) def test_ignore_whitelisted_names(self): tree = ast.parse( diff --git a/setup.py b/setup.py index 816f723..9cba193 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,6 @@ ], }, entry_points={ - 'flake8.extension': ['B00 = flake8_builtins:BuiltinsChecker'], + 'flake8.extension': ['A00 = flake8_builtins:BuiltinsChecker'], }, )