2020]
2121PRODUCTION_RC = 'pylintrc_default'
2222TEST_RC = 'pylintrc_reduced'
23- TEST_RC_MODS = 'pylintrc_test_modifications'
23+ TEST_DISABLED_MESSAGES = [
24+ 'invalid-name' ,
25+ 'missing-docstring' ,
26+ 'too-many-public-methods' ,
27+ 'too-few-public-methods' ,
28+ 'attribute-defined-outside-init' ,
29+ 'unbalanced-tuple-unpacking' ,
30+ 'too-many-locals' ,
31+ 'exec-used' ,
32+ 'no-init' ,
33+ 'no-self-use' ,
34+ ]
35+ TEST_RC_ADDITIONS = {
36+ 'MESSAGES CONTROL' : {
37+ 'disable' : ', ' .join (TEST_DISABLED_MESSAGES ),
38+ },
39+ }
2440
2541
2642def read_config (filename ):
@@ -31,25 +47,22 @@ def read_config(filename):
3147 return config
3248
3349
34- def make_test_rc (base_rc_filename , modifications_rc_filename ,
35- target_filename ):
36- """Combines a base rc and modifications into single file."""
50+ def make_test_rc (base_rc_filename , additions_dict , target_filename ):
51+ """Combines a base rc and test additions into single file."""
3752 main_cfg = read_config (base_rc_filename )
38- modification_cfg = read_config (modifications_rc_filename )
3953
4054 # Create fresh config for test, which must extend production.
4155 test_cfg = ConfigParser .ConfigParser ()
42-
4356 test_cfg ._sections = copy .deepcopy (main_cfg ._sections )
44- for section , opts in modification_cfg ._sections .items ():
57+
58+ for section , opts in additions_dict .items ():
4559 curr_section = test_cfg ._sections .setdefault (
46- section , modification_cfg ._dict ())
60+ section , test_cfg ._dict ())
4761 for opt , opt_val in opts .items ():
48- if opt in curr_section :
49- if curr_section [opt ] != opt_val :
50- curr_section [opt ] = ', ' .join ([curr_section [opt ], opt_val ])
51- else :
52- curr_section [opt ] = opt_val
62+ curr_val = curr_section .get (opt )
63+ if curr_val is None :
64+ raise KeyError ('Expected to be adding to existing option.' )
65+ curr_section [opt ] = '%s, %s' % (curr_val , opt_val )
5366
5467 with open (target_filename , 'w' ) as file_obj :
5568 test_cfg .write (file_obj )
@@ -109,7 +122,7 @@ def lint_fileset(filenames, rcfile, description):
109122
110123def main ():
111124 """Script entry point. Lints both sets of files."""
112- make_test_rc (PRODUCTION_RC , TEST_RC_MODS , TEST_RC )
125+ make_test_rc (PRODUCTION_RC , TEST_RC_ADDITIONS , TEST_RC )
113126 library_files , non_library_files = get_python_files ()
114127 lint_fileset (library_files , PRODUCTION_RC , 'library code' )
115128 lint_fileset (non_library_files , TEST_RC , 'test and demo code' )
0 commit comments