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

Refactor file checking to allow parallel linting in Prospector #3016

Merged
merged 1 commit into from
Oct 18, 2019
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
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,4 @@ contributors:

* laike9m: contributor

* Janne Rönkkö: contributor
12 changes: 11 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,21 @@ Release date: TBA

Closes #2729

* Allow parallel linting when run under Prospector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to the 2.5 section instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done



What's New in Pylint 2.4.3?
===========================

Release date: TBA
Pass the actual PyLinter object to sub processes to allow using custom
PyLinter classes.

PyLinter object (and all its members except reporter) needs to support
pickling so the PyLinter object can be passed to worker processes.

* Refactor file checking

Remove code duplication from file checking.

* Fix an issue with ``unnecessary-comprehension`` in comprehensions with additional repacking of elements.

Expand Down
6 changes: 5 additions & 1 deletion pylint/checkers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,15 @@ def _has_same_layout_slots(slots, assigned_value):
}


def _scope_default():
return collections.defaultdict(list)


class ScopeAccessMap:
"""Store the accessed variables per scope."""

def __init__(self):
self._scopes = collections.defaultdict(lambda: collections.defaultdict(list))
self._scopes = collections.defaultdict(_scope_default)

def set_accessed(self, node):
"""Set the given node as accessed."""
Expand Down
11 changes: 7 additions & 4 deletions pylint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import configparser
import contextlib
import copy
import functools
import io
import optparse
import os
Expand Down Expand Up @@ -719,10 +720,8 @@ def read_config_file(self, config_file=None, verbose=None):
opt = "-".join(["long"] * helplevel) + "-help"
if opt in self._all_options:
break # already processed
# pylint: disable=unused-argument
def helpfunc(option, opt, val, p, level=helplevel):
print(self.help(level))
sys.exit(0)

helpfunc = functools.partial(self.helpfunc, level=helplevel)

helpmsg = "%s verbose help." % " ".join(["more"] * helplevel)
optdict = {"action": "callback", "callback": helpfunc, "help": helpmsg}
Expand Down Expand Up @@ -830,6 +829,10 @@ def help(self, level=0):
with _patch_optparse():
return self.cmdline_parser.format_help()

def helpfunc(self, option, opt, val, p, level): # pylint: disable=unused-argument
print(self.help(level))
sys.exit(0)


class OptionsProviderMixIn:
"""Mixin to provide options to an OptionsManager"""
Expand Down
Loading