freqtrade icon indicating copy to clipboard operation
freqtrade copied to clipboard

use black as formatter

Open orehunt opened this issue 4 years ago • 13 comments

What's your stance on using black as formatter for the project? It doesn't respect a couple of flake8 rules, ignore = F403, F405, W503, E203, E231 And the thing that might annoy someone is that if a sequence of tokens doesn't fit inlineit gets fully split vertically

orehunt avatar May 18 '20 12:05 orehunt

I remember we've been discussing it with @xmatthias , I do not have any objections against it.

hroff-1902 avatar May 18 '20 12:05 hroff-1902

i do like the idea of black beeing a "no compromise" formatter - as we can just run it and there's no discussion as to "let's format this that way".

I am however sceptical on introducing it "in one rush" in a project this size.

I did try to use it for freqtrade about a year ago - but it does a large amount of changes to the simplest files i wasn't comfortable it wouln't accidentally introduce bugs (it'll be impossible to review as every other line is changed...).

Now that said - i think black has matured (it was pretty fresh back then) - so i think the probability of it introducing bugs is pretty low - so i'm not against it.


There is another caveat though - i'd like to keep the 100 character line limit (80 is too small in my opinion) - and to configure black for that, we MUST use a pyproject.toml file. The problem with adding this file is that pip tends to freak out if it's present but not the method to install (or at least it was a few pip versions ago)- so i think we'll need to change the installation method to pyproject.toml first (*unless pip now handles this correctly).

xmatthias avatar May 18 '20 17:05 xmatthias

"i'd like to keep the 100 character line limit" -- sure, this should be kept in any case, by configuring the formatter accordingle when (and if) one will be used.

hroff-1902 avatar May 18 '20 17:05 hroff-1902

Additional point - if we're to use black - we should also consider using pre-commit - it can be configured to run black right before commiting - which should avoid commits like "make flake happy" - or "fix flake" ...

xmatthias avatar Jun 27 '20 18:06 xmatthias

Additional point - if we're to use black - we should also consider using pre-commit - it can be configured to run black right before commiting - which should avoid commits like "make flake happy" - or "fix flake" ...

no problem for me...

hroff-1902 avatar Jun 28 '20 00:06 hroff-1902

Can I look up an IMEI number and get info

JessieJamesH avatar Sep 05 '21 11:09 JessieJamesH

I'd like to do this right after the feat/short branch gets merged

samgermain avatar Jan 19 '22 02:01 samgermain

tbh, i don't see any rush with this - and think that "right after it's merged" is a bad idea. doing a "black" step will change many files, making the tracking of changes difficult as many lines will have "black" against it's changes.

Maybe 1-2 months after that.

xmatthias avatar Jan 19 '22 06:01 xmatthias

making the tracking of changes difficult

Even with this?

SmartManoj avatar Apr 09 '22 02:04 SmartManoj

Does github natively support it? no. Therefore - give it 1-2 months minumum, then i'll look into this (i'll not accept PR's for this - but will do this change myself once the time is right as reviewing such a change would take more time than doing the actual change).

xmatthias avatar Apr 09 '22 06:04 xmatthias

Does github natively support it? no.

Yes.

Source

SmartManoj avatar May 08 '22 08:05 SmartManoj

Sounds like the managing of technical debt is a bit in the way of moving this forward? How about reviewing sections of the codebase and getting them to be as Black wants it to be, instead of using a commit hook? Personally I'm not too fond of pre-commit hooks that modify files underneath my feet 😬 Also, implementing other linters such as https://github.com/charliermarsh/ruff might make it easier to manage? Or an overview in a static analysis tool such as Sonar?

wkoot avatar Feb 07 '23 09:02 wkoot

Don't see how this comment is related to this issue, really. everyone is free to not install pre-commit hooks if they don't like them. Which hooks run is a different topic entirely. We run the same checks in CI - so if the code in a PR doesn't correspond to the guidelines currently applied, CI will fail - which implicitly asks for a change. If you didn't run the pre-commit hook - it'll be an additional roundtrip - but it's not really relevant either.

changing to black will change every python file in the project. I've got a huge change in a parallel PR (not yet a PR) which is about 80-90% ready (but it's kinda stuck as i'm tight on time). I'm however not ready to invest the time twice - once to update to black (ensuring it'll break nothing) - and then trying to merge that on top of that pr PR - which is changing at least half of the python files in the repository.

There's no rush to it - and nobody's profits will improve by having a different code style applied - therefore i also treat this as very low priority.

xmatthias avatar Feb 07 '23 10:02 xmatthias