summaryrefslogtreecommitdiff
path: root/pylint/lint.py
Commit message (Collapse)AuthorAgeFilesLines
* Refactor - Move the content of lint.py in its own packagePierre Sassoulas2020-04-261-1884/+0
| | | | Also move unittest_lint in test/lint.
* Print the fully qualified name of the extensionClaudiu Popa2020-03-251-2/+5
| | | | | We need this name so it's easier to figure out what name can be passed to `--load-plugins`.
* Add --list-extensions commandanubh-v2020-03-251-1/+26
| | | | Closes #3303
* pyupgrade: automated removal of python2 constructsAnthony Sottile2020-03-241-2/+1
| | | | | | | | | | | | | using configuration: ```yaml - repo: https://github.com/asottile/pyupgrade rev: v2.1.0 hooks: - id: pyupgrade args: [--py3-plus, --keep-percent-format] exclude: ^tests/(extensions/data/|functional/|input/|regrtest_data/) ```
* Add more tests for loading a malitious astroid fileClaudiu Popa2020-03-121-1/+0
|
* Continue adding the current working directory to sys.path with `fix_import_path`Claudiu Popa2020-03-121-30/+40
| | | | | | | | | | | | | | | | | | | | | | | This behaviour was previously removed in ac2c49867077cea9d0542560590999f2ebe00276 along with the removal of `''` to not force `pylint` load local files having the same name as stdlib or pylint dependencies. But we need the current working directory in sys.path in order to properly solve relative imports. For instance, given a package `pkg` and two modules, `pkg.A` and `pkg.B`, pylint would not be able to import a relative import `from .B import X` because it does not know where it can look for `.B` in the first place. Having the current working directory in sys.path means that `astroid.modutils.file_info_from_modpath` is still able to solve relative imports. At the same time, having the cwd in sys.path means that we might still load files local to this directory during pylint's initialization. The second part of this commit is to move `fix_import_path` before doing any AST processing. As a side effect, this removes a nasty bug with multiple jobs linting. Because the path was previously modified before spinning up new workers, those new workers would have had the cwd in sys.path and as a result, they would have been "able" to load local files from the directory, such as a malitious `astroid.py`.
* Move _get_python_path in utils to be accessible by that file as wellClaudiu Popa2020-03-121-15/+1
|
* Do not add the current directory to `sys.path` any longerClaudiu Popa2020-03-121-2/+6
| | | | | | | | Adding the current directory to `sys.path` can also mean that we're going to load modules having the same name as stdlib modules or astroid modules, which can break pylint. We were doing this since 4becf6f9e596b45401680c4947e2d92c953d5e08, but there was indication on why we were doing that.
* Mark --rcfile as a command since it cannot used in the configuration file. ↵Claudiu Popa2020-01-051-1/+2
| | | | Found in #3329
* Enable else-if-used extension (#3316)Nick Drozd2019-12-241-7/+5
| | | After all, if we don't use this, why should anybody else?
* Remove unintentional debug statementClaudiu Popa2019-11-211-1/+0
|
* Improve the testing around the new --fail-under flagClaudiu Popa2019-11-211-0/+1
|
* Add support for --fail-under flagsyutbai2019-11-211-3/+18
| | | | | | | | | | | Add a --fail-under <score> flag, also configurable in a `.pylintrc`file If the final score is more than the specified score, it's considered a success and pylint exits with exit code 0. Otherwise, it's considered a failure and pylint exits with its current exit code based on the messages issued. Close #2242
* Remove dead code (#3257)Thomas Hisch2019-11-211-4/+0
| | | | | This code is not needed, since get_ast with `data` != None is only needed for the --from-stdin feature, where get_ast is only called once. Therefore, a cache is not needed.
* Add support for disabling line-too-long for multilines stringshippo912019-11-191-48/+55
| | | | | | | | | This commit adds support for disabling `line-too-long` messages for multilines strings such as docstrings. When a pylint disable pragma is present at the end of the docstring, it is taken in account for the entire docstring. Close #2957
* Fix problem with syntaxerrors in file from stdinThomas Hisch2019-11-171-12/+17
| | | | | | | | | Exceptions raised in _ast_from_string were not properly handled in Pylint.check. Therefore, the output of `echo for | pylint --disable=all --enable=syntax-error --from-stdin module.py` contained a traceback. This issue is fixed by integrating the code from _ast_from_string into Pylint.get_ast.
* Fix py3k (#3210)Hugues2019-11-041-0/+5
| | | | | | | Enable syntax errors to properly surface invalid code in py3 porting mode, instead of silently swallowing them and giving the incorrect impression that the code is valid for py3. Closes #2956
* Refactor file checking for a simpler parallel API (#3016)Janne Rönkkö2019-10-181-236/+248
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change prepares the code for enabling Prospector to take advantage of running PyLint parallel. Iterating files is moved into generator (_iterate_file_descrs) so that parallel checking can use the same implementation (_check_file) just by providing different kind of generator that reads the files from parent process. The refactoring removes code duplication that existed in PyLinter._do_check method; checking module content from stdin had identical implementation to checking content from a source file. Made PyLinter.expand_files a private method. The previous implementation of parallel linting created new PyLinter objects in the worker (child) process causing failure when running under Prospector because Prospector uses a custom PyLinter class (a class inherited from PyLinter) and PyLint naturally just creates PyLinter object. This caused linting to fail because there is options for Prospector's IndentChecker which was not created in the worker process. The new implementation passes the original PyLinter object into workers when the workers are created. See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods Note that as Windows uses spawn method by default, PyLinter object (and its) members need to be pickleable from now on with the exception being PyLinter.reporter which is not passed to child processes. The performance has remained about the same based on quick tests done with Django project containing about 30 000 lines of code; with the old implementation linting took 26-28 seconds with 8 jobs on quad core i7 and 24-27 seconds with the new implementation.
* Can read setup.cfg and pyproject.toml filesAshley Whetter2019-10-091-1/+3
| | | | Closes #617
* ``import-outside-toplevel`` is emitted for ``ImportFrom`` nodes as well.Claudiu Popa2019-10-091-3/+1
| | | | Close #3175
* Disable too-many-public-methods for PyLinterClaudiu Popa2019-09-121-1/+1
|
* Add a command to list enabled/disabled messagesTrevor Bekolay2019-09-121-0/+36
| | | | | | | | | | | When enabling/disabling several messages and groups in a config file, it can be unclear which messages are actually enabled and which are disabled. This new command produces the final resolved lists of enabled/disabled messages, sorted by symbol but with the ID provided for use with `--help-msg`. This commit includes a test, documentation, and adding myself to the contributors list, as this is my first contribution.
* Remove redundant compatibility code (#3097)Hugo van Kemenade2019-09-121-2/+0
| | | | We no longer support Python 2 so we can remove the compatibility code we had in place for that version.
* Report unnecessary else after continue and breakRobert Schweizer2019-09-101-3/+1
| | | | Close #2327
* [pylint.message] Rename MessagesStore to MessageDefinitionStorePierre Sassoulas2019-08-091-2/+2
| | | | We anticipate to have a MessageIdStore.
* [pylint.lint] Rename neededcheckers to needed_checkersPierre Sassoulas2019-08-061-5/+5
|
* Fix number of statements in by_module stats (#3023)Andres Perez Hortal2019-07-291-0/+4
| | | | | Previously, self.stats['by_module'][modname]["statement"] was initialized to 0 and never updated once the module was processed.
* Improve help for options (#2986)Peter Kolbus2019-07-091-7/+7
|
* Refactor - Use a constant for the main checker namePierre Sassoulas2019-06-201-3/+7
| | | | Following review see : https://github.com/PyCQA/pylint/pull/2844#discussion_r281014968
* Fix a bunch of linting errors from the codebaseClaudiu Popa2019-05-221-7/+2
|
* Fixed pragmas on their own line after a backlash being ignored (#2923)Ashley Whetter2019-05-211-0/+15
| | | Closes #199
* Syntax errors report the column number.Claudiu Popa2019-05-201-3/+5
| | | | Close #2914
* Refactor - Move refactor.utils function to the utils packagePierre Sassoulas2019-03-291-3/+2
| | | | | | | This permit to have less cross dependency as the utils package does not depend on anything. The checker package still depends on reporter. Also moved classes from __init__ to their own file in reporter.
* Refactor - Remove circular import between utils and reporterPierre Sassoulas2019-03-291-1/+2
| | | | | ReportsHandlerMixIn was importing Nodes from reporter and is probably more suited for the reporter package anyway.
* Refactor - Avoid intra-packages circular dependencies for constantsPierre Sassoulas2019-03-291-2/+3
| | | | | | | | Some constants were package internal but were used by multiple packages. This created circular dependencies. By creating a file for constants we make sure this does not happen because we won't import everything important in this file and every thing else can depend on it.
* Style - Re-Apply black following the isort cleanupPierre Sassoulas2019-03-201-1/+0
| | | | Change with isort triggered change with black.
* Style - Apply isort on all apllicable filesPierre Sassoulas2019-03-201-14/+12
|
* Refactor - Rename PylintASTWalker to ASTWalkerPierre Sassoulas2019-03-091-8/+2
| | | | | For obvious reasons. See review here : https://github.com/PyCQA/pylint/pull/2654#discussion_r263843101
* Refactor - Create a pylint.message packagePierre Sassoulas2019-03-091-14/+21
| | | | | | | | There is a lot of Message related class in Utils this warrant the creation of a new package. See also review for burst utils.py into a package here: https://github.com/PyCQA/pylint/pull/2654#issuecomment-470748956
* Fix output in python -m pylint --version (#2788)Thomas Hisch2019-03-051-4/+4
| | | Close #2764
* Add support for reading from stdin (#2746)Thomas Hisch2019-03-021-22/+79
| | | | | pylint gained a new `--from-stdin` flag which activates stdin linting, useful for editors and similar use cases. Closes: #1187
* Fix lint warningsClaudiu Popa2019-02-131-4/+5
|
* Added a new command line option ``list-groups`` for listing all the check ↵Claudiu Popa2019-02-131-0/+27
| | | | groups ``pylint`` knows about.
* remove entire _patch_submodulesNicolas Dickreuter2019-01-201-16/+1
|
* remove popping for all versionsNicolas Dickreuter2019-01-201-5/+1
|
* avoid popping __main__ for python version >= 3.3Nicolas Dickreuter2019-01-201-1/+1
|
* Adjust the docstring a bitClaudiu Popa2018-12-201-3/+5
|
* Added load_configuration() hook for pluginsMatus Valo2018-12-201-0/+19
| | | | | | | A new optional hook for plugins is added: `load_configuration()`. This hook is executed after configuration is loaded to allow plugins to provide a specific configuration tailored to their purpose (e.g. pylint-django could set up their own set of `good_names` or blacklisted directories)
* Refactor - get_messages -> get_messages_from_checkerPierre Sassoulas2018-12-181-1/+1
|
* Adding implicit-str-concat-in-sequence check (#1655)Lucas Cimon2018-10-101-1/+1
| | | | | ``implicit-str-concat-in-sequence`` detects string concatenation inside lists, sets & tuples. It would warn on code such as `('a', 'b' 'c')`.