leanprover-community / leanprover-community/physlib

Style lint technical debt

Open
#1,180 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
749
Forks
189
Avg merge
1d 21h
Merged PRs (30d)
75

Description

Having done a lot of project maintenance and written a lot of python code, I have many opinions about both. I looked at scripts/lint-style.py and immediately thought of ~5-10 refactoring tasks, from the cosmetic to updating to the contemporary state of defensible python:

  • Full mypy strict typing
  • Chained if/elif/else -> case/match and assignment operator (:=)
  • (unit tests might seem overbearing for tooling, but to use the favorite wording of Claude, there's a high cost of wrong here)
  • (pydantic dependency probably also undesirable unless we're willing to require uv for project management of pythonic components, however pydantic would allow for a very easy, defensible, and conventional way to validate input data contracts, for example, style-exceptions.txt. Given how much string scraping lint-style.py is doing, pydantic would be a significant improvement)
  • If python code, even as maintenance tooling, we probably would want a pyproject.toml anyway with
    [tool.ruff.lint]
    select = ["E", "W", "F", "I", "N", "UP", "B", "C4", "SIM", "TID", "RUF"]
    
    at a minimum
  • Business logic leaking out of python into sidecar shell scripts
  • s/argv/argparse/g
  • if __name__ == "__main__"
However

A comment near the top of the file says, "This is adapted from the linter for mathlib3. It should be rewritten in Lean," implying at least two constraints on the problems and the strategy of their solutions:

  1. What is the project coupling strength to mathlib(4)? Should we work within their conventions, specifically
  2. This entire file should be rewritten in lean, basically invalidating or at least dead ending any python improvements?

I'm not very familiar with lean yet, so can't judge the linting usecase or hammer-finding-nails signal. It's usually better for a language's own ecosystem to evaluate and manage style and formatting issues natively. For example: black, isort, pyupgrade, mypy for python, rustfmt, clippy, cargo-audit for rust, gofmt, go vet, goimports for go. Perhaps there's nothing to do here but instrument whatever that is, or contribute to lean tooling directly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading scripts/lint-style.py, especially the comment about adapting the mathlib3 linter and rewriting it in Lean. Determine the project's coupling to mathlib and whether Python improvements or Lean tooling are wanted; completion requires an agreed scope and strategy before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.