Merge lp:~dobey/ubuntuone-dev-tools/no-more-pylint into lp:ubuntuone-dev-tools

Proposed by dobey
Status: Merged
Approved by: Brian Curtin
Approved revision: 103
Merged at revision: 103
Proposed branch: lp:~dobey/ubuntuone-dev-tools/no-more-pylint
Merge into: lp:ubuntuone-dev-tools
Diff against target: 541 lines (+9/-384)
4 files modified
bin/u1lint (+5/-67)
pylintrc (+0/-307)
run-tests (+1/-3)
setup.py (+3/-7)
To merge this branch: bzr merge lp:~dobey/ubuntuone-dev-tools/no-more-pylint
Reviewer Review Type Date Requested Status
Brian Curtin (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+164240@code.launchpad.net

Commit message

Drop all usage of pylint in u1lint and only use pyflakes instead.

Description of the change

We don't use pylint in the projects any more, so lets get rid of it here too, and make pyflakes the default.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
Brian Curtin (brian.curtin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/u1lint'
--- bin/u1lint 2012-11-28 21:45:47 +0000
+++ bin/u1lint 2013-05-16 17:44:27 +0000
@@ -1,6 +1,6 @@
1#!/usr/bin/python1#!/usr/bin/python
2#2#
3# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2013 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -26,22 +26,14 @@
26# do not wish to do so, delete this exception statement from your26# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source27# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.28# files in the program, then also delete it here.
29"""Wrapper script for pylint command."""29"""Wrapper script for pyflakes command."""
3030
31from __future__ import print_function31from __future__ import print_function
3232
33# pylint: disable=F0401
34try:
35 import configparser
36except ImportError:
37 import ConfigParser as configparser
38# pylint: disable=F0401
39
40import os33import os
41import subprocess34import subprocess
42import sys35import sys
4336
44from dirspec.basedir import xdg_data_dirs
4537
46SRCDIR = os.environ.get('SRCDIR', os.getcwd())38SRCDIR = os.environ.get('SRCDIR', os.getcwd())
4739
@@ -68,38 +60,28 @@
68 if os.path.exists(os.path.join(path, "python.exe")):60 if os.path.exists(os.path.join(path, "python.exe")):
69 return path61 return path
7062
71 # pylint: disable=F0401
72 try:63 try:
73 import winreg64 import winreg
74 except ImportError:65 except ImportError:
75 import _winreg as winreg66 import _winreg as winreg
76 # pylint: enable=F0401
77 software_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software')67 software_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software')
78 python_key = None68 python_key = None
79 try:69 try:
80 python_key = winreg.OpenKey(software_key, 'Python')70 python_key = winreg.OpenKey(software_key, 'Python')
81 # pylint: disable=E0602
82 except WindowsError:71 except WindowsError:
83 # pylint: enable=E0602
84 try:72 try:
85 # look in the WoW6432node, we are running python73 # look in the WoW6432node, we are running python
86 # 32 on a 64 machine74 # 32 on a 64 machine
87 wow6432node_key = winreg.OpenKey(software_key, 'WoW6432Node')75 wow6432node_key = winreg.OpenKey(software_key, 'WoW6432Node')
88 python_key = winreg.OpenKey(wow6432node_key, 'Python')76 python_key = winreg.OpenKey(wow6432node_key, 'Python')
89 # pylint: disable=E0602
90 except WindowsError:77 except WindowsError:
91 # pylint: enable=E0602
92 raise InvalidSetupException(78 raise InvalidSetupException(
93 'Could not located python installation path.')79 'Could not located python installation path.')
94 try:80 try:
95 core_key = winreg.OpenKey(python_key, 'PythonCore')81 core_key = winreg.OpenKey(python_key, 'PythonCore')
96 # pylint: disable=E1101
97 version_key = winreg.OpenKey(core_key, sys.winver)82 version_key = winreg.OpenKey(core_key, sys.winver)
98 # pylint: enable=E1101
99 return winreg.QueryValue(version_key, 'InstallPath')83 return winreg.QueryValue(version_key, 'InstallPath')
100 # pylint: disable=E0602
101 except WindowsError:84 except WindowsError:
102 # pylint: enable=E0602
103 raise InvalidSetupException(85 raise InvalidSetupException(
104 'Could not located python installation path.')86 'Could not located python installation path.')
10587
@@ -135,39 +117,6 @@
135 return [script, ]117 return [script, ]
136118
137119
138def find_pylintrc():
139 """Return the first pylintrc found."""
140 # Use the pylintrc in the source tree if there is one
141 full_name = os.path.join(SRCDIR, 'pylintrc')
142 if os.path.exists(full_name):
143 return full_name
144
145 # If no pylintrc in the source tree, use the first in $XDG_DATA_DIRS
146 # Hopefully this is the one we installed, and hasn't been overridden
147 for name in xdg_data_dirs:
148 full_name = os.path.join(name, 'ubuntuone-dev-tools', 'pylintrc')
149 if os.path.exists(full_name):
150 return full_name
151 return None
152
153
154PYLINTRC = find_pylintrc()
155
156
157def _read_pylintrc_ignored():
158 """Get the ignored files list from pylintrc"""
159 try:
160 config = configparser.ConfigParser()
161 config.read([PYLINTRC])
162
163 # pylint: disable=E1103
164 return [os.path.join(SRCDIR, item) for item in
165 config.get("MASTER", "ignore").split(",")]
166 except (TypeError, configparser.NoOptionError):
167 return []
168 # pylint: enable=E1103
169
170
171def _group_lines_by_file(data):120def _group_lines_by_file(data):
172 """Format file:line:message output as lines grouped by file."""121 """Format file:line:message output as lines grouped by file."""
173 did_fail = False122 did_fail = False
@@ -180,7 +129,6 @@
180 elif line.startswith("build/") or len(current) < 3:129 elif line.startswith("build/") or len(current) < 3:
181 pass130 pass
182 elif filename == current[0]:131 elif filename == current[0]:
183 # pylint warning W0511 is a custom note
184 if not "[W0511]" in current[2]:132 if not "[W0511]" in current[2]:
185 did_fail = True133 did_fail = True
186 outputs.append(" " + current[1] + ": " + current[2])134 outputs.append(" " + current[1] + ": " + current[2])
@@ -188,7 +136,6 @@
188 filename = current[0]136 filename = current[0]
189 outputs.append("")137 outputs.append("")
190 outputs.append(filename + ":")138 outputs.append(filename + ":")
191 # pylint warning W0511 is a custom note
192 if not "[W0511]" in current[2]:139 if not "[W0511]" in current[2]:
193 did_fail = True140 did_fail = True
194 outputs.append(" " + current[1] + ": " + current[2])141 outputs.append(" " + current[1] + ": " + current[2])
@@ -199,7 +146,6 @@
199def _find_files():146def _find_files():
200 """Find all Python files under the current tree."""147 """Find all Python files under the current tree."""
201 pyfiles = []148 pyfiles = []
202 # pylint: disable=W0612
203 for root, dirs, files in os.walk(SRCDIR, topdown=False):149 for root, dirs, files in os.walk(SRCDIR, topdown=False):
204 for filename in files:150 for filename in files:
205 filepath = root + os.path.sep151 filepath = root + os.path.sep
@@ -233,20 +179,12 @@
233 (options, args) = parser.parse_args()179 (options, args) = parser.parse_args()
234180
235 failed = False181 failed = False
236 ignored = _read_pylintrc_ignored()182 ignored = []
237 if options.ignored:183 if options.ignored:
238 ignored.extend([os.path.join(SRCDIR, item) for item in184 ignored.extend([os.path.join(SRCDIR, item) for item in
239 map(str.strip, options.ignored.split(','))])185 map(str.strip, options.ignored.split(','))])
240186
241 if os.environ.get('USE_PYFLAKES'):187 pylint_args = get_subprocess_start_info('pyflakes')
242 pylint_args = get_subprocess_start_info('pyflakes')
243 else:
244 pylint_args = get_subprocess_start_info('pylint')
245 # append the extra args to the start info
246 pylint_args.extend(['--output-format=parseable',
247 '--include-ids=yes'])
248 if PYLINTRC:
249 pylint_args.append("--rcfile=" + PYLINTRC)
250188
251 for path in _find_files():189 for path in _find_files():
252 is_build = path.startswith(os.path.join(SRCDIR, "_build"))190 is_build = path.startswith(os.path.join(SRCDIR, "_build"))
@@ -272,7 +210,7 @@
272 print(grouped, end="\n\n")210 print(grouped, end="\n\n")
273211
274 returncode = sp.wait()212 returncode = sp.wait()
275 # XXX Testing that W0511 does not cause a failure213
276 if failed:214 if failed:
277 if returncode != 0:215 if returncode != 0:
278 exit(returncode)216 exit(returncode)
279217
=== removed file 'pylintrc'
--- pylintrc 2011-04-13 14:44:11 +0000
+++ pylintrc 1970-01-01 00:00:00 +0000
@@ -1,307 +0,0 @@
1# lint Python modules using external checkers.
2#
3# This is the main checker controlling the other ones and the reports
4# generation. It is itself both a raw checker and an astng checker in order
5# to:
6# * handle message activation / deactivation at the module level
7# * handle some basic but necessary stats'data (number of classes, methods...)
8#
9[MASTER]
10
11# Specify a configuration file.
12#rcfile=
13
14# Python code to execute, usually for sys.path manipulation such as
15# pygtk.require().
16#init-hook=
17
18# Profiled execution.
19profile=no
20
21# Add <file or directory> to the black list. It should be a base name, not a
22# path. You may set this option multiple times.
23#ignore=<somedir>
24
25# Pickle collected data for later comparisons.
26persistent=no
27
28# List of plugins (as comma separated values of python modules names) to load,
29# usually to register additional checkers.
30load-plugins=
31
32
33[MESSAGES CONTROL]
34
35# Enable only checker(s) with the given id(s). This option conflicts with the
36# disable-checker option
37#enable-checker=
38
39# Enable all checker(s) except those with the given id(s). This option
40# conflicts with the enable-checker option
41#disable-checker=
42
43# Enable all messages in the listed categories.
44#enable-cat=
45
46# Disable all messages in the listed categories.
47#disable-cat=
48
49# Disable the message(s) with the given id(s) or categories
50# W0142: Used * or ** magic
51# W0221: Arguments number differs from %s method (pylint is confused by * and **)
52# W0613: Unused argument %r (We get lots of these from interfaces)
53# W0404: Erroneous re-import warning: MM: X Reimported (line MM)
54disable=R,I,W0142,W0221,W0613,W0404
55
56
57[REPORTS]
58
59# Set the output format. Available formats are text, parseable, colorized, msvs
60# (visual studio) and html
61output-format=colorized
62
63# Include message's id in output
64include-ids=yes
65
66# Put messages in a separate file for each module / package specified on the
67# command line instead of printing them on stdout. Reports (if any) will be
68# written in a file name "pylint_global.[txt|html]".
69files-output=no
70
71# Tells whether to display a full report or only the messages
72reports=no
73
74# Python expression which should return a note less than 10 (10 is the highest
75# note). You have access to the variables errors warning, statement which
76# respectively contain the number of errors / warnings messages and the total
77# number of statements analyzed. This is used by the global evaluation report
78# (R0004).
79evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
80
81# Add a comment according to your evaluation note. This is used by the global
82# evaluation report (R0004).
83comment=no
84
85# Enable the report(s) with the given id(s).
86#enable-report=
87
88# Disable the report(s) with the given id(s).
89#disable-report=
90
91
92# try to find bugs in the code using type inference
93#
94[TYPECHECK]
95
96# Tells whether missing members accessed in mixin class should be ignored. A
97# mixin class is detected if its name ends with "mixin" (case insensitive).
98ignore-mixin-members=yes
99
100# List of classes names for which member attributes should not be checked
101# (useful for classes with attributes dynamically set).
102ignored-classes=
103
104# When zope mode is activated, add a predefined set of Zope acquired attributes
105# to generated-members.
106zope=no
107
108# List of members which are set dynamically and missed by pylint inference
109# system, and so shouldn't trigger E0201 when accessed.
110generated-members=REQUEST,acl_users,aq_parent
111
112
113# checks for
114# * unused variables / imports
115# * undefined variables
116# * redefinition of variable from builtins or from an outer scope
117# * use of variable before assignment
118#
119[VARIABLES]
120
121# Tells whether we should check for unused import in __init__ files.
122init-import=yes
123
124# A regular expression matching names used for dummy variables (i.e. not used).
125dummy-variables-rgx=_|dummy
126
127# List of additional names supposed to be defined in builtins. Remember that
128# you should avoid to define new builtins when possible.
129additional-builtins=
130
131
132# checks for :
133# * doc strings
134# * modules / classes / functions / methods / arguments / variables name
135# * number of arguments, local variables, branches, returns and statements in
136# functions, methods
137# * required module attributes
138# * dangerous default values as arguments
139# * redefinition of function / method / class
140# * uses of the global statement
141#
142[BASIC]
143
144# Required attributes for module, separated by a comma
145required-attributes=
146
147# Regular expression which should only match functions or classes name which do
148# not require a docstring
149no-docstring-rgx=(__.*__|setUp|tearDown)
150
151# Regular expression which should only match correct module names
152module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
153
154# Regular expression which should only match correct module level names
155const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
156
157# Regular expression which should only match correct class names
158class-rgx=[A-Z_][a-zA-Z0-9]+$
159
160# Regular expression which should only match correct function names
161function-rgx=[a-z_][a-z0-9_]{2,79}$
162
163# Regular expression which should only match correct method names
164method-rgx=([a-z_][a-z0-9_]{2,79}$|setUp|tearDown)
165
166# Regular expression which should only match correct instance attribute names
167attr-rgx=[a-z_][a-z0-9_]{1,30}$
168
169# Regular expression which should only match correct argument names
170argument-rgx=[a-z_][a-z0-9_]{1,30}$
171
172# Regular expression which should only match correct variable names
173variable-rgx=[a-z_][a-z0-9_]{1,30}$
174
175# Regular expression which should only match correct list comprehension /
176# generator expression variable names
177inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
178
179# Good variable names which should always be accepted, separated by a comma
180good-names=d,e,f,g,i,j,k,ex,logger,Run,_
181
182# Bad variable names which should always be refused, separated by a comma
183bad-names=foo,bar,baz,toto,tutu,tata
184
185# List of builtins function names that should not be used, separated by a comma
186bad-functions=apply,input,reduce
187
188
189# checks for sign of poor/misdesign:
190# * number of methods, attributes, local variables...
191# * size, complexity of functions, methods
192#
193[DESIGN]
194
195# Maximum number of arguments for function / method
196max-args=5
197
198# Maximum number of locals for function / method body
199max-locals=15
200
201# Maximum number of return / yield for function / method body
202max-returns=6
203
204# Maximum number of branch for function / method body
205max-branchs=12
206
207# Maximum number of statements in function / method body
208max-statements=50
209
210# Maximum number of parents for a class (see R0901).
211max-parents=7
212
213# Maximum number of attributes for a class (see R0902).
214max-attributes=7
215
216# Minimum number of public methods for a class (see R0903).
217min-public-methods=2
218
219# Maximum number of public methods for a class (see R0904).
220max-public-methods=20
221
222
223# checks for :
224# * methods without self as first argument
225# * overridden methods signature
226# * access only to existent members via self
227# * attributes not defined in the __init__ method
228# * supported interfaces implementation
229# * unreachable code
230#
231[CLASSES]
232
233# List of interface methods to ignore, separated by a comma. This is used for
234# instance to not check methods defines in Zopes Interface base class.
235#ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by,providedBy
236
237# List of method names used to declare (i.e. assign) instance attributes.
238defining-attr-methods=__init__,__new__,setUp
239
240
241# checks for
242# * external modules dependencies
243# * relative / wildcard imports
244# * cyclic imports
245# * uses of deprecated modules
246#
247[IMPORTS]
248
249# Deprecated modules which should not be used, separated by a comma
250deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
251
252# Create a graph of every (i.e. internal and external) dependencies in the
253# given file (report RP0402 must not be disabled)
254import-graph=
255
256# Create a graph of external dependencies in the given file (report RP0402 must
257# not be disabled)
258ext-import-graph=
259
260# Create a graph of internal dependencies in the given file (report RP0402 must
261# not be disabled)
262int-import-graph=
263
264
265# checks for :
266# * unauthorized constructions
267# * strict indentation
268# * line length
269# * use of <> instead of !=
270#
271[FORMAT]
272
273# Maximum number of characters on a single line.
274max-line-length=79
275
276# Maximum number of lines in a module
277max-module-lines=2000
278
279# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
280# tab).
281indent-string=' '
282
283
284# checks for similarities and duplicated code. This computation may be
285# memory / CPU intensive, so you should disable it if you experiments some
286# problems.
287#
288[SIMILARITIES]
289
290# Minimum lines number of a similarity.
291min-similarity-lines=4
292
293# Ignore comments when computing similarities.
294ignore-comments=yes
295
296# Ignore docstrings when computing similarities.
297ignore-docstrings=yes
298
299
300# checks for:
301# * warning notes in the code like FIXME, XXX
302# * PEP 263: source code with non ascii character but no encoding declaration
303#
304[MISCELLANEOUS]
305
306# List of note tags to take in consideration, separated by a comma.
307notes=FIXME,XXX,TODO,fixme,xxx,todo
3080
=== modified file 'run-tests'
--- run-tests 2012-10-18 21:17:22 +0000
+++ run-tests 2013-05-16 17:44:27 +0000
@@ -1,6 +1,6 @@
1#!/bin/bash1#!/bin/bash
2#2#
3# Copyright 2010-2012 Canonical Ltd.3# Copyright 2010-2013 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -26,8 +26,6 @@
26$PYTHON bin/u1trial --reactor=twisted -i "test_squid_windows.py" ubuntuone26$PYTHON bin/u1trial --reactor=twisted -i "test_squid_windows.py" ubuntuone
27echo "Running style checks..."27echo "Running style checks..."
28$PYTHON bin/u1lint28$PYTHON bin/u1lint
29# Run with pyflakes as well as pylint
30USE_PYFLAKES="1" $PYTHON bin/u1lint
3129
32pep8 --repeat . bin/* --exclude=*.bat,.pc30pep8 --repeat . bin/* --exclude=*.bat,.pc
33rm -rf _trial_temp31rm -rf _trial_temp
3432
=== modified file 'setup.py'
--- setup.py 2012-11-28 21:45:47 +0000
+++ setup.py 2013-05-16 17:44:27 +0000
@@ -1,6 +1,6 @@
1#!/usr/bin/python1#!/usr/bin/python
2#2#
3# Copyright 2010-2012 Canonical Ltd.3# Copyright 2010-2013 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -59,23 +59,19 @@
59 if retcode != 0:59 if retcode != 0:
60 sys.exit(retcode)60 sys.exit(retcode)
6161
62# pylint: disable=C0103
63scripts = ['bin/u1lint',62scripts = ['bin/u1lint',
64 'bin/u1trial']63 'bin/u1trial']
65# pylint: enable=C0103
6664
67if sys.platform == 'win32':65if sys.platform == 'win32':
68 # lets add the .bat so that windows users are happy66 # lets add the .bat so that windows users are happy
69 scripts.extend(['bin/u1lint.bat', 'bin/u1trial.bat'])67 scripts.extend(['bin/u1lint.bat', 'bin/u1trial.bat'])
70 DATA_FILES = [(os.path.join(basedir.default_data_path, PACKAGE),68 DATA_FILES = [(os.path.join(basedir.default_data_path, PACKAGE),
71 ['pylintrc',69 ['data/dbus-session.conf.in',
72 'data/dbus-session.conf.in',
73 'data/squid.conf.in']),70 'data/squid.conf.in']),
74 ]71 ]
75else:72else:
76 DATA_FILES = [('share/%s' % PACKAGE,73 DATA_FILES = [('share/%s' % PACKAGE,
77 ['pylintrc',74 ['data/dbus-session.conf.in',
78 'data/dbus-session.conf.in',
79 'data/squid.conf.in']),75 'data/squid.conf.in']),
80 ('share/man/man1',76 ('share/man/man1',
81 ['man/u1lint.1',77 ['man/u1lint.1',

Subscribers

People subscribed via source and target branches

to all changes: