Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions ale_linters/python/pyrefly.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ call ale#Set('python_pyrefly_use_global', get(g:, 'ale_use_global_executables',
call ale#Set('python_pyrefly_auto_pipenv', 0)
call ale#Set('python_pyrefly_auto_poetry', 0)
call ale#Set('python_pyrefly_auto_uv', 0)
call ale#Set('python_pyrefly_config', {'python': {'pyrefly': {'displayTypeErrors': 'force-on'}}})

function! ale_linters#python#pyrefly#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyrefly_auto_pipenv'))
Expand Down Expand Up @@ -54,4 +55,5 @@ call ale#linter#Define('python', {
\ 'project_root': function('ale#python#FindProjectRoot'),
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
\ 'cwd': function('ale_linters#python#pyrefly#GetCwd'),
\ 'lsp_config': {b -> ale#Var(b, 'python_pyrefly_config')},
\})
30 changes: 30 additions & 0 deletions doc/ale-python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,37 @@ g:ale_python_pyrefly_auto_uv
Set the executable to `uv` if true. This is overridden by a manually-set
executable.

*ale-options.python_pyrefly_config*
*g:ale_python_pyrefly_config*
*b:ale_python_pyrefly_config*
python_pyrefly_config
g:ale_python_pyrefly_config
Type: |Dictionary|
Default: `{'python': {'pyrefly': {'displayTypeErrors': 'force-on'}}}`

Settings for configuring the `pyrefly` language server.

Starting with `pyrefly` version `0.31.1` displaying type errors is
disabled by default if no `pyrefly.toml` or `pyproject.toml` with a
`[tool.pyrefly]` section exists. The default |g:ale_python_pyrefly_config|
enables `displayTypeErrors`. When explicitly configuring
|g:ale_python_pyrefly_config| ensure to configure `displayTypeErrors`
if desired. To disable `displayTypeErrors` set the value to `force-off`
or set to `default` to require a `pyrefly` configuration for the
Comment thread
sivel marked this conversation as resolved.
project.

A commonly used setting for `pyrefly` is disabling language services
apart from type checking, you can set this setting like so, or use
whatever other settings you want: >

let b:ale_python_pyright_config = {
\ 'python': {
\ 'pyrefly': {
\ 'disableLanguageServices': v:true,
\ }
\ },
\}
<
===============================================================================
pyright *ale-python-pyright*

Expand Down
7 changes: 7 additions & 0 deletions test/linter/test_pyrefly.vader
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ Execute(uv is detected when python_pyrefly_auto_uv is set):

AssertLinter 'uv',
\ ale#Escape('uv') . ' run pyrefly lsp'

Execute(Assert the default config):
AssertLSPConfig {'python': {'pyrefly': {'displayTypeErrors': 'force-on'}}}

let b:ale_python_pyrefly_config = {}

AssertLSPConfig {}
Loading