Skip to content

Latest commit

 

History

History
63 lines (36 loc) · 2.42 KB

code_standard_and_dev_guide.rst

File metadata and controls

63 lines (36 loc) · 2.42 KB

Code Standard

Docstring

Please use the Numpydoc Style.

Continuous Integration

Continuous Integration (CI) tools help you stick to the quality standards by running tests every time you push a new commit and reporting the results to a pull request.

When you submit a PR request, you can check whether your code passes the CI tests in the "check" section at the bottom of the web page.

  1. Qlib will check the code format with black. The PR will raise error if your code does not align to the standard of Qlib(e.g. a common error is the mixed use of space and tab).

    You can fix the bug by inputting the following code in the command line.

pip install black
python -m black . -l 120
  1. Qlib will check your code style pylint. The checking command is implemented in [github action workflow](
    pylint --disable=C0104,C0114,C0115,C0116,C0301,C0302,C0411,C0413,C1802,R0201,R0401,R0801,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R1720,W0105,W0123,W0201,W0511,W0613,W1113,W1514,E0401,E1121,C0103,C0209,R0402,R1705,R1710,R1725,R1735,W0102,W0212,W0221,W0223,W0231,W0237,W0612,W0621,W0622,W0703,W1309,E1102,E1136 --const-rgx='[a-z_][a-z0-9_]{2,30}$' qlib --init-hook "import astroid; astroid.context.InferenceContext.max_inferred = 500"
    ). Sometime pylint's restrictions are not that reasonable. You can ignore specific errors like this
return -ICLoss()(pred, target, index)  # pylint: disable=E1130
  1. Qlib will check your code style flake8. The checking command is implemented in [github action workflow](

    ).

    You can fix the bug by inputing the following code in the command line.

flake8 --ignore E501,F541,E402,F401,W503,E741,E266,E203,E302,E731,E262,F523,F821,F811,F841,E713,E265,W291,E712,E722,W293 qlib
  1. Qlib has integrated pre-commit, which will make it easier for developers to format their code.

    Just run the following two commands, and the code will be automatically formatted using black and flake8 when the git commit command is executed.

pip install -e .[dev]
pre-commit install

Development Guidance

As a developer, you often want make changes to Qlib and hope it would reflect directly in your environment without reinstalling it. You can install Qlib in editable mode with following command. The [dev] option will help you to install some related packages when developing Qlib (e.g. pytest, sphinx)

pip install -e ".[dev]"