Skip to content

Commit

Permalink
Merge pull request #30 from JBKahn/entry-point
Browse files Browse the repository at this point in the history
Entry point fix
  • Loading branch information
JBKahn authored Feb 11, 2018
2 parents 06d0ba1 + 35e06ca commit e5d3812
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
python:
- "2.7"
- "2.6"
- "3.4"
- "3.5"
- "3.6"
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ available in ``flake8``::
Changes
-------

3.1.0 - 2018-02-11
``````````````````
* Add a framework classifier for use in pypi.org
* Fix entry_point in setup.py leaving it off by default again.

3.0.1 - 2017-11-06
``````````````````
* Fix conflict in setup.py leaving it off by default again.
Expand Down
6 changes: 3 additions & 3 deletions flake8_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ast
from six import PY2, PY3

__version__ = '3.0.1'
__version__ = '3.1.0'

PRINT_FUNCTION_NAME = "print"
PPRINT_FUNCTION_NAME = "pprint"
Expand All @@ -15,8 +15,8 @@
'pprint': 'T003 pprint found.',
},
'declared': {
'print': 'T101 Python 2.x reserved word print used.',
'pprint': 'T103 pprint declared',
'print': 'T002 Python 2.x reserved word print used.',
'pprint': 'T004 pprint declared',
},
}

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flake8==3.4.1
six==1.10.0
flake8==3.5.0
six==1.11.0
pycodestyle==2.3.1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_long_description():
zip_safe=False,
entry_points={
'flake8.extension': [
'R = flake8_print:PrintChecker',
'T00 = flake8_print:PrintChecker',
],
},
install_requires=install_requires,
Expand All @@ -47,6 +47,7 @@ def get_long_description():
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Framework :: Flake8',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
Expand Down
28 changes: 14 additions & 14 deletions test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def check_code_for_print_statements(code):

T001 = 'T001 print found.'
T003 = 'T003 pprint found.'
T101 = 'T101 Python 2.x reserved word print used.'
T103 = 'T103 pprint declared.'
T002 = 'T002 Python 2.x reserved word print used.'
T004 = 'T004 pprint declared.'


class TestNoQA(object):
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_catches_simple_print_python2(self):
@pytest.mark.skipif(PY3, reason="requires python2")
def test_catches_empty_print_python2(self):
result = check_code_for_print_statements('from __future__ import print_function\nprint')
assert result == [{'col': 0, 'line': 2, 'message': T101}]
assert result == [{'col': 0, 'line': 2, 'message': T002}]

def test_catches_simple_print_python3(self):
result = check_code_for_print_statements('print(4)')
Expand Down Expand Up @@ -202,47 +202,47 @@ def test_print_in_name(self):
@pytest.mark.skipif(PY2, reason="requires python3")
def test_redefine_print_function(self):
result = check_code_for_print_statements('def print(): pass')
assert result == [{'col': 0, 'line': 1, 'message': T101}]
assert result == [{'col': 0, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_arg(self):
result = check_code_for_print_statements('def foo(print): pass')
assert result == [{'col': 0, 'line': 1, 'message': T101}]
assert result == [{'col': 0, 'line': 1, 'message': T002}]

result = check_code_for_print_statements('def foo(*, print=3): pass')
assert result == [{'col': 0, 'line': 1, 'message': T101}]
assert result == [{'col': 0, 'line': 1, 'message': T002}]

result = check_code_for_print_statements('def foo(print=3): pass')
assert result == [{'col': 0, 'line': 1, 'message': T101}]
assert result == [{'col': 0, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_assignment(self):
result = check_code_for_print_statements('print=1')
assert result == [{'col': 0, 'line': 1, 'message': T101}]
assert result == [{'col': 0, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_assignment_value(self):
result = check_code_for_print_statements('x = print')
assert result == [{'col': 4, 'line': 1, 'message': T101}]
assert result == [{'col': 4, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_assignment_value_else(self):
result = check_code_for_print_statements('x = print if True else 1')
assert result == [{'col': 4, 'line': 1, 'message': T101}]
assert result == [{'col': 4, 'line': 1, 'message': T002}]
result = check_code_for_print_statements('x = 1 if True else print')
assert result == [{'col': 19, 'line': 1, 'message': T101}]
assert result == [{'col': 19, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_assignment_value_or(self):
result = check_code_for_print_statements('x = print or 1')
assert result == [{'col': 4, 'line': 1, 'message': T101}]
assert result == [{'col': 4, 'line': 1, 'message': T002}]
result = check_code_for_print_statements('x = 1 or print')
assert result == [{'col': 9, 'line': 1, 'message': T101}]
assert result == [{'col': 9, 'line': 1, 'message': T002}]

@pytest.mark.skipif(PY2, reason="requires python3")
def test_print_in_lambda(self):
result = check_code_for_print_statements('x = lambda a: print')
assert result == [{'col': 14, 'line': 1, 'message': T101}]
assert result == [{'col': 14, 'line': 1, 'message': T002}]


class TestPprintCases(object):
Expand Down

0 comments on commit e5d3812

Please sign in to comment.