Skip to content

Commit

Permalink
Change error codes from B00X to A00X
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
gforcada committed Aug 18, 2017
1 parent 1393ed7 commit 0da8d0b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
7 changes: 4 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
----------------
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down
6 changes: 3 additions & 3 deletions flake8_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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')
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
],
},
entry_points={
'flake8.extension': ['B00 = flake8_builtins:BuiltinsChecker'],
'flake8.extension': ['A00 = flake8_builtins:BuiltinsChecker'],
},
)

0 comments on commit 0da8d0b

Please sign in to comment.