Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change error codes from B00X to A00X #8

Merged
merged 1 commit into from
Aug 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Changelog
=========

0.5 (unreleased)
1.0 (unreleased)
----------------

- Use requirements.txt to pin dependencies.
Expand All @@ -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)
----------------

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 @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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')
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
],
},
entry_points={
'flake8.extension': ['B00 = flake8_builtins:BuiltinsChecker'],
'flake8.extension': ['A00 = flake8_builtins:BuiltinsChecker'],
},
)