Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ignore .ale-not-project-root directories during determine Python Proj…#4991

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@mangin
Copy link

…ect directory
Here’s a clearer and more polished version of your GitHub PR description, with improved grammar, clarity, and structure:


Problem

In our monorepo, we have a structure like this:

mono_repo/project_1/setup.cfg...mono_repo/project_N/setup.cfgmono_repo/setup.cfg

When using ALE (Asynchronous Lint Engine) for linting, it automatically determines the Python project root by locating the first directory that contains a Python config file (e.g.,setup.cfg,pyproject.toml, etc.).

However, in our setup, this behavior can be problematic. For example, ALE may incorrectly treat the top-levelmono_repo/project_*/setup.cfg as the root, instead of one of the nestedmono_repo directory. This prevents us from applying linter rules defined at the project level.

Proposed Solution

To address this, I propose introducing a marker file named.ale-not-project-root. When ALE encounters this file, it will skip that directory as a potential Python project root and continue "searching deeper."

Example Use Case

mono_repo/mono_repo/setup.cfgmono_repo/project_1/.ale-not-project-rootmono_repo/project_1/setup.cfgmono_repo/project_2/.ale-not-project-rootmono_repo/project_2/setup.cfg

With this marker, ALE will skipmono_repo/project_1 andmono_repo/project_2 and use thesetup.cfg from the root.

Feedback

Does this approach sound reasonable? Happy to discuss alternatives or improvements.

Copy link
Member

@w0rpw0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a bit too hacky. I've prefer tweaking this a bit better to match project roots, possibly removing some of the old files we used to test for. I removedpytest.ini this morning, for example.

@w0rp
Copy link
Member

I tend to discourage configurations that might change behaviour in ALE specifically in a committed project file.

@mangin
Copy link
Author

You're right — our current approach to determining the Python project root is admittedly a bit hacky, and it's true that we already rely on committed project files for this behavior. Right now, we walk up from "the file" until we hit a known config file, which works well for most projects. I understand the logic behind it — it's a simple heuristic that covers a lot of cases.

That said, some projects can be structured in less conventional ways, and this method can be too optimistic. Personally, I’d like to have some mechanism to override or customize this behavior when needed.

Do you have any thoughts on how we could allow users to explicitly set or override the Python project root?

@w0rp
Copy link
Member

Let's change the behavior actually to prefer the value of theale_root setting that already exists. Ifale_root is set, always prefer that over everything else and skip all of the directory searching behaviour. It'll be faster than scanning the filesystem, and it will be pretty consistent. Have a look at:h ale_root and uses in the codebase already. I'd say:

  1. Renameale#lsp_linter#FindProjectRoot toale#linter#GetRoot and put it inlinter.vim at the bottom of the file
  2. Probably replacereturn ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) in that function with justreturn '' as I think that's a bug that never gets triggered in code paths for LSP linters.
  3. Call the newale#linter#GetRoot function first inale#python#FindProjectRoot
  4. Add more tests to cover the changes/
  5. Update comments in code and documentation everywhere to explain the new behaviour.

Theoretically a breaking change, but a change for the better.

For fun I'll set OpenAI Codex to the task and see how well it does...

@w0rp
Copy link
Member

@mangin Okay, so Codex did avery good job actually.#4993

You can rip off this commit and tweak it a bit.

@w0rp
Copy link
Member

I'll close this one. See the draft of the other option I proposed here.

@w0rpw0rp closed thisAug 13, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@w0rpw0rpw0rp requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mangin@w0rp

[8]ページ先頭

©2009-2025 Movatter.jp