Skip to content

Commit

Permalink
Update for latest flake8 release
Browse files Browse the repository at this point in the history
Update to use new API methods from flake8 3.x. Note that this does
change the minimum version of flake8 to 3.0.

Fixes #7
  • Loading branch information
tholo committed Jul 26, 2016
1 parent 8665f81 commit 7f8a94b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.6
---

- Update for flake8 3.x

0.5
---

Expand Down
33 changes: 20 additions & 13 deletions pytest_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import os
import re

from flake8.engine import get_style_guide
from flake8.main import application

import py

import pytest

__version__ = '0.5'
__version__ = '0.6'

HISTKEY = "flake8/mtimes"

Expand Down Expand Up @@ -132,15 +132,22 @@ def __call__(self, path):

def check_file(path, flake8ignore, maxlength):
"""Run flake8 over a single file, and return the number of failures."""
args = []
if maxlength:
flake8_style = get_style_guide(
parse_argv=False, paths=['--max-line-length', maxlength])
else:
flake8_style = get_style_guide(parse_argv=False)
options = flake8_style.options

if options.install_hook:
from flake8.hooks import install_hook
install_hook()

return flake8_style.input_file(str(path), expected=flake8ignore)
args = ['--max-line-length', maxlength]
app = application.Application()
app.find_plugins()
app.register_plugin_options()
app.parse_configuration_and_cli(args)
app.options.ignore = flake8ignore
app.make_formatter() # fix this
app.make_notifier()
app.make_guide()
app.make_file_checker_manager()
app.run_checks([str(path)])
app.formatter.start()
app.report_errors()
# app.report_statistics()
# app.report_benchmarks()
app.formatter.stop()
return app.result_count
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='pytest-flake8',
version='0.5',
version='0.6',
description='pytest plugin to check FLAKE8 requirements',
long_description=open("README.rst").read(),
classifiers=[
Expand All @@ -15,7 +15,6 @@
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
Expand All @@ -35,7 +34,7 @@
'pytest11': ['flake8 = pytest_flake8'],
},
install_requires=[
'flake8>=2.5',
'flake8>=3.0',
'pytest>=2.8',
],
)

0 comments on commit 7f8a94b

Please sign in to comment.