Repository: Lightning-AI/pytorch-lightning

Issue:
Use `black` for autoformatting
[`black`](https://github.com/python/black) has become popular enough for
Python formatting that it was officially adopted by the PSF, and is
being used to format the standard library. I like it because it makes
code that's very consistent to read, which makes development ever so
slightly easier for everyone.

In case this PR is desired but the actual formatting changes interfere
with other current branches, I can rebase to leave out the actual
formatting for now.


Discussion:
thanks for the PR. 

2 things: 
1. does this conflict with pep8? we already have that coming in a different PR. 
2. make sure to submit proposals and that we both agree on the improvement before adding any future PRs. that way we can deconflict and align with the project goals. 

but nevertheless, thanks for contributing! 
if we do bring this in, let's use single quotes not double quotes.

@alok also, please resolve the conflicts first.
Yeah normally I'd discuss first but this was a really quick PR since I've set it up for other projects before. Black is a stricter subset of pep 8 that's meant to make reading diffs as easy as possible. It's not the prettiest style, but like gofmt, is meant to eliminate pointless style debates.

The tool doesn't use single quotes on purpose and it has some reasoning on its readme, but FWIW you can use any quote style you want and it'll change it at the end.
If you look at it and decide you want it, let me know and I'll rebase. 
you can run black with the parameter `-S` which should hold whatever ' or " you have
and black is just another PEP8 formatting utility, but in particular, it adds something extra like splitting lines (which personally I do not like very much)
@alok thanks for this but we're going to pass at the moment. In the future get a verbal ok from me so we both agree on a new feature.

We're done adding formatting and engineering "best practices" to the package. @Borda has already added the last few missing pieces for better test coverage and package stability. From here forward let's focus on feature or speed improvements in the package. 
In [CONTRIBUTING.md](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/.github/CONTRIBUTING.md), you say to lint the code with `flake8`. But you don't say anything about Python formatting tools such as `black`, `autopep8` or `yapf`?

It would be nice to agree on one so it's easy to format the code the same way for everyone when contributing to the project. I also found I save time when developing using such a tool.

I personally like `black` because it has no configuration and works just well. I would be fine configuring my IDE to use another one for this project. But that would be nice if you guys can decide on one.

(I can also open a new issue if needed)
We have been using `black` in a company and personally don't line some splitting lines which makes too long and harder to navigate... On the other hand it make sense to relay on some tool so I will check `autopep8` and `yarf` :) 
> Black is formatting the code similar to autopep8 but is moving the closing brackets to a new line and also does not format the tuple in an unnecessary way. Yapf with the Facebook setting is formatting very similar to black here but is not changing the quotes here again. The only difference which happened

https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505

Resolving patch:
diff --git a/pytorch_lightning/loggers/comet.py b/pytorch_lightning/loggers/comet.py
--- a/pytorch_lightning/loggers/comet.py
+++ b/pytorch_lightning/loggers/comet.py
@@ -31,6 +31,7 @@ class CometLogger(LightningLoggerBase):
     r"""
     Log using `comet.ml <https://www.comet.ml>`_.
     """
+
     def __init__(self, api_key=None, save_dir=None, workspace=None,
                  rest_api_key=None, project_name=None, experiment_name=None, **kwargs):
         r"""
diff --git a/pytorch_lightning/loggers/neptune.py b/pytorch_lightning/loggers/neptune.py
--- a/pytorch_lightning/loggers/neptune.py
+++ b/pytorch_lightning/loggers/neptune.py
@@ -27,6 +27,7 @@ class NeptuneLogger(LightningLoggerBase):
     Neptune logger can be used in the online mode or offline (silent) mode.
     To log experiment data in online mode, NeptuneLogger requries an API key:
     """
+
     def __init__(self, api_key=None, project_name=None, offline_mode=False,
                  experiment_name=None, upload_source_files=None,
                  params=None, properties=None, tags=None, **kwargs):
diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py
--- a/pytorch_lightning/trainer/trainer.py
+++ b/pytorch_lightning/trainer/trainer.py
@@ -862,7 +862,7 @@ def run_pretrain_routine(self, model):
 
         # check if we should run validation during training
         self.disable_validation = ((self.num_val_batches == 0 or
-                                   not self.is_overriden('validation_step')) and
+                                    not self.is_overriden('validation_step')) and
                                    not self.fast_dev_run)
 
         # run tiny validation (if validation defined)


Test patch:
diff --git a/tests/requirements.txt b/tests/requirements.txt
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -4,6 +4,7 @@ coverage
 codecov
 pytest>=3.0.5
 pytest-cov
+pytest-flake8
 flake8
 check-manifest
 test-tube>=0.7.5