frankkramer-lab / aucmedi

a framework for Automated Classification of Medical Images
https://frankkramer-lab.github.io/aucmedi/
GNU General Public License v3.0
38 stars 13 forks source link

Introduce a python formater like black? #86

Open muellerdo opened 2 years ago

muellerdo commented 2 years ago

https://github.com/psf/black

pylint?

muellerdo commented 2 years ago

https://github.com/PyCQA/pycodestyle

pylint

DanielHieber commented 9 months ago

If this was not yet implemented, I could provide a flake8 workflow to be added to the automatic github workflows. It is quite easy to ignore specific PEP8 rules and tune the checker to your own preferences.

Could also be combined with pre-commit hooks to automatically lint the code prior to committing it, reducing the execution of failed workflows, as the style should be correct on committing to git.

https://flake8.pycqa.org/en/latest/ https://github.com/PyCQA/flake8

muellerdo commented 9 months ago

Hello @DanielHieber,

thanks for the offer! Your help & contribution would be awesome! :)

Definitely makes sense to finally add an automatic formating tool to the code & pull requests.

One thing that kept me from just including like black was two things:

#---------------------------------------------#
#                  Training                   #
#---------------------------------------------#
# Training the Neural Network model
def train(self, training_generator, validation_generator=None, epochs=20,
          iterations=None, callbacks=[], class_weights=None,
          transfer_learning=False):

This (original) beomces the following (black):

# ---------------------------------------------#
#                  Training                   #
# ---------------------------------------------#
# Training the Neural Network model
def train(
    self,
    training_generator,
    validation_generator=None,
    epochs=20,
    iterations=None,
    callbacks=[],
    class_weights=None,
    transfer_learning=False,
):

1) Commenting should be left alone, if you wanna structure some comments in code, autoformatting can be a pain 2) A very personal perspective of mine: I don't like it that the code with just a few functions now takes up a huge amount of lines. I know, it is probably a better & more intuitive representation, but I find it personally a little bit annoying to scroll more through dozens of lines just to pass a single function :X But like I said, this is personal and I can probably get used to it :D

Cheers, Dominik

DanielHieber commented 9 months ago

I see your problem. Let me see if I can find a linter that is to your liking/provides the least discomfort.