mirror of
https://github.com/dense-analysis/ale.git
synced 2026-11-17 01:10:41 +08:00
Compare commits
2
Commits
80ff84db84
...
9e49019a26
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e49019a26 | ||
|
|
a0572359ae |
No files matched your search
@@ -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'))
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
@@ -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''',
|
||||
\ },
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user