[Python] Require black and isort for new Python files. (#8096)

* [Python] Require black and isort for new Python files.

- Require black and isort for spark and dask module.

These files are relatively new and are more conform to the black formatter. We will
convert the rest of the library as we move forward.

Other libraries including dask/distributed and optuna use the same formatting style and
have a more strict standard. The black formatter is indeed quite nice, automating it can
help us unify the code style.

- Gather Python checks into a single script.
This commit is contained in:
Jiaming Yuan
2022-07-20 10:25:24 +08:00
committed by GitHub
parent f23cc92130
commit 8bdea72688
13 changed files with 226 additions and 126 deletions

View File

@@ -0,0 +1,14 @@
import os
from typing import Union
class DirectoryExcursion:
def __init__(self, path: Union[os.PathLike, str]):
self.path = path
self.curdir = os.path.normpath(os.path.abspath(os.path.curdir))
def __enter__(self):
os.chdir(self.path)
def __exit__(self, *args):
os.chdir(self.curdir)