Commit graph

118 commits

Author SHA1 Message Date
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
w0rp
8a659b7cc6
Fix #1566 - Add g:ale_python_flake8_change_directory 2018-05-28 16:34:54 +01:00
w0rp
6ab3fdc4d0
Close #1521 - Allow the language to be set with simple strings for LSP linters 2018-04-27 22:52:11 +01:00
Andreas Kloeckner
603e61ad71 flake8: Move to the buffer's directory before running flake8 command 2018-04-26 18:53:44 -05:00
w0rp
d8a673515a
Close #1162 - Implement completion support with LSP servers 2018-04-22 12:28:19 +01:00
w0rp
f9ba3d924f
Fix #1507 - Add an option for disabling switching directories for pylint 2018-04-17 13:30:30 +01:00
w0rp
3f0e1cd05d Fix #1492 - Make pylint error parsing work on Windows 2018-04-10 15:18:16 +01:00
w0rp
719b790574
Close #542 - Add an option for disabling running locally installed executables by default 2018-04-09 19:11:20 +01:00
rhysd
4903b966a7 pylint: Move to the buffer's directory before running pylint command (Fix #1472) 2018-04-09 16:43:10 +09:00
w0rp
5972b97223 #476 Make F401 a warning and E112 a syntax error 2018-02-18 09:44:04 +00:00