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

Move to pyproject.toml from setup.{py/cfg} and add a minimal ruff linter/formatter #526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MridulS
Copy link

@MridulS MridulS commented Feb 20, 2024

I started working on #155 and I thought it would be helpful to clean up this repo a bit before.

I have moved around a bunch of stuff in this PR, let me know if it makes easier to review if I break this up in smaller pull requests :)

  • moved all the config from setup.cfg to pyproject.toml
  • Removed setup.py, moved the version handling to setuptools_scm through pyproject.toml
  • Add a ruff linter and formatter to pre-commit to bring the linting in this repo up to date with astropy/astropy

I hope I didn't break anything here 😅

python -m build was able to build a wheel successfully and I was able to run pytest with no failures.

I have not run the ruff linter yet! Once we have a positive review I can run the pre-commit bits to format the code (didn't want to pollute the diff too much).

@MridulS
Copy link
Author

MridulS commented Feb 20, 2024

Another thing is that I have removed the coverage, flake8, pycodestyle specific configuration. I can add them back but I am not a 100% it makes sense to keep this along the pre-commit ruff action :)

@bsipocz
Copy link
Member

bsipocz commented Feb 20, 2024

Add a ruff linter and formatter to pre-commit to bring the linting in this repo up to date with astropy/astropy

Please no, we are talking about turning off more formatting stuff than we already have and this goes the opposite direction. But I let @msdemlei to chime in, too.

@MridulS
Copy link
Author

MridulS commented Feb 21, 2024

Please no, we are talking about turning off more formatting stuff than we already have and this goes the opposite direction. But I let @msdemlei to chime in, too.

No worries, we don't have to add more linters :)

Is consolidating everything in pyproject.toml okay? I think it really helps to have everything in one place as a single source of truth.

@msdemlei
Copy link
Contributor

msdemlei commented Feb 21, 2024 via email

@ManonMarchand
Copy link
Member

ManonMarchand commented Mar 20, 2025

I had a look at it, and the ruff reformatting touches ~6k lines like this. With a bit of rules selections (not forcing the strings to be double quoted was the most important gain), I could get down to ~3k lines diff.
Most of the changes made sense, but there is still one annoying behavior that I couldn't disable which was to write only one item per line for iterables.

Ex:

 __all__ = [
-    "parse_tables", "parse_capabilities", "parse_availability",
-    "TablesFile", "CapabilitiesFile", "AvailabilityFile"]
+    "parse_tables",
+    "parse_capabilities",
+    "parse_availability",
+    "TablesFile",
+    "CapabilitiesFile",
+    "AvailabilityFile",
+]

See the open issue astral-sh/ruff#11886 in Ruff. The only way to disable it in the formatting for now is to add a fmt: skip comment for every affected line, but we have A LOT of occurrences.

My take on this would be to drop the Ruff formatting from this PR until this issue is solved.

We could still add the existing codestyle check to a pre-commit hook if everyone agrees.

@msdemlei
Copy link
Contributor

msdemlei commented Mar 20, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants