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.
This commit is contained in:
w0rp
2025-06-24 07:47:02 +01:00
parent 80ff84db84
commit a0572359ae
4 changed files with 13 additions and 48 deletions

View File

@@ -26,7 +26,6 @@ function! ale#python#FindProjectRootIni(buffer) abort
" If you change this, update ale-python-root documentation. " If you change this, update ale-python-root documentation.
if filereadable(l:path . '/MANIFEST.in') if filereadable(l:path . '/MANIFEST.in')
\|| filereadable(l:path . '/setup.cfg') \|| filereadable(l:path . '/setup.cfg')
\|| filereadable(l:path . '/pytest.ini')
\|| filereadable(l:path . '/tox.ini') \|| filereadable(l:path . '/tox.ini')
\|| filereadable(l:path . '/.pyre_configuration.local') \|| filereadable(l:path . '/.pyre_configuration.local')
\|| filereadable(l:path . '/mypy.ini') \|| filereadable(l:path . '/mypy.ini')
@@ -55,11 +54,12 @@ endfunction
" Given a buffer number, find the project root directory for Python. " Given a buffer number, find the project root directory for Python.
" The root directory is defined as the first directory found while searching " The root directory is defined as the first directory found while searching
" upwards through paths, including the current directory, until a path " upwards through paths, including the current directory, until a path
" containing an init file (one from MANIFEST.in, setup.cfg, pytest.ini, " containing an configuration file is found. (See list above)
" 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 " If it is not possible to find the project root directory via configuration
" searching upwards through paths, including the current directory, until no " file, then it will be defined as the first directory found searching upwards
" __init__.py files is found. " through paths, including the current directory, until no __init__.py files
" is found.
function! ale#python#FindProjectRoot(buffer) abort function! ale#python#FindProjectRoot(buffer) abort
let l:ini_root = ale#python#FindProjectRootIni(a:buffer) let l:ini_root = ale#python#FindProjectRootIni(a:buffer)

View File

@@ -63,7 +63,6 @@ ALE will look for configuration files with the following filenames. >
MANIFEST.in MANIFEST.in
setup.cfg setup.cfg
pytest.ini
tox.ini tox.ini
.pyre_configuration.local .pyre_configuration.local
mypy.ini mypy.ini
@@ -81,6 +80,7 @@ ALE will look for configuration files with the following filenames. >
poetry.lock poetry.lock
pyproject.toml pyproject.toml
.tool-versions .tool-versions
uv.lock
< <
The first directory containing any of the files named above will be used. The first directory containing any of the files named above will be used.

View File

@@ -125,35 +125,35 @@ Execute(The flake8 callbacks should detect virtualenv directories):
\ . ' --stdin-display-name %s -', \ . ' --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') call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
AssertEqual AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'), \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
\ ale#python#FindProjectRoot(bufnr('')) \ 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') call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
AssertEqual AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'), \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
\ ale#python#FindProjectRoot(bufnr('')) \ 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') call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
AssertEqual 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('')) \ 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') call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
AssertEqual AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'), \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
\ ale#python#FindProjectRoot(bufnr('')) \ 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') call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
AssertEqual AssertEqual

View File

@@ -111,41 +111,6 @@ Execute(The flakehell callbacks should detect virtualenv directories):
\ . ' --stdin-display-name %s -', \ . ' --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. " Some users currently run flakehell this way, so we should support it.
Execute(Using `python -m flakehell` should be supported for running flakehell): Execute(Using `python -m flakehell` should be supported for running flakehell):
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py') call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')