nomad-coe / electronic-parsers

Apache License 2.0
18 stars 7 forks source link

Ruff format code #199

Closed ndaelman-hu closed 4 months ago

ndaelman-hu commented 4 months ago

I ended up formatting all the electronic parsers using ruff format .. Local tests and mpy all run fine.

ladinesa commented 4 months ago

pls merge if tests pass

ondracka commented 4 months ago

Just wondering if this is something that should be enforced (or even done automatically) as part of the pre-merge testing? So that the formatting doesn't deteriorate over time when people that don't normally use ruff (like me) contribute...

ndaelman-hu commented 4 months ago

Maybe @ladinesa or @markus1978 can comment.

To my understanding: Ruff is now the official linter in NOMAD. It is set in the pytoml file, and some IDEs will then see to apply it. If you check the CI/CD, you'll see that there's a ruff check too.

Anyhow, sorry for the huge reformat without any prior announcement. Normally, you can just rebase. Let us know if you need any help setting up Ruff.

ondracka commented 4 months ago

My bad, now I see ruff is already part of the pipeline.

ondracka commented 4 months ago

Well, actually what is the ruff CI job doing? Because I see it was for example already run for the small openmx parser improvement I merged last week and there it passed: https://github.com/nomad-coe/electronic-parsers/actions/runs/7917707267/job/21614400900 even though the same code got reformatted now in this pull request. I'm completely OK with NOMAD enforcing ruff (and its obviously my bad for not noticing it and also for sticking with vim instead of using proper IDE :) just saying that I would expect to get a test failure if I try to merge something that is not OK in this regard.

ladinesa commented 4 months ago

It is simpy checking the specified linting config in pyproject.toml, you might pass this whilst not having an ideal ruff format. ruff should autoformat your file when you save or file or directly running ruff format.

ndaelman-hu commented 4 months ago

its obviously my bad for not noticing it and also for sticking with vim instead of using proper IDE :)

I used to program with VIM all the time. Tbh, VSCode is really a step up and has loads of nice plugins. The memory consumption is okay, the only pain is setting up the debugger by times.

Since we use it a lot in NOMAD, we can lend you a hand if you have any questions there. Just post your questions on Discord: https://discord.gg/q9bg7DD6