Skip to content

Automatic formatting.#481

Draft
albu-diku wants to merge 2 commits intonextfrom
addition/automatic-formatting
Draft

Automatic formatting.#481
albu-diku wants to merge 2 commits intonextfrom
addition/automatic-formatting

Conversation

@albu-diku
Copy link
Contributor

Integrate black into the Makefile replacing previous autopep8 attempt.

We are currently trying to have consistent formatting in the codebase but
here is currently no standardised way to do this. Based on some growing
consensus bring in black and switch local formatting and linting to it.

A new `make fmt` target will format files with the appropriate style. The
`make lint` target (broken/unused) invokes the same but in checking mode
and thus will report violations.

Given we are likely to adopt this in stages we define a variable in the
Makefile listing the directories we wish to enforce cleanliness for.

@jonasbardino jonasbardino added the refactor Non-functional changes to simplify or clean up label Mar 11, 2026
PY = 3
endif

FORMAT_ENFORCE_DIRS = ./mig/lib ./tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to include ./bin and ./sbin here in line with https://github.com/ucphhpc/migrid-sync/milestone/7 . Not sure it causes troubles with the out-of-dir symlinks being too 'greedy', though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, wasn't sure exactly how far we'd go here so so went for the places I was positive of for a first draft - will attempt that fuller list.

@echo "'make unittest' - execute tests locally for development"

.PHONY: fmt
fmt:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick and late to the party: I don't think the three letter abbreviation fmt is all that obvious or unambiguous, so I'd suggest we at least alias it as formatcode or codestyle. I don't mind doing so myself as follow-up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh ok - it was borrowed from the go command line and rust picked up the same terminology as well, so bit of a familiar to the wider ecosystem intended. Will add an alias.

Copy link
Contributor

@jonasbardino jonasbardino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far.
I would really like to also have isort included as black screws with all our imports and adding it later will give another round of significant diffs.

While it's nice to see the results being sane I'm slightly uncertain if we actually want to merge with the fmt target applied in the same PR, and more so if isort is not included.
What do you think?

Just to clarify I'll gladly help adding isort to the mix unless you prefer to do that yourself.
https://github.com/ucphhpc/migrid-sync/tree/addition/automatic-formatting-plus-isort
has my simple attempt to do so.

jonasbardino added a commit that referenced this pull request Mar 11, 2026
…elation to

vindicating the style changes in PR #481.
@jonasbardino
Copy link
Contributor

The lint errors are not new as seen in
#482
so they are not show stoppers.

@albu-diku
Copy link
Contributor Author

Looks good so far. I would really like to also have isort included as black screws with all our imports and adding it later will give another round of significant diffs.

While it's nice to see the results being sane I'm slightly uncertain if we actually want to merge with the fmt target applied in the same PR, and more so if isort is not included. What do you think?

Just to clarify I'll gladly help adding isort to the mix unless you prefer to do that yourself. https://github.com/ucphhpc/migrid-sync/tree/addition/automatic-formatting-plus-isort has my simple attempt to do so.

Happy to add isort too and make it part of this - kept it to this initially only as a caution to do only what we want (although only in one portion of the tree so perhaps less an issue).

Yah, my sense is it comes down to what level of assurance we as part of this really. On the one hand, we’re using extremely robust tools for all this so there’s no particular concern on my part about how much we include. So perhaps it’s more, do we see any value in going in stages or would it be preferable to change logic files to how we want in one go.

The advantage we have with this branch is it’ll let us see the results of tweaks. Let’s try i sort and see where we land - and perhaps the import thing mentioned earlier is another candidate modulo consensus.

jonasbardino added a commit that referenced this pull request Mar 12, 2026
* Initially just triggered existing lint errors for wsgisupp in relation to vindicating
 the style changes in PR #481.

* Fix lint errors by retiring legacy PY2 imports and add missing self arg to the
`_errors` class `close` method.
Add missing a couple of docstrings while at it and adjust imports slightly.
We are currently trying to have consistent formatting in the codebase but
here is currently no standardised way to do this. Based on some growing
consensus bring in black and switch local formatting and linting to it.

A new `make fmt` target will format files with the appropriate style. The
`make lint` target (broken/unused) invokes the same but in checking mode
and thus will report violations.

Given we are likely to adopt this in stages we define a variable in the
Makefile listing the directories we wish to enforce cleanliness for.
@albu-diku albu-diku force-pushed the addition/automatic-formatting branch from 98ee6b2 to e1f0355 Compare March 14, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Non-functional changes to simplify or clean up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants