Skip to content

Commit

Permalink
Move pylint sys.path hackery into pylintrc so that any use of pylint …
Browse files Browse the repository at this point in the history
…gets it
  • Loading branch information
cpennington committed Dec 1, 2017
1 parent 840eb0b commit 6d8ce9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
37 changes: 9 additions & 28 deletions pavelib/quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,17 @@ def find_fixme(options):

apps_list = ' '.join(top_python_dirs(system))

pythonpath_prefix = (
"PYTHONPATH={system}/djangoapps:common/djangoapps:common/lib".format(
system=system
)
)

sh(
"{pythonpath_prefix} pylint --disable all --enable=fixme "
cmd = (
"pylint --disable all --enable=fixme "
"--output-format=parseable {apps} "
"> {report_dir}/pylint_fixme.report".format(
pythonpath_prefix=pythonpath_prefix,
apps=apps_list,
report_dir=report_dir
)
)

sh(cmd, ignore_error=True)

num_fixme += _count_pylint_violations(
"{report_dir}/pylint_fixme.report".format(report_dir=report_dir))

Expand Down Expand Up @@ -109,20 +104,14 @@ def run_pylint(options):

apps_list = ' '.join(top_python_dirs(system))

pythonpath_prefix = (
"PYTHONPATH={system}/djangoapps:common/djangoapps:common/lib".format(
system=system
)
)

sh(
"{pythonpath_prefix} pylint {flags} --output-format=parseable {apps} "
"pylint {flags} --output-format=parseable {apps} "
"> {report_dir}/pylint.report".format(
pythonpath_prefix=pythonpath_prefix,
flags=" ".join(flags),
apps=apps_list,
report_dir=report_dir
)
),
ignore_error=True,
)

num_violations += _count_pylint_violations(
Expand Down Expand Up @@ -768,15 +757,9 @@ def _pep8_output(count, violations_list, is_html=False):
eslint_files = get_violations_reports("eslint")
eslint_reports = u' '.join(eslint_files)

pythonpath_prefix = (
"PYTHONPATH=$PYTHONPATH:lms:lms/djangoapps:cms:cms/djangoapps:"
"common:common/djangoapps:common/lib"
)

# run diff-quality for pylint.
if not run_diff_quality(
violations_type="pylint",
prefix=pythonpath_prefix,
reports=pylint_reports,
percentage_string=percentage_string,
branch_string=compare_branch_string,
Expand All @@ -787,7 +770,6 @@ def _pep8_output(count, violations_list, is_html=False):
# run diff-quality for eslint.
if not run_diff_quality(
violations_type="eslint",
prefix=pythonpath_prefix,
reports=eslint_reports,
percentage_string=percentage_string,
branch_string=compare_branch_string,
Expand All @@ -801,7 +783,7 @@ def _pep8_output(count, violations_list, is_html=False):


def run_diff_quality(
violations_type=None, prefix=None, reports=None, percentage_string=None, branch_string=None, dquality_dir=None
violations_type=None, reports=None, percentage_string=None, branch_string=None, dquality_dir=None
):
"""
This executes the diff-quality commandline tool for the given violation type (e.g., pylint, eslint).
Expand All @@ -810,11 +792,10 @@ def run_diff_quality(
"""
try:
sh(
"{pythonpath_prefix} diff-quality --violations={type} "
"diff-quality --violations={type} "
"{reports} {percentage_string} {compare_branch_string} "
"--html-report {dquality_dir}/diff_quality_{type}.html ".format(
type=violations_type,
pythonpath_prefix=prefix,
reports=reports,
percentage_string=percentage_string,
compare_branch_string=branch_string,
Expand Down
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
ignore = ,.git,.tox,migrations,node_modules,.pycharm_helpers
persistent = yes
load-plugins = edx_lint.pylint,pylint_django,pylint_celery
init-hook = "import sys; sys.path.extend(['lms/djangoapps', 'cms/djangoapps', 'common/djangoapps'])"

[MESSAGES CONTROL]
enable =
Expand Down Expand Up @@ -444,4 +445,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = Exception

# ebf3c66ab89931381f66d2fbf20aa581696156c2
# cb770bb6272f6fe1edfd74aa1fb912be5541481c
1 change: 1 addition & 0 deletions pylintrc_tweaks
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pylintrc tweaks for use with edx_lint.
[MASTER]
ignore+ = ,.git,.tox,migrations,node_modules,.pycharm_helpers
init-hook="import sys; sys.path.extend(['lms/djangoapps', 'cms/djangoapps', 'common/djangoapps'])"

[BASIC]
attr-rgx = [a-z_][a-z0-9_]{2,40}$
Expand Down

0 comments on commit 6d8ce9b

Please sign in to comment.