pyproject - A linter and language server for `pyproject.toml` files
Posted by vandalism@reddit | Python | View on Reddit | 17 comments
Hey all, I've been working on a static analysis tool (and language server) for pyproject.toml files after encountering inconsistencies in build tool error reporting (e.g. some tools will let you ship empty licenses directories). It would be nice to have a single source of truth for PEP 621 related checks and beyond that can be run prior to running more expensive workflows.
There are already a few basic rules for PEP 621 related errors/warnings, but its easily extendible to fit any specific tool's requirements.
What my project does
It can run checks on your Python project configuration from the command-line: pyproject check, format your pyproject.toml files: pyproject format, and start a language server. The language server currently has support for hover information, diagnostics, completions, and formatting.
Target audience
pyproject is useful for anyone that works on Python projects with a pyproject.toml configuration file.
It's still heavy alpha software, but I thought I'd share in case there's interest for something like this :)
https://github.com/terror/pyproject
jpgoldberg@reddit
Nice. This could definitely be useful.
The README states
Having each rule in its own module is nice, but as I look at some of them, I wonder if you could make it easier to extend by providing documentation on how to write a rule or (non-exclusive) defining macros that make it easier to create rules. (I've never written a Rust macro, but it seems like some of the more typical rules could have a lot of their code automatically generated.)
vandalism@reddit (OP)
This is definitely something I'm looking to add (or accept a contribution for). Interesting idea regarding macros, I haven't really thought of a design for making rules easier to write, if you have any ideas/examples as to where this can be useful feel free to share.
vandalism@reddit (OP)
I just thought of something actually, maybe something like this?
cgoldberg@reddit
I use
validate-pyproject. Is yours any different or better?https://validate-pyproject.readthedocs.io
vandalism@reddit (OP)
Yeah I came across that before, I believe they only do schema checks (and a few additional ones).
pyprojectaims to be flexible enough to extend with any kind of error/warning, and there are already a few extras: outdated dependencies, missing license files, missing readme files, etc.cgoldberg@reddit
I'll check it out. It would be nice if it had a Python wrapper and was published on PyPI so I could install it in a Python-only build system (without a Rust toolchain or downloading binaries).
vandalism@reddit (OP)
Yeah this should be out soon, I'm currently waiting to get ownership for the
pyprojectpackage on PyPI. Pretty soon you'll be able to justuvx pyproject checkwith a bunch of useful default rules.cgoldberg@reddit
Nice. If you remember, reply to this comment when that's available :)
vandalism@reddit (OP)
Just released it!
vandalism@reddit (OP)
It's live :)
mgedmin@reddit
I noticed that your screenshot shows a warning that recommends adding an upper-bound to
requires-python. That is a bad idea.uv's documentation explains why, and links to two more discussions for more detail.
vandalism@reddit (OP)
Interesting! I just made these warnings opt-in if anyone wants to enforce it.
Sigmatics@reddit
I like it
Going to be a hard sell though if you're not publishing this as a wheel through pypi
BravestCheetah@reddit
It sounds like a really cool project, thought sadly i wont have a personal use for it as `uv` handles my pyproject almost completely by itself
joerick@reddit
Great idea! Might I suggest though, a more distinct name? It's gonna be hard to google and hard to talk about this with people. "pyproject (the suite of tools)" is probably what you'd have to say each time.
Maybe
pyproject-lintorpyproject-toolswould work?PurepointDog@reddit
Pretty meta, but solid concept. I think ruff also checks certain rules in a pyproject file though fyi - might be nice to compare against that and/or submit back to the ruff codebase.
Your contributions may be worth far more if they're on top of an established project like ruff
vandalism@reddit (OP)
Yeah I’d love to get some (or all) of this functionality into Ruff, I saw a thread not too long ago before working on this (https://github.com/astral-sh/ruff/discussions/17771), and it seems like they don’t have support for this yet?