Skip to content
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

Automatically detect module for lake exe runLinter #2

Closed
austinletson opened this issue May 4, 2024 · 16 comments
Closed

Automatically detect module for lake exe runLinter #2

austinletson opened this issue May 4, 2024 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@austinletson
Copy link
Collaborator

Instead of users manually providing a module to lint with the lint-module input, automatically detect which module to lint.

Depending on how this automatic detection works, we may still want to allow users to manually specify which module to lint.

@kim-em
Copy link
Collaborator

kim-em commented May 9, 2024

I think we can just look for e.g.

@[default_target]
lean_lib Mathlib

and decide on the basis of that to run it on Mathlib.

It would be nice if there were a way to query lake directly for this! @tydeu, any ideas there?

@digama0
Copy link

digama0 commented May 9, 2024

Should this issue be moved to batteries?

@austinletson
Copy link
Collaborator Author

austinletson commented May 9, 2024

The original intention here was detection contained in lean-action, similar to the detection of Mathlib in detect_mathlib.sh.

However, if batteries's lake exe runLinter will be the standard way to lint lean projects it seems generally useful to have dynamic default module detection. My understanding is that currently the default module to lint is Batteries so if you run lake exe runLinter (instead of lake exe runLinter SomeModule for instance) in a downstream package it still lints the entirety of batteries.

@tydeu
Copy link
Member

tydeu commented May 9, 2024

As a more general question: should we have a lake lint that functions similar to lake test but for linting?

@austinletson
Copy link
Collaborator Author

@tydeu Would this be a good use case for lake install.

Users could run lake install lean-lint and lake exe lean-lint? Similar to the rust-clippy linter usage?

@kim-em
Copy link
Collaborator

kim-em commented May 13, 2024

@tydeu, in the meantime, do you have a suggestion for what we ask lake here?

In batteries we need to generate lake exe runLinter Batteries, in mathlib lake exe runLinter Mathlib, etc.

I think getting the answer to: "please tell me all defaultTarget lean_libs" would suffice here.

@digama0
Copy link

digama0 commented May 13, 2024

This is not difficult to do using the Lake API. I just want this to be a Batteries issue so that the implementation task is not lost. (For that matter we should also have a mathlib issue tracking using the Lake API in cache.)

@kim-em
Copy link
Collaborator

kim-em commented May 13, 2024

@austinletson austinletson added enhancement New feature or request labels May 13, 2024
@oliver-butterley
Copy link
Contributor

This is not difficult to do using the Lake API. I just want this to be a Batteries issue so that the implementation task is not lost. (For that matter we should also have a mathlib issue tracking using the Lake API in cache.)

Prior to runLinter being updated to autodetect the module:

Is there an easy way to ask Lake what is the default module? Would a similar method exist to ask for the requires?

Of course it can be done by a script reading the lakefile but I perhaps there is a more elegant way.

@tydeu
Copy link
Member

tydeu commented May 15, 2024

@oliver-butterley A script is the best solution at the present. I do hope to implement better solutions in the future.

@kim-em
Copy link
Collaborator

kim-em commented May 15, 2024

Mario and Mac's answers seem to contradict here. Can't we do this via the Lake API, rather than scraping the lakefile?

@tydeu
Copy link
Member

tydeu commented May 15, 2024

@semorrison I fully agree with Mario's answer. By "script", a meant some Lean code using the Lake API. The alternative I understood @oliver-butterley to be suggesting was doing this through the Lake CLI, which is not possible at present.

@oliver-butterley
Copy link
Contributor

Indeed, I was hoping that the API mentioned by Mario was exposed in the Lake CLI. I.e., that something like lake info followed by package, lean_lib or requires would return the respective data of the current project directory.

Thanks for the clarification.

@kim-em
Copy link
Collaborator

kim-em commented May 15, 2024

Any hints about the relevant API function? :-)

@austinletson
Copy link
Collaborator Author

leanprover-community/batteries#811 should resolve this.

I used the resolveDefaultPackageTarget function to match the behavior of lake build, although there may be a more straightforward method.

@austinletson austinletson self-assigned this Jun 7, 2024
@austinletson
Copy link
Collaborator Author

I am closing this as not planned since it is out of score for lean-action. leanprover-community/batteries#811 should still resolve this, however lean-action users should wrap any usage of the batteries linter in lake lint

@austinletson austinletson closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants