-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Python project root dir detection for flake8 configuration #2502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for this.
@@ -25,8 +25,7 @@ function! ale#python#FindProjectRootIni(buffer) abort | |||
\|| filereadable(l:path . '/tox.ini') | |||
\|| filereadable(l:path . '/mypy.ini') | |||
\|| filereadable(l:path . '/pycodestyle.cfg') | |||
\|| filereadable(l:path . '/flake8.cfg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python-language-server
discovers paths by looking for flake8.cfg
, so I'd keep this. It's mentioned here: https://pypi.org/project/python-language-server/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be a typo in the README of python-language-server
.
The commit which introduced the original introduced the change for reading flake8
but documented it incorrectly (palantir/python-language-server@3c1f183).
The python-language-server
has limited contributions to the project to those who have contributed in the past — I am unable to open an issue nor a pull request to address this discrepancy 😞 .
autoload/ale/python.vim
Outdated
@@ -25,8 +25,7 @@ function! ale#python#FindProjectRootIni(buffer) abort | |||
\|| filereadable(l:path . '/tox.ini') | |||
\|| filereadable(l:path . '/mypy.ini') | |||
\|| filereadable(l:path . '/pycodestyle.cfg') | |||
\|| filereadable(l:path . '/flake8.cfg') | |||
\|| filereadable(l:path . '/.flake8rc') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A number of projects and linter plugins search for .flake8rc
, so I'd keep this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched the history of the flake8
project and it has never supported .flake8rc
, from what I can tell.
I conducted a hasty Google search: ".flake8rc" and identified the following (potential) projects that may be using this are:
- https://github.com/AtomLinter/linter-flake8
- https://github.com/flycheck/flycheck
- https://github.com/w0rp/ale
Ale is using this in the documentation and within this function.
For linter-flake8
, it looks like it is another documentation bug (https://github.com/AtomLinter/linter-flake8/blob/875c273d3affe253478b804a51441688a0b2d03e/package.json#L27), from search https://github.com/AtomLinter/linter-flake8/search?q=flake8rc&unscoped_q=flake8rc.
For flycheck
, it appears they have a flycheck-flake8rc
-specific configuration file documented in (https://github.com/flycheck/flycheck/blob/47174a12fd84a685f36019632838c73b4813b66d/doc/languages.rst).
@@ -25,8 +25,7 @@ function! ale#python#FindProjectRootIni(buffer) abort | |||
\|| filereadable(l:path . '/tox.ini') | |||
\|| filereadable(l:path . '/mypy.ini') | |||
\|| filereadable(l:path . '/pycodestyle.cfg') | |||
\|| filereadable(l:path . '/flake8.cfg') | |||
\|| filereadable(l:path . '/.flake8rc') | |||
\|| filereadable(l:path . '/.flake8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move this further up the list, as this is the officially supported filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for this.
Absolutely.
I noticed that the tests for ale#python#FindProjectRoot
are in https://github.com/w0rp/ale/blob/master/test/command_callback/test_flake8_command_callback.vader. The path of least resistence would be to add a test there, which I'm planning on doing.
There is an opportunity to factor these out into a separate file, which occurs for some other languagse. If you don't mind, I'm happy to do this refactoring as a separate PR.
I'm still getting familiar with Vimscript, so it may take me a bit to get this right 😄.
@w0rp, let me know how you would like to proceed with the other configuration files that I responded to.
@@ -25,8 +25,7 @@ function! ale#python#FindProjectRootIni(buffer) abort | |||
\|| filereadable(l:path . '/tox.ini') | |||
\|| filereadable(l:path . '/mypy.ini') | |||
\|| filereadable(l:path . '/pycodestyle.cfg') | |||
\|| filereadable(l:path . '/flake8.cfg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be a typo in the README of python-language-server
.
The commit which introduced the original introduced the change for reading flake8
but documented it incorrectly (palantir/python-language-server@3c1f183).
The python-language-server
has limited contributions to the project to those who have contributed in the past — I am unable to open an issue nor a pull request to address this discrepancy 😞 .
autoload/ale/python.vim
Outdated
@@ -25,8 +25,7 @@ function! ale#python#FindProjectRootIni(buffer) abort | |||
\|| filereadable(l:path . '/tox.ini') | |||
\|| filereadable(l:path . '/mypy.ini') | |||
\|| filereadable(l:path . '/pycodestyle.cfg') | |||
\|| filereadable(l:path . '/flake8.cfg') | |||
\|| filereadable(l:path . '/.flake8rc') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched the history of the flake8
project and it has never supported .flake8rc
, from what I can tell.
I conducted a hasty Google search: ".flake8rc" and identified the following (potential) projects that may be using this are:
- https://github.com/AtomLinter/linter-flake8
- https://github.com/flycheck/flycheck
- https://github.com/w0rp/ale
Ale is using this in the documentation and within this function.
For linter-flake8
, it looks like it is another documentation bug (https://github.com/AtomLinter/linter-flake8/blob/875c273d3affe253478b804a51441688a0b2d03e/package.json#L27), from search https://github.com/AtomLinter/linter-flake8/search?q=flake8rc&unscoped_q=flake8rc.
For flycheck
, it appears they have a flycheck-flake8rc
-specific configuration file documented in (https://github.com/flycheck/flycheck/blob/47174a12fd84a685f36019632838c73b4813b66d/doc/languages.rst).
Leave |
I'm curious more than anything: What other linters have you seen that use it? I haven't been able to find anything concrete that would affect the Python linters which ale calls out to. I'll leave |
No linters automatically read it, but the location of the file is used to figure out where the root of a project might be. |
@w0rp, I have updated the PR with the changes requested and added a new test suite for future iterations of detecting a Python project's root directory. |
Add test files and a new test suite for detecting a Python project's root directory.
The official configuration files for `flake8` are `.flake8`, `tox.ini`, and `setup.cfg`. After investigation, it is safe to remove `flake8.cfg` as it appears to only exist as a typo in other tooling documentation (e.g., `python-language-server`). Even though no linters automatically read `.flake8rc`, it is kept in case projects may be using it for detecting the projects root directory.
Cheers! 🍻 |
The official configuration files for
flake8
are.flake8
,tox.ini
,and
setup.cfg
.After investigation, it is safe to remove
flake8.cfg
as it appears toonly exist as a typo in other tooling documentation (e.g.,
python-language-server
).Even though no linters automatically read
.flake8rc
, it is kept incase projects may be using it for detecting the projects root directory.
http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations