Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cyclic import from ignored for tests. #302

Merged
merged 3 commits into from
Oct 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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