Skip to content

Commit

Permalink
Merge pull request #302 from dhermes/remove-cyclic-twice
Browse files Browse the repository at this point in the history
Remove cyclic import from ignored for tests.
  • Loading branch information
dhermes committed Oct 28, 2014
2 parents 1237161 + d75091a commit 87cf71d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ coverage.xml

# Regression test environment variables.
regression/local_test_setup

# Make sure a generated file isn't accidentally committed.
pylintrc_reduced
6 changes: 1 addition & 5 deletions pylintrc_default
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ ignore = datastore_v1_pb2.py
[MESSAGES CONTROL]
disable = I, protected-access, maybe-no-member, no-member,
redefined-builtin, star-args, missing-format-attribute,
similarities, arguments-differ,




similarities, arguments-differ

[REPORTS]
reports = no
Expand Down
37 changes: 0 additions & 37 deletions pylintrc_reduced

This file was deleted.

49 changes: 49 additions & 0 deletions run_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
violations (hence it has a reduced number of style checks).
"""

import ConfigParser
import copy
import subprocess
import sys

Expand All @@ -18,6 +20,52 @@
]
PRODUCTION_RC = 'pylintrc_default'
TEST_RC = 'pylintrc_reduced'
TEST_DISABLED_MESSAGES = [
'invalid-name',
'missing-docstring',
'too-many-public-methods',
'too-few-public-methods',
'attribute-defined-outside-init',
'unbalanced-tuple-unpacking',
'too-many-locals',
'exec-used',
'no-init',
'no-self-use',
]
TEST_RC_ADDITIONS = {
'MESSAGES CONTROL': {
'disable': ', '.join(TEST_DISABLED_MESSAGES),
},
}


def read_config(filename):
"""Reads pylintrc config onto native ConfigParser object."""
config = ConfigParser.ConfigParser()
with open(filename, 'r') as file_obj:
config.readfp(file_obj)
return config


def make_test_rc(base_rc_filename, additions_dict, target_filename):
"""Combines a base rc and test additions into single file."""
main_cfg = read_config(base_rc_filename)

# Create fresh config for test, which must extend production.
test_cfg = ConfigParser.ConfigParser()
test_cfg._sections = copy.deepcopy(main_cfg._sections)

for section, opts in additions_dict.items():
curr_section = test_cfg._sections.setdefault(
section, test_cfg._dict())
for opt, opt_val in opts.items():
curr_val = curr_section.get(opt)
if curr_val is None:
raise KeyError('Expected to be adding to existing option.')
curr_section[opt] = '%s, %s' % (curr_val, opt_val)

with open(target_filename, 'w') as file_obj:
test_cfg.write(file_obj)


def valid_filename(filename):
Expand Down Expand Up @@ -74,6 +122,7 @@ def lint_fileset(filenames, rcfile, description):

def main():
"""Script entry point. Lints both sets of files."""
make_test_rc(PRODUCTION_RC, TEST_RC_ADDITIONS, TEST_RC)
library_files, non_library_files = get_python_files()
lint_fileset(library_files, PRODUCTION_RC, 'library code')
lint_fileset(non_library_files, TEST_RC, 'test and demo code')
Expand Down

0 comments on commit 87cf71d

Please sign in to comment.