mesh-adaptation / goalie

Goal-oriented error estimation and mesh adaptation for finite element problems solved using Firedrake
Other
1 stars 1 forks source link

Pre-commit for sorting imports #162

Closed jwallwork23 closed 2 months ago

jwallwork23 commented 2 months ago
          @jwallwork23 I saw now that `.utility` is separated from other relative imports. And imports are a bit disordered in general. 

Perhaps we should (in a separate issue) organise imports manually or e.g. add isort to pre-commit?

_Originally posted by @ddundo in https://github.com/mesh-adaptation/goalie/pull/161#discussion_r1564863797_

ddundo commented 2 months ago

I've never done this before so I googled today. It seems like the best practice is to use ruff (https://github.com/astral-sh/ruff), and enable black, flake8 and isort through it, as it is 10-100x faster according to their github. This would all be set in pyproject, so it fits in well with your recent pull requests that expand pyproject. Then we could incorporate the settings that we have in .flake8 too.

What do you think @jwallwork23? If you agree with this I will wait for #155 to get merged and do this. Otherwise I can just add isort to the pre-commit config file and leave the rest as it is.

jwallwork23 commented 2 months ago

@ddundo Thanks for looking into this. I've heard people talk about ruff but haven't used it myself. I guess if it allows us to put all the config into the pyproject.toml file then that sounds like a good way to go!

Note that rather than waiting you could alternatively open a PR whose target branch is 148_pyproject (the one associated with #155) rather than main. Up to you, I don't mind which order they happen.

ddundo commented 2 months ago

Note that rather than waiting you could alternatively open a PR whose target branch is 148_pyproject (the one associated with #155) rather than main. Up to you, I don't mind which order they happen.

Makes sense! I just did that :)

ddundo commented 2 months ago

Completed in #155.