Skip to content

Commit dfb57aa

Browse files
committed
setup: Add pylint and pep8 config files
1 parent f40370a commit dfb57aa

4 files changed

Lines changed: 282 additions & 34 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ include bugzilla.1
33
include bz-api-notes.txt
44
include python-bugzilla.spec
55
include *requirements.txt
6-
recursive-include tests *.py *.txt
6+
recursive-include tests *.py *.txt *.cfg

setup.py

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -119,39 +119,18 @@ def finalize_options(self):
119119
pass
120120

121121
def _run(self):
122-
os.system("pylint "
123-
"--reports=n "
124-
"--output-format=colorized "
125-
"--dummy-variables-rgx=\"dummy|ignore*|.*ignore\" "
126-
# Lines in modules, function size, ...
127-
"--disable Design "
128-
# Line length, spacing, ...
129-
"--disable Format "
130-
# Duplicate code
131-
"--disable Similarities "
132-
# Use of * or **
133-
"--disable W0142 "
134-
# Name doesn't match some style regex
135-
"--disable C0103 "
136-
# C0111: No docstring
137-
"--disable C0111 "
138-
# W0603: Using the global statement
139-
"--disable W0603 "
140-
# W0703: Catching too general exception:
141-
"--disable W0703 "
142-
# I0012: Warn about pylint messages disabled in comments
143-
"--disable I0011 "
144-
# R0201: Method could be a function
145-
"--disable R0201 "
146-
147-
"bugzilla/ bin-bugzilla tests/*.py ")
148-
149-
os.system("pep8 --format=pylint "
150-
"bugzilla/ bin-bugzilla tests/ "
151-
# E303: Too many blank lines
152-
# E125: Continuation indent isn't different from next block
153-
# E128: Not indented for visual style
154-
"--ignore E303,E125,E128")
122+
files = ["bugzilla/", "bin-bugzilla", "tests/*.py"]
123+
output_format = sys.stdout.isatty() and "colorized" or "text"
124+
125+
cmd = "pylint "
126+
cmd += "--output-format=%s " % output_format
127+
cmd += " ".join(files)
128+
os.system(cmd + " --rcfile tests/pylint.cfg")
129+
130+
print("running pep8")
131+
cmd = "pep8 "
132+
cmd += " ".join(files)
133+
os.system(cmd + " --config tests/pep8.cfg")
155134

156135
def run(self):
157136
os.link("bin/bugzilla", "bin-bugzilla")

tests/pep8.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[pep8]
2+
3+
format = pylint
4+
5+
# E125: Continuation indent isn't different from next block
6+
# E128: Not indented for visual style
7+
# E303: Too many blank lines
8+
9+
ignore=E125,E128,E303

tests/pylint.cfg

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
[MASTER]
2+
3+
# Specify a configuration file.
4+
#rcfile=
5+
6+
# Python code to execute, usually for sys.path manipulation such as
7+
# pygtk.require().
8+
#init-hook=
9+
10+
# Profiled execution.
11+
profile=no
12+
13+
# Add files or directories to the blacklist. They should be base names, not
14+
# paths.
15+
#ignore=
16+
17+
# Pickle collected data for later comparisons.
18+
persistent=yes
19+
20+
# List of plugins (as comma separated values of python modules names) to load,
21+
# usually to register additional checkers.
22+
load-plugins=
23+
24+
25+
[MESSAGES CONTROL]
26+
27+
# Enable the message, report, category or checker with the given id(s). You can
28+
# either give multiple identifier separated by comma (,) or put this option
29+
# multiple time.
30+
#enable=
31+
32+
# Disable the message, report, category or checker with the given id(s). You
33+
# can either give multiple identifier separated by comma (,) or put this option
34+
# multiple time (only on the command line, not in the configuration file where
35+
# it should appear only once).
36+
37+
disable=Design,Format,Similarities,invalid-name,missing-docstring,locally-disabled,unnecessary-lambda,star-args,fixme,global-statement,broad-except,no-self-use,
38+
39+
40+
[REPORTS]
41+
42+
# Set the output format. Available formats are text, parseable, colorized, msvs
43+
# (visual studio) and html. You can also give a reporter class, eg
44+
# mypackage.mymodule.MyReporterClass.
45+
#output-format=text
46+
47+
# Include message's id in output
48+
include-ids=no
49+
50+
# Include symbolic ids of messages in output
51+
symbols=no
52+
53+
# Put messages in a separate file for each module / package specified on the
54+
# command line instead of printing them on stdout. Reports (if any) will be
55+
# written in a file name "pylint_global.[txt|html]".
56+
files-output=no
57+
58+
# Tells whether to display a full report or only the messages
59+
reports=no
60+
61+
# Python expression which should return a note less than 10 (10 is the highest
62+
# note). You have access to the variables errors warning, statement which
63+
# respectively contain the number of errors / warnings messages and the total
64+
# number of statements analyzed. This is used by the global evaluation report
65+
# (RP0004).
66+
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
67+
68+
# Add a comment according to your evaluation note. This is used by the global
69+
# evaluation report (RP0004).
70+
comment=no
71+
72+
73+
[TYPECHECK]
74+
75+
# Tells whether missing members accessed in mixin class should be ignored. A
76+
# mixin class is detected if its name ends with "mixin" (case insensitive).
77+
ignore-mixin-members=yes
78+
79+
# List of classes names for which member attributes should not be checked
80+
# (useful for classes with attributes dynamically set).
81+
ignored-classes=SQLObject
82+
83+
# When zope mode is activated, add a predefined set of Zope acquired attributes
84+
# to generated-members.
85+
zope=no
86+
87+
# List of members which are set dynamically and missed by pylint inference
88+
# system, and so shouldn't trigger E0201 when accessed. Python regular
89+
# expressions are accepted.
90+
generated-members=REQUEST,acl_users,aq_parent
91+
92+
93+
[FORMAT]
94+
95+
# Maximum number of characters on a single line.
96+
max-line-length=80
97+
98+
# Maximum number of lines in a module
99+
max-module-lines=1000
100+
101+
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
102+
# tab).
103+
indent-string=' '
104+
105+
106+
[SIMILARITIES]
107+
108+
# Minimum lines number of a similarity.
109+
min-similarity-lines=4
110+
111+
# Ignore comments when computing similarities.
112+
ignore-comments=yes
113+
114+
# Ignore docstrings when computing similarities.
115+
ignore-docstrings=yes
116+
117+
# Ignore imports when computing similarities.
118+
ignore-imports=no
119+
120+
121+
[MISCELLANEOUS]
122+
123+
# List of note tags to take in consideration, separated by a comma.
124+
notes=FIXME,XXX,TODO
125+
126+
127+
[VARIABLES]
128+
129+
# Tells whether we should check for unused import in __init__ files.
130+
init-import=no
131+
132+
# A regular expression matching the beginning of the name of dummy variables
133+
# (i.e. not used).
134+
dummy-variables-rgx=ignore.*|.*_ignore
135+
136+
# List of additional names supposed to be defined in builtins. Remember that
137+
# you should avoid to define new builtins when possible.
138+
additional-builtins=_
139+
140+
141+
[BASIC]
142+
143+
# Required attributes for module, separated by a comma
144+
required-attributes=
145+
146+
# List of builtins function names that should not be used, separated by a comma
147+
bad-functions=map,filter,apply,input
148+
149+
# Regular expression which should only match correct module names
150+
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
151+
152+
# Regular expression which should only match correct module level names
153+
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
154+
155+
# Regular expression which should only match correct class names
156+
class-rgx=[A-Z_][a-zA-Z0-9]+$
157+
158+
# Regular expression which should only match correct function names
159+
function-rgx=[a-z_][a-z0-9_]{2,30}$
160+
161+
# Regular expression which should only match correct method names
162+
method-rgx=[a-z_][a-z0-9_]{2,30}$
163+
164+
# Regular expression which should only match correct instance attribute names
165+
attr-rgx=[a-z_][a-z0-9_]{2,30}$
166+
167+
# Regular expression which should only match correct argument names
168+
argument-rgx=[a-z_][a-z0-9_]{2,30}$
169+
170+
# Regular expression which should only match correct variable names
171+
variable-rgx=[a-z_][a-z0-9_]{2,30}$
172+
173+
# Regular expression which should only match correct list comprehension /
174+
# generator expression variable names
175+
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
176+
177+
# Good variable names which should always be accepted, separated by a comma
178+
good-names=i,j,k,ex,Run,_
179+
180+
# Bad variable names which should always be refused, separated by a comma
181+
bad-names=foo,bar,baz,toto,tutu,tata
182+
183+
# Regular expression which should only match functions or classes name which do
184+
# not require a docstring
185+
no-docstring-rgx=__.*__
186+
187+
188+
[CLASSES]
189+
190+
# List of interface methods to ignore, separated by a comma. This is used for
191+
# instance to not check methods defines in Zope's Interface base class.
192+
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
193+
194+
# List of method names used to declare (i.e. assign) instance attributes.
195+
defining-attr-methods=__init__,__new__,setUp
196+
197+
# List of valid names for the first argument in a class method.
198+
valid-classmethod-first-arg=cls
199+
200+
# List of valid names for the first argument in a metaclass class method.
201+
valid-metaclass-classmethod-first-arg=mcs
202+
203+
204+
[IMPORTS]
205+
206+
# Deprecated modules which should not be used, separated by a comma
207+
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
208+
209+
# Create a graph of every (i.e. internal and external) dependencies in the
210+
# given file (report RP0402 must not be disabled)
211+
import-graph=
212+
213+
# Create a graph of external dependencies in the given file (report RP0402 must
214+
# not be disabled)
215+
ext-import-graph=
216+
217+
# Create a graph of internal dependencies in the given file (report RP0402 must
218+
# not be disabled)
219+
int-import-graph=
220+
221+
222+
[DESIGN]
223+
224+
# Maximum number of arguments for function / method
225+
max-args=5
226+
227+
# Argument names that match this expression will be ignored. Default to name
228+
# with leading underscore
229+
ignored-argument-names=_.*
230+
231+
# Maximum number of locals for function / method body
232+
max-locals=15
233+
234+
# Maximum number of return / yield for function / method body
235+
max-returns=6
236+
237+
# Maximum number of branch for function / method body
238+
max-branchs=12
239+
240+
# Maximum number of statements in function / method body
241+
max-statements=50
242+
243+
# Maximum number of parents for a class (see R0901).
244+
max-parents=7
245+
246+
# Maximum number of attributes for a class (see R0902).
247+
max-attributes=7
248+
249+
# Minimum number of public methods for a class (see R0903).
250+
min-public-methods=2
251+
252+
# Maximum number of public methods for a class (see R0904).
253+
max-public-methods=20
254+
255+
256+
[EXCEPTIONS]
257+
258+
# Exceptions that will emit a warning when being caught. Defaults to
259+
# "Exception"
260+
overgeneral-exceptions=Exception

0 commit comments

Comments
 (0)