Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: flake8-eyeo/setup.py

Issue 30050569: Noissue - Removed linters which are now moved to a seperate repository (Closed)
Patch Set: Created April 25, 2019, 11:17 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « flake8-eyeo/flake8_eyeo.py ('k') | flake8-eyeo/tests/A101.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH
3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation.
7 #
8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15
16 from __future__ import print_function
17
18 import os
19 import glob
20 import tokenize
21 import sys
22 import re
23 import subprocess
24
25 from setuptools import setup, Command
26
27
28 class TestCommand(Command):
29 user_options = []
30
31 def _get_expected_errors(self, filename):
32 errors = set()
33
34 def tokeneater(kind, token, start, end, line):
35 if kind == tokenize.COMMENT:
36 match = re.search(r'^#+[*\s]*(A\d+)', token)
37 if match:
38 try:
39 offset = token.index('*')
40 except ValueError:
41 offset = 0
42 errors.add((start[0] + 1,
43 start[1] + 1 + offset,
44 match.group(1)))
45
46 with open(filename, 'rb') as file:
47 if sys.version_info[0] >= 3:
48 for token in tokenize.tokenize(file.readline):
49 tokeneater(*token)
50 else:
51 tokenize.tokenize(file.readline, tokeneater)
52
53 return errors
54
55 def _get_reported_errors(self, filename):
56 output = subprocess.Popen(['flake8', '--select=A', filename],
57 stdout=subprocess.PIPE).communicate()[0]
58
59 errors = set()
60 for line in output.decode('utf-8').splitlines():
61 _, lineno, colno, error = line.split(':', 3)
62 errors.add((int(lineno), int(colno), error.split()[0]))
63
64 return errors
65
66 def initialize_options(self):
67 pass
68
69 def finalize_options(self):
70 pass
71
72 def run(self):
73 directory = os.path.dirname(__file__)
74 filenames = glob.glob(os.path.join(directory, 'tests', '*.py'))
75 failed = False
76
77 for filename in sorted(filenames):
78 expected = self._get_expected_errors(filename)
79 reported = self._get_reported_errors(filename)
80 failures = expected ^ reported
81
82 if not failures:
83 print(filename + ': OK')
84 continue
85
86 for record in sorted(failures):
87 lineno, colno, error = record
88
89 print('{}:{}:{}: '.format(filename, lineno, colno), end='')
90 if record in expected:
91 print(error + ' expected')
92 else:
93 print('unexpected ' + error)
94
95 failed = True
96
97 if failed:
98 sys.exit(1)
99
100
101 setup(
102 name='flake8-eyeo',
103 version='0.1',
104 py_modules=['flake8_eyeo'],
105 install_requires=[
106 'flake8>=3.2.1',
107 'flake8-docstrings',
108 'flake8-commas',
109 'pep8-naming',
110 ],
111 entry_points={
112 'flake8.extension': [
113 '_ = flake8_eyeo:DefaultConfigOverride',
114 'A = flake8_eyeo:check_ast',
115 'A1 = flake8_eyeo:check_quotes',
116 'A111 = flake8_eyeo:check_redundant_parenthesis',
117 'A303 = flake8_eyeo:check_non_default_encoding',
118 ],
119 },
120 cmdclass={'test': TestCommand},
121 )
OLDNEW
« no previous file with comments | « flake8-eyeo/flake8_eyeo.py ('k') | flake8-eyeo/tests/A101.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld