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

Add: make target to run black-formatter as it is used in PR checks. #174

Merged
merged 1 commit into from
Dec 5, 2020

Conversation

frosch123
Copy link
Member

I don't know how you invoke black. But there are quite some custom options for NML.

@FLHerne
Copy link
Contributor

FLHerne commented Dec 5, 2020

Comment as on IRC:

This should probably also add a --check run of black, and flake8, to make test.

Potentially we could then drop black and flake8 as separate GitHub actions because the main testing would run them, but then we'd lose inline notes from TrueBrain's action.

@frosch123
Copy link
Member Author

I added them to "make test".
But now "make test" depends on "flake8" and "black" being installed.

@FLHerne
Copy link
Contributor

FLHerne commented Dec 5, 2020

I don't think that's an issue really; black at least you pretty much need to make any significant changes without upsetting the commit-checker.

Perhaps the people building distro packages will mind?

In principle we could have a test script that checks whether they're installed and warns but succeeds otherwise, but that seems TMWFTLB.

Makefile Outdated Show resolved Hide resolved
@FLHerne
Copy link
Contributor

FLHerne commented Dec 5, 2020

I guess this should add black and flake8 to "Optional Dependencies" of README.md.

@frosch123 frosch123 force-pushed the makeitblack branch 2 times, most recently from 4dc091a to a33fc33 Compare December 5, 2020 17:27
README.md Outdated Show resolved Hide resolved
@LordAro
Copy link
Member

LordAro commented Dec 5, 2020

Not sure I like this being rolled into the make test rule. A separate "check" rule, perhaps?

@@ -1,11 +1,13 @@
MAKE?=make
PYTHON?=/usr/bin/env python3
BLACK_OPTIONS=-l 120 --exclude 'action2var_variables.py|action3_callbacks.py|generated'
Copy link
Member

Choose a reason for hiding this comment

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

if you like, black options can also be put in pyproject.toml, see https://black.readthedocs.io/en/stable/pyproject_toml.html .
This makes sure that if someone executed black, it picks up the right rules too.
I have yet to apply this for all other OpenTTD projects :)

Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

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

I think such quality of life improvements are always a good thing. You cannot execute tests often enough.

@@ -15,3 +17,10 @@ extensions:

clean:
$(MAKE) -C regression clean

flake:
Copy link
Member

Choose a reason for hiding this comment

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

My OCD cannot handle that make flake also executes black .. but using any other name is silly :P

@TrueBrain
Copy link
Member

Not sure I like this being rolled into the make test rule. A separate "check" rule, perhaps?

As much as a regression shows a runtime error, flake shows possible runtime errors. One can debate if black is really a test, but flake for sure is. And with having flake under make test, you might as well add black too, as .. why not! :D

@frosch123
Copy link
Member Author

Conclusion: noone likes pyproject.toml

@frosch123 frosch123 merged commit 3802579 into OpenTTD:master Dec 5, 2020
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.

None yet

4 participants