Follow the code style¶
We use the following tools to make the code style to be as consistent as possible:
The following versions of the above tools are used:
black == 12.6b0
flake8 == 3.9.2
isort == 5.9.2
After running the following commands:
$ git clone https://github.com/k2-fsa/icefall $ cd icefall $ pip install pre-commit $ pre-commit install
it will run the following checks whenever you run git commit, automatically:
![]()
Fig. 4 pre-commit hooks invoked by
git commit(Failed).¶
If any of the above checks failed, your git commit was not successful.
Please fix any issues reported by the check tools.
Hint
Some of the check tools, i.e., black and isort will modify
the files to be commited in-place. So please run git status
after failure to see which file has been modified by the tools
before you make any further changes.
After fixing all the failures, run git commit again and
it should succeed this time:
![]()
Fig. 5 pre-commit hooks invoked by
git commit(Succeeded).¶
If you want to check the style of your code before git commit, you
can do the following:
$ cd icefall $ pip install black==21.6b0 flake8==3.9.2 isort==5.9.2 $ black --check your_changed_file.py $ black your_changed_file.py # modify it in-place $ $ flake8 your_changed_file.py $ $ isort --check your_changed_file.py # modify it in-place $ isort your_changed_file.py

