add ruff linter to functional2 pytests #812

Closed
opened 2025-04-28 14:55:58 +00:00 by commentatorforall · 11 comments

Currently there is no linting or anything else denoting common code styling for functional2 tests.
Hence, there is also no pre-commit/mr check if the guidelines are followed

Describe the solution you'd like

As has been discussed in the Lix-Development channel somewhen, ruff should be added as a linter.
It supports pre-commit hooks, which should be enabled as well.
The style configuration can be added to the pyproject.toml

I would suggest having all configuration options enabled and clearly set to avoid discussions and differentiating code-styles in the future

Describe alternatives you've considered

black has also been suggested, but disregarded in advantage of ruff, as the latter is faster and a drop-in replacement for black

Additional context

ruff has also been mentioned in the wiki as to be added at a later point in time

My intention for this issue is for it to be a discussion point for which style guides to use and to keep track of who is currently working on the implementation

## Is your feature request related to a problem? Please describe. Currently there is no linting or anything else denoting common code styling for functional2 tests. Hence, there is also no pre-commit/mr check if the guidelines are followed ## Describe the solution you'd like As has been discussed in the Lix-Development channel somewhen, `ruff` should be added as a linter. It supports pre-commit hooks, which should be enabled as well. The style configuration can be added to the pyproject.toml I would suggest having all configuration options enabled and clearly set to avoid discussions and differentiating code-styles in the future ## Describe alternatives you've considered `black` has also been suggested, but disregarded in advantage of `ruff`, as the latter is faster and a drop-in replacement for `black` ## Additional context ruff has also been mentioned in the [wiki](https://wiki.lix.systems/books/lix-contributors/page/code#bkmrk-python) as to be added at a later point in time My intention for this issue is for it to be a discussion point for which style guides to use and to keep track of who is currently working on the implementation
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/3085 ("functional2: Added ruff formatter")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/3085", "number": 3085, "kind": "commit message"}], "cl_meta": {"3085": {"change_title": "functional2: Added ruff formatter"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/3085](https://gerrit.lix.systems/c/lix/+/3085) ("functional2: Added ruff formatter")
Author
Member

should ruff be scoped to only run on functional2 or be scoped to include all python files within lix?

should ruff be scoped to only run on functional2 or be scoped to include all python files within lix?
Owner

Eventually having more linting is definitely a good thing, and I'm in favour, but starting with functional2 is a great idea as it'll let us make incremental progress.

Eventually having more linting is definitely a good thing, and I'm in favour, but starting with functional2 is a great idea as it'll let us make incremental progress.
Author
Member

i definitely see the point, but if you check out the pr (the pre-commit stuff) it does introduce some imo hacky stuff

i definitely see the point, but if you check out the pr (the [pre-commit stuff](https://gerrit.lix.systems/c/lix/+/3085/4/misc/pre-commit.nix#122)) it does introduce some imo hacky stuff
Owner

That's totally okay for now.

That's totally okay for now.
Member

Love linting, love pre-commit hooks. I'll check out the CL later and try my best to review.

Open Q: can Ruff be beat into working with Xonsh, or is it completely impossible? It might give us clues as to where to go long-term (like maybe massively shrinking Xonsh code size in favor of pure Python).

Love linting, love pre-commit hooks. I'll check out the CL later and try my best to review. Open Q: can Ruff be beat into working with Xonsh, or is it completely impossible? It might give us clues as to where to go long-term (like maybe massively shrinking Xonsh code size in favor of pure Python).
Owner

@kfearsoff wrote in #812 (comment):

Open Q: can Ruff be beat into working with Xonsh, or is it completely impossible? It might give us clues as to where to go long-term (like maybe massively shrinking Xonsh code size in favor of pure Python).

It doesn't matter much, there's nearly zero logic in xonsh files today, so a linter doesn't achieve very much. Trying to get it working on xonsh doesn't seem like a particularly important job for that reason imo.

@kfearsoff wrote in https://git.lix.systems/lix-project/lix/issues/812#issuecomment-10578: > Open Q: can Ruff be beat into working with Xonsh, or is it completely impossible? It might give us clues as to where to go long-term (like maybe massively shrinking Xonsh code size in favor of pure Python). It doesn't matter much, there's nearly zero logic in xonsh files today, so a linter doesn't achieve very much. Trying to get it working on xonsh doesn't seem like a particularly important job for that reason imo.
Author
Member

About the docstrings:
as of rn, pydoclint doesn't support sphinx docs yet; a pr is open though (last interaction in september 2024)
supported styles are google, numpy and pep275

should we move to one of those or wait until sphinx is supported?
personally i am not a fan of the other docstring styles.

About the docstrings: as of rn, pydoclint doesn't support sphinx docs yet; a pr is open though (last interaction in september 2024) supported styles are google, numpy and pep275 should we move to one of those or wait until sphinx is supported? personally i am not a fan of the other docstring styles.
Author
Member

continuing on that, while pydoclint itself supports sphinx styling, the ruff implementation doesn't yet (see https://github.com/astral-sh/ruff/issues/12434)

continuing on that, while pydoclint itself supports sphinx styling, the ruff implementation doesn't yet (see https://github.com/astral-sh/ruff/issues/12434)
Owner

goofy! can we ignore the problem for now? it seems plausible that we could just not lint doc strings until they invent a linter that supports them; it's not like sphinx doc strings are a rare use case.

goofy! can we ignore the problem for now? it seems plausible that we could just not lint doc strings until they invent a linter that supports them; it's not like sphinx doc strings are a rare use case.
Author
Member

Either that or go with google style

Either that or go with google style
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#812
No description provided.