From b7d891fbacb44341d59d0bbf25868447df509fa6 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 | 6 +++++- README.rst | 12 ++++++------ flake8_builtins.py | 6 +++--- run_tests.py | 18 +++++++++--------- setup.py | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 35383dc..a15a14a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,7 @@ Changelog ========= -0.5 (unreleased) +1.0 (unreleased) ---------------- - Use requirements.txt to pin dependencies. @@ -12,6 +12,10 @@ Changelog - Fix tests with newer flake8 version. [gforcada] +- 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 c2c5e32..e9df365 100644 --- a/run_tests.py +++ b/run_tests.py @@ -16,7 +16,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( @@ -25,7 +25,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( @@ -35,7 +35,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( @@ -59,25 +59,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') @@ -101,13 +101,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 9a12cf1..8820545 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,6 @@ ], }, entry_points={ - 'flake8.extension': ['B00 = flake8_builtins:BuiltinsChecker'], + 'flake8.extension': ['A00 = flake8_builtins:BuiltinsChecker'], }, )