Compare commits

...
2 Commits
Author SHA1 Message Date
Andrey Starodubtsev 9e49019a26 Some absolute paths are not recognized for Windows (#4987)
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* Some abs paths are not recognized for win32

Paths like "c:/abc/def.cpp" were not recognized as absolute on Windows.

* Fix test for mypy_handler

mypy handler not just simplifies path, but tries to convert path to
absolute.
2025-06-24 11:05:11 +01:00
w0rp a0572359ae Remove pytest.ini from project detection files
This breaks detecting the project root when editing tests with a nested
pytest.ini file where other project files are available. The other files
are so common we can just removes this entirely and test that we
ignore it in one case.
2025-06-24 07:47:15 +01:00
7 changed files with 35 additions and 54 deletions

No files matched your search

+4 -5
View File
@@ -115,12 +115,11 @@ endfunction
" Return 1 if a path is an absolute path.
function! ale#path#IsAbsolute(filename) abort
if has('win32') && a:filename[:0] is# '\'
return 1
if has('win32')
return a:filename[:0] =~# '[\\/]' || a:filename[0:2] =~? '[A-Z]:[/\\]'
else
return a:filename[:0] is# '/'
endif
" Check for /foo and C:\foo, etc.
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
endfunction
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h'))
+6 -6
View File
@@ -26,7 +26,6 @@ function! ale#python#FindProjectRootIni(buffer) abort
" If you change this, update ale-python-root documentation.
if filereadable(l:path . '/MANIFEST.in')
\|| filereadable(l:path . '/setup.cfg')
\|| filereadable(l:path . '/pytest.ini')
\|| filereadable(l:path . '/tox.ini')
\|| filereadable(l:path . '/.pyre_configuration.local')
\|| filereadable(l:path . '/mypy.ini')
@@ -55,11 +54,12 @@ endfunction
" Given a buffer number, find the project root directory for Python.
" The root directory is defined as the first directory found while searching
" upwards through paths, including the current directory, until a path
" containing an init file (one from MANIFEST.in, setup.cfg, pytest.ini,
" tox.ini) is found. If it is not possible to find the project root directory
" via init file, then it will be defined as the first directory found
" searching upwards through paths, including the current directory, until no
" __init__.py files is found.
" containing an configuration file is found. (See list above)
"
" If it is not possible to find the project root directory via configuration
" file, then it will be defined as the first directory found searching upwards
" through paths, including the current directory, until no __init__.py files
" is found.
function! ale#python#FindProjectRoot(buffer) abort
let l:ini_root = ale#python#FindProjectRootIni(a:buffer)
+1 -1
View File
@@ -63,7 +63,6 @@ ALE will look for configuration files with the following filenames. >
MANIFEST.in
setup.cfg
pytest.ini
tox.ini
.pyre_configuration.local
mypy.ini
@@ -81,6 +80,7 @@ ALE will look for configuration files with the following filenames. >
poetry.lock
pyproject.toml
.tool-versions
uv.lock
<
The first directory containing any of the files named above will be used.
+1 -1
View File
@@ -107,7 +107,7 @@ Execute(The mypy handler should handle Windows names with spaces):
\ {
\ 'lnum': 4,
\ 'col': 0,
\ 'filename': ale#path#Simplify('C:\something\with spaces.py'),
\ 'filename': ale#path#GetAbsPath(getcwd(), 'C:\something\with spaces.py'),
\ 'type': 'E',
\ 'text': 'No library stub file for module ''django.db''',
\ },
+6 -6
View File
@@ -125,35 +125,35 @@ Execute(The flake8 callbacks should detect virtualenv directories):
\ . ' --stdin-display-name %s -',
\]
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
Execute(FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
Execute(FindProjectRoot should detect the project root directory for namespace package via setup.cf):
call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
Execute(FindProjectRoot should ignore the location of pytest.ini):
call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest/namespace'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
Execute(FindProjectRoot should detect the project root directory for namespace package via tox.ini):
call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
Execute(FindProjectRoot should detect the project root directory for non-namespace package):
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
AssertEqual
-35
View File
@@ -111,41 +111,6 @@ Execute(The flakehell callbacks should detect virtualenv directories):
\ . ' --stdin-display-name %s -',
\]
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
\ ale#python#FindProjectRoot(bufnr(''))
" Some users currently run flakehell this way, so we should support it.
Execute(Using `python -m flakehell` should be supported for running flakehell):
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
+17
View File
@@ -13,6 +13,15 @@ Execute(Relative paths should be resolved correctly):
AssertEqual
\ 'C:\foo\bar\baz\whatever.txt',
\ ale#path#GetAbsPath('C:\foo\bar\baz\xyz', '../whatever.txt')
AssertEqual
\ 'C:\foo\bar\baz\whatever.txt',
\ ale#path#GetAbsPath('C:\foo\bar\baz\xyz', '..\whatever.txt')
AssertEqual
\ 'C:\foo\bar\baz\whatever.txt',
\ ale#path#GetAbsPath('C:/foo/bar/baz/xyz', '../whatever.txt')
AssertEqual
\ 'C:\foo\bar\baz\whatever.txt',
\ ale#path#GetAbsPath('C:/foo/bar/baz/xyz', '..\whatever.txt')
endif
Execute(Absolute paths should be resolved correctly):
@@ -26,4 +35,12 @@ Execute(Absolute paths should be resolved correctly):
if has('win32')
AssertEqual '\ding', ale#path#GetAbsPath('/foo/bar/xyz', '\\ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('/foo/bar/xyz', 'c:/ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('/foo/bar/xyz', 'c:\ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('\foo\bar\xyz', 'c:/ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('\foo\bar\xyz', 'c:\ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:/foo/bar/xyz', 'c:/ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:/foo/bar/xyz', 'c:\ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:\foo\bar\xyz', 'c:/ding')
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:\foo\bar\xyz', 'c:\ding')
endif