xgboost/tests/ci_build/test_utils.py
Jiaming Yuan 8bdea72688
[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.
2022-07-20 10:25:24 +08:00

15 lines
331 B
Python

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)