Commit Graph

127 Commits

Author SHA1 Message Date
Diep Pham 6c51bb1573
Improve pylama linter output handling (#4106)
* Use JSON format for newer pylama version

https://github.com/klen/pylama/blob/develop/Changelog

The --format json option is added in pylama version 8.1.4.

* Fix linting warnings for pylama
2022-04-24 08:28:33 +09:00
Jon Parise 8b1ea33cc0
Add a unimport linter for Python files (#4058)
Unimport (https://github.com/hakancelik96/unimport/) is a linter,
formatter for finding and removing unused import statements.

This introduces linting support, although fixer support could come
later.
2022-02-08 15:54:25 +09:00
Brendan Maginnis b9744076a1
Pass full path to pydocstyle (#3995)
* Pass full path to pydocstyle

* Update pydocstyle tests
2021-12-09 23:24:32 +09:00
David Houston ea643b97ab
Add cspell Linter (#3981)
* Add cspell linter

Add cspell linter, with the languages it supports.

Signed-off-by: David Houston <houstdav000@gmail.com>

* Add cspell Global Variables Documentation

Add documentation to /doc/ale.txt with cspell configuration options.

Signed-off-by: David Houston <houstdav000@gmail.com>

* Add cspell to docs, Minor Cleanup

Add cspell for each supported language, adding some spaces and removing
others when caught navigating the file.

Signed-off-by: David Houston <houstdav000@gmail.com>
2021-11-19 07:41:05 +09:00
a666 f9deee0e41
Add flakehell python linter (#3295) (#3921) 2021-10-02 16:37:57 +09:00
Oliver Albertini b504eeb094
[python/pyre.vim] Fix pyre persistent behavior (#3895)
It's necessary to provide a `-l` option to pyre with the closest parent
directory containing a `.pyre_configuration.local` file, or simply
change directory (cwd) to the root of the pyre project. Thanks to Ken
Verbosky for the code that fixes this.

Error seen when not using such a solution:

```
1031.473923 on 6: Dropping message 'ƛ Background task unexpectedly quited: Invalid configuration: Cannot find any source files to analyze. Either `source_directories` or `targets` must be specified.
```

Issue with this approach is that if you are editing files under
different projects, the `pyre persistent` process is not re-created for
each file. We have to do `:ALEStopAlllsps` in order for the process to
start with the new working directory.

Co-authored-by: Oliver Ruben Albertini <ora@fb.com>
2021-09-10 12:53:54 +09:00
Daniel Roseman 7d8fb2ba17
Python support poetry (#3834)
* Add poetry support to python linters and black fixer.

* Update python.vim to detect poetry project.

* Update ale.vim, add an option for poetry `g:ale_python_auto_poetry`.

* Update ale-python.txt, add poetry support.

* Add and update poetry related tests.

Co-authored-by: unc0 <unc0@users.noreply.github.com>
2021-07-25 13:39:05 +09:00
Gerardo Gómez Rodríguez 8b73d98baf
chore: replace python-language-server to supported pylsp (#3810)
As mentioned in #3722 palantir's python-language-server is no longer maintained.
The alternative is to use the community-driven https://github.com/python-lsp/python-lsp-server.
2021-07-09 22:40:31 +09:00
Nathan Henrie ed7f4dee53
issue 3033 (#3620)
* Add ale_python_pyls_options

* Add extra explanatory detail

* Fix alignment

* Fix test
2021-03-18 08:55:50 +09:00
w0rp 9fe7b1fe6a
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they
can later be swapped out when running linters over projects is
supported, and also better support filename mapping for running linters
on other machines in future.
2021-03-01 20:11:10 +00:00
Daniel Leong 8cb9f5ef51
mypy: Pass user options before any others (#3582)
This enables us to use a custom `python` exe as the "mypy" executable
and pass `-m mypy` in `mypy_options`
2021-02-11 20:29:23 +00:00
Dalius Dobravolskas 01800a23ad
Support for LSP/tsserver Code Actions (#3437)
* Added tsserver and LSP code action support.
* tsserver refactors support added.
* Handling special case when new text is added after new line symbol.
* ale#code_action#ApplyChanges simplified.
* Initial attempt on LSP Code Actions.
* workspace/executeCommand added.
* Some null checks added.
* Add last column to LSP Code Action message.
* Pass diagnostics to LSP code action.

Previously ApplyChanges code was applied from top-to-bottom that required 
extra parameters to track progress and there was bug. I have changed code
to bottom-to-top approach as that does not require those extra parameters
and solved the bug.

Tested with typescript-language-server and it is working.
2020-11-14 10:15:17 +00:00
w0rp 4ddf742643
Close #2522 - Check pylint on the fly
Newer versions of pylint will now check your code as you type. Older
versions will still only check the file on disk.

Co-authored-by: Oliver Wiegers <oliver.wiegers@gmail.com>
2020-09-09 21:45:15 +01:00
w0rp ac2100d410
Fix flake8 cd logic for invalid options 2020-08-31 09:12:36 +01:00
Konstantin Alekseev 1462de6685 Run flake8 from project root by default.
Option `per-file-ignores` was introduced in flake8 version 3.7.0.
It allows to ignore specific errors in specific files using glob syntax.
For example `per-file-ignores = src/generated/*.py:F401` will
ignore `F401` error in all python files in `src/generated`.
Thus ale has to run flake8 from project root where .flake8 config
is placed otherwise glob won't match linted file.
2020-08-30 22:56:10 +03:00
w0rp 7d4ce4e6aa
Close #3325 - Apply new formatting where possible 2020-08-28 19:50:36 +01:00
w0rp 19229e8e27
Close #2472 - Add support for pyright 2020-08-07 12:16:13 +01:00
Harry Percival 72d2c55479 Mypy: try to find folder containing mypy.ini to use as cwd. (#2385)
* When deciding which directory to run mypy from, prefer a folder with mypy.ini in it
* Add a test for mypy.ini-finding behaviour
2020-01-02 14:35:21 +00:00
w0rp 8c4c8dfd97
Fix #2704 - Show mypy notes; can be disabled 2020-01-02 14:19:21 +00:00
Richard French 266fa1c0a4 mypy linter capture stderr for error reporting in ALEInfo 2019-08-15 16:36:11 +01:00
Katsuya Horiuchi f444abdfe6 Add option to show msg id when pylint is used (#2445)
* Add python_pylint_use_msg_id to tweak output of pylint
* Add test for ale_python_pylint_use_msg_id
* Add doc on ale_python_pylint_use_msg_id
2019-05-09 17:28:18 +01:00
w0rp 3bebcb5d48
#2132 - Replace command_chain and chain_with with ale#command#Run 2019-04-07 14:58:06 +01:00
w0rp 883978ece9
#2132 - Replace all uses of foo_callback with foo 2019-02-22 18:05:04 +00:00
w0rp 8012e5b60f
Merge pull request #2303 from kevinoid/bandit-use-config
python/bandit: Use .bandit configuration file
2019-02-20 09:58:02 +00:00
Kevin Locke 52c2400786 python/bandit: Use .bandit configuration file
Bandit automatically [uses any .bandit file] within the directories on
which it is invoked.  Since ALE invokes bandit on stdin, it does not
load a .bandit file automatically.  Add support for automatically
finding a .bandit file and passing it to bandit via the --ini option
along with a variable to disable this behavior if desired.

Note: This is useful for the skips and tests configuration options, but
not exclude which would require invoking bandit using a file name, which
may or may not be a good trade-off.

[uses any .bandit file]: https://github.com/PyCQA/bandit/blob/1.5.1/bandit/cli/main.py#L70-L73

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-02-17 14:24:18 -07:00
Kevin Locke 3300b1aca7 python/pylint: Change directory to project root
Pylint only [checks for pylintrc] (and .pylintrc) files in the packages
aboves its current directory before falling back to user and global
pylintrc.  For projects with a src dir, running pylint from the
directory containing the file will not use the project pylintrc.

Adopt the convention used by many other Python linters of running from
the project root, which solves this issue.  Add pylintrc and .pylintrc
to FindProjectRoot.  Update docs.

[checks for pylintrc]: https://github.com/PyCQA/pylint/blob/pylint-2.2.2/pylint/config.py#L106

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-02-17 10:40:50 -07:00
Kevin Locke a6caa85a58 pylama: Use %s instead of %t
Although using %t to lint changes was desirable, many pylama checks use
surrounding paths and file contents (e.g. C0103 module name, E0402
relative import beyond top, etc.)  The more such errors I find during
testing, the less %t seems like a good idea.  Switch to %s.

Also set `lint_file` to 1 and mark Pylama as a file linter in the docs.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-02-12 10:45:26 -07:00
w0rp 7a48750610
Complain about binary operators on the ends of lines 2019-02-10 11:43:48 +00:00
Kevin Locke a24f0b4d5f Support pylama for python (#2266)
* Add pylama for python
* Consolidate python traceback handling
2019-02-08 21:44:34 +00:00
w0rp 3e11cbd18d
Update syntax checking
* Line continuation characters should be on the same lines.
* .vim file line indentation should be a multiple of 4.
2019-02-06 18:05:13 +00:00
w0rp f03370e183
Merge pull request #2207 from pmacosta/master
Fixed parsing of pydocstyle errors
2019-01-27 11:01:14 +00:00
w0rp d882c434a1
Merge pull request #2215 from irwand/master
support older flake8 output, still used by hacking module from openstack style guide
2019-01-27 10:57:42 +00:00
Martino Pilia 0a5de2b42b
Add bandit linter for Python 2019-01-26 11:48:03 +01:00
yut23 f2db164268 Add support for pyls configuration options
Resolves #1443.
Heavily inspired by the analogous support added for elixir-ls.
2019-01-20 23:59:46 -05:00
Irwan Djajadi 08affaad7a support older flake8 output, still used by hacking module from open style guide 2019-01-16 10:59:05 -06:00
Pablo Acosta-Serafini 86af4be0d0 Fixed parsing of pydocstyle errors
ale#Escape function seems to prepend and append ' to the file name, which
are not present in the pydocstyle output. Having the parsing regexp match
the file name was overkill anyway, since there is an obvious 1:1
correspondence between the buffer number and the (potential) errors
reported by pydocstyle.
2019-01-14 20:36:14 -05:00
pmacosta fdd37acc1f Add support for pydocstyle linter (#2085)
The linter can correctly parse pydocstyle output with any of the following
command-line options enabled: --explain, --source, --debug, and/or
--verbose
2018-12-06 11:27:03 -07:00
Marius Gedminas 9481f307fb flake8 reports visual columns
Fixes #2092.
2018-11-22 11:57:02 +02:00
Eddie Lebow dbe9352935 Add `python_auto_pipenv` config var for all python linters.
This allows a user to set one variable instead of eight.
2018-09-15 22:10:46 -04:00
Eddie Lebow 56e67c5811 Add python_[linter]_auto_pipenv options for python linters (fixes #1656)
When set to true, and the buffer is currently inside a pipenv,
GetExecutable will return "pipenv", which will trigger the existing
functionality to append the correct pipenv arguments to run each linter.

Defaults to false.

I was going to implement ale#python#PipenvPresent by invoking
`pipenv --venv` or `pipenv --where`, but it seemed to be abominably
slow, even to the point where the test suite wasn't even finishing
("Tried to run tests 3 times"). The diff is:

diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index 7baae079..8c100d41 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -106,5 +106,9 @@ endfunction

" Detects whether a pipenv environment is present.
function! ale#python#PipenvPresent(buffer) abort
-    return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''
+    let l:cd_string = ale#path#BufferCdString(a:buffer)
+    let l:output = systemlist(l:cd_string . 'pipenv --where')[0]
+    " `pipenv --where` returns the path to the dir containing the Pipfile
+    " if in a pipenv, or some error text otherwise.
+    return strpart(l:output, 0, 18) !=# "No Pipfile present"
 endfunction

Using vim's `findfile` is much faster, behaves correctly in the majority
of situations, and also works reliably when the `pipenv` command doesn't
exist.
2018-09-15 22:10:46 -04:00
actionless eb38c4b3f1 fix(linters: python): mark as lint_file 2018-07-26 14:45:28 +02:00
Yauhen Kirylau 8517e901ff Add support for 'vulture' for Python 2018-07-26 08:41:27 +01:00
w0rp 9ddf1b6a05
Make the language option for LSP linters optional 2018-07-04 13:12:58 +01:00
w0rp db85b931ec
Remove deprecated code for the 2.0 release 2018-07-04 08:36:34 +01:00
Derek P Sifford ea6d720fec add pyre lsp linter to python linters 2018-07-01 14:59:49 -04:00
w0rp b047271051
Merge pull request #1682 from fennerm/fix_prospector_e474
Fix prospector empty string error
2018-06-27 21:34:28 +01:00
Fenner Macrae 1ca2334846 Fix prospector empty string error
Prospector linter is raising error when no warnings are present in file
(#1680). Copied fix from #779.
2018-06-26 16:58:34 -07:00
Eddie Lebow ca88e67af0 Allow all Python linter executables to be set to `pipenv`.
It appends ` run {linter_name}`, analogously to the Ruby linters when
the executable is set to `bundle`
2018-06-05 00:33:26 -04:00
Eddie Lebow dd642b117c Allow flake8 executable to be set to `pipenv`.
It appends ` run flake8`, analogously to the Ruby tools when the
executable is set to `bundle`
2018-06-02 21:49:12 -04:00
w0rp 191967cfee
#1587 - Add deprecation warnings for old linter options 2018-05-28 19:52:27 +01:00