Skip to content

Commit

Permalink
move back to setup.py (#39)
Browse files Browse the repository at this point in the history
* move back to setup.py:

* fix setup.cfg

* skip bad test

* Update README.md

* Update README.md
  • Loading branch information
JBKahn committed Nov 1, 2019
1 parent d00109a commit 0819d2a
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -11,8 +11,8 @@ env:
- FLAKE8_VERSION="3.2.1"

install:
- pip install poetry
- poetry install
- if [[ -n "$FLAKE8_VERSION" ]]; then poetry run pip install flake8=="$FLAKE8_VERSION"; fi
- pip install pycodestyle
- if [[ -n "$FLAKE8_VERSION" ]]; then pip install flake8=="$FLAKE8_VERSION"; fi
- python setup.py install
script:
- poetry run pytest
- pytest
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -38,6 +38,11 @@ Error codes
Changes
-------

##### 3.1.2 - 2019-31-10

* Swapped back from poetry to setup.py :(....python ecosystem issues....
* single function refactor code

##### 3.1.1 - 2019-03-12

* Fix reading from stdin when it is closed (requires flake8 > 2.1).
Expand Down
25 changes: 17 additions & 8 deletions flake8_print.py
Expand Up @@ -8,7 +8,7 @@
except ImportError:
from flake8 import utils as stdin_utils

__version__ = "3.1.1"
__version__ = "3.1.2"

PRINT_FUNCTION_NAME = "print"
PPRINT_FUNCTION_NAME = "pprint"
Expand Down Expand Up @@ -91,11 +91,20 @@ def run(self):

parser = PrintFinder()
parser.visit(self.tree)
for error, message in parser.prints_used.items():
if not pycodestyle.noqa(self.lines[error[0] - 1]):
yield (error[0], error[1], message, PrintChecker)
error_dicts = (parser.prints_used, parser.prints_redefined)
errors_seen = set()

for index, error_dict in enumerate(error_dicts):
for error, message in error_dict.items():
if error in errors_seen:
continue

code = message.split(' ', 1)[0]
line = self.lines[error[0] - 1]
line_has_noqa = bool(pycodestyle.noqa(line))

for error, message in parser.prints_redefined.items():
if error not in parser.prints_used:
if not pycodestyle.noqa(self.lines[error[0] - 1]):
yield (error[0], error[1], message, PrintChecker)
if line_has_noqa is True and code in line:
continue

errors_seen.add(error)
yield (error[0], error[1], message, PrintChecker)
File renamed without changes.
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[aliases]
test=pytest
60 changes: 60 additions & 0 deletions setup.py
@@ -0,0 +1,60 @@
# coding: utf-8

from __future__ import with_statement
from setuptools import setup


def get_version(fname='flake8_print.py'):
with open(fname) as f:
for line in f:
if line.startswith('__version__'):
return eval(line.split('=')[-1])


def get_long_description():
descr = []
for fname in ('README.md',):
with open(fname) as f:
descr.append(f.read())
return '\n\n'.join(descr)


install_requires = ['flake8>=1.5', 'six', 'pycodestyle']

test_requires = ['pytest', 'flake8>=1.5', 'pycodestyle']

setup(
name='flake8-print',
version=get_version(),
description="print statement checker plugin for flake8",
long_description=get_long_description(),
keywords='flake8 print',
author='Joseph Kahn',
author_email='josephbkahn@gmail.com',
url='https://github.com/jbkahn/flake8-print',
license='MIT',
py_modules=['flake8_print'],
zip_safe=False,
entry_points={
'flake8.extension': [
'T00 = flake8_print:PrintChecker',
],
},
install_requires=install_requires,
tests_require=test_requires,
setup_requires=['pytest-runner'],
test_suite="nose.collector",
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Framework :: Flake8',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Quality Assurance',
],
)
11 changes: 10 additions & 1 deletion test_linter.py
Expand Up @@ -64,9 +64,18 @@ def check_code_for_print_statements(code):
class TestNoQA(object):
@pytest.mark.skipif(sys.version_info < (2, 7), reason="Python 2.6 does not support noqa")
def test_skips_noqa(self):
result = check_code_for_print_statements("print(4) # noqa")
result = check_code_for_print_statements("print(4) # noqa")
assert result == list()

def test_skips_noqa__with_specific_error_code(self):
result = check_code_for_print_statements("print(4) # noqa: T001")
assert result == list()

@pytest.mark.skip(reason="not supported by pycodestyle ast checks")
def test_skips_noqa__without_specific_error_code(self):
result = check_code_for_print_statements("print(4) # noqa: E731")
assert result == [1]

@pytest.mark.skipif(True, reason="no idea how to get this to work without local line")
def test_skips_noqa_multiline_end(self):
result = check_code_for_print_statements(
Expand Down

0 comments on commit 0819d2a

Please sign in to comment.