All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 Save g:ale_python_auto_pipenv
4 let g:ale_python_auto_pipenv = 0
6 call ale#assert#SetUpLinterTest('python', 'ruff')
8 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
9 let b:command_head = ale#Escape('ruff') . ' -q --no-fix'
10 let b:command_tail = ' --format json-lines --stdin-filename %s -'
12 GivenCommandOutput ['ruff 0.0.83']
19 call ale#assert#TearDownLinterTest()
21 Execute(The ruff callbacks should return the correct default values):
22 AssertLinterCwd expand('%:p:h')
23 AssertLinter 'ruff', b:command_head . b:command_tail
25 Execute(ruff should run with the file path of buffer in old versions):
26 " version `0.0.69` supports liniting input from stdin
27 GivenCommandOutput ['ruff 0.0.68']
29 AssertLinterCwd expand('%:p:h')
30 AssertLinter 'ruff', b:command_head . b:command_tail[:-23] . ' %s'
32 Execute(ruff should run with the --output-format flag in new versions):
33 GivenCommandOutput ['ruff 0.1.0']
35 AssertLinterCwd expand('%:p:h')
36 AssertLinter 'ruff', b:command_head . ' --output-format json-lines --stdin-filename %s -'
38 Execute(ruff should run with the stdin in new enough versions):
39 GivenCommandOutput ['ruff 0.0.83']
41 AssertLinterCwd expand('%:p:h')
42 AssertLinter 'ruff', b:command_head . b:command_tail[:-3] . ' -'
43 " AssertLinter 'ruff', b:command_head . b:command_tail[:-3] . '--format json-lines -'
45 Execute(ruff should run with the check subcmd in versions >= 0.3.0):
46 GivenCommandOutput ['ruff 0.3.0']
48 AssertLinterCwd expand('%:p:h')
49 let b:cmd_head = ale#Escape('ruff') . ' check -q --no-fix'
50 AssertLinter 'ruff', b:cmd_head . ' --output-format json-lines --stdin-filename %s -'
52 Execute(The option for disabling changing directories should work):
53 let g:ale_python_ruff_change_directory = 0
56 AssertLinter 'ruff', b:command_head . b:command_tail
58 Execute(The ruff executable should be configurable, and escaped properly):
59 let g:ale_python_ruff_executable = 'executable with spaces'
61 AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . ' -q --no-fix' . b:command_tail
63 Execute(The ruff command callback should let you set options):
64 let g:ale_python_ruff_options = '--some-flag'
65 AssertLinter 'ruff', b:command_head . ' --some-flag' . b:command_tail
67 let g:ale_python_ruff_options = '--some-option value'
68 AssertLinter 'ruff', b:command_head . ' --some-option value' . b:command_tail
70 Execute(The ruff callbacks shouldn't detect virtualenv directories where they don't exist):
71 call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
73 AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir')
74 AssertLinter 'ruff', b:command_head . b:command_tail
76 Execute(The ruff callbacks should detect virtualenv directories):
77 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
78 let b:executable = ale#path#Simplify(
79 \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff'
81 AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
82 AssertLinter b:executable, ale#Escape(b:executable) . ' -q --no-fix' . b:command_tail
84 Execute(You should able able to use the global ruff instead):
85 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
86 let g:ale_python_ruff_use_global = 1
88 AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
89 AssertLinter 'ruff', b:command_head . b:command_tail
91 Execute(Setting executable to 'pipenv' appends 'run ruff'):
92 let g:ale_python_ruff_executable = 'path/to/pipenv'
93 let g:ale_python_ruff_use_global = 1
95 AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run ruff -q --no-fix'
98 Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
99 let g:ale_python_ruff_auto_pipenv = 1
100 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
102 AssertLinterCwd expand('%:p:h')
103 AssertLinter 'pipenv', ale#Escape('pipenv') . ' run ruff -q --no-fix'
106 Execute(Setting executable to 'poetry' appends 'run ruff'):
107 let g:ale_python_ruff_executable = 'path/to/poetry'
108 let g:ale_python_ruff_use_global = 1
110 AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run ruff -q --no-fix'
113 Execute(poetry is detected when python_ruff_auto_poetry is set):
114 let g:ale_python_ruff_auto_poetry = 1
115 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
117 AssertLinterCwd expand('%:p:h')
118 AssertLinter 'poetry', ale#Escape('poetry') . ' run ruff -q --no-fix'
121 Execute(uv is detected when python_ruff_auto_uv is set):
122 let g:ale_python_ruff_auto_uv = 1
123 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
125 AssertLinterCwd expand('%:p:h')
126 AssertLinter 'uv', ale#Escape('uv') . ' run ruff -q --no-fix'