The following lines should be included in The pyproject.toml file to indicate the configuration of the different code and documentation style tools.
[tool.black] line-length = "<length>" [tool.isort] profile = "black" force_sort_within_sections = true line_length = "<length>" default_section = "THIRDPARTY" src_paths = ["doc", "src", "tests"] [tool.coverage.run] source = ["ansys.<product>"] [tool.coverage.report] show_missing = true [tool.pytest.ini_options] addopts = "--doctest-modules" [tool.pydocstyle] convention = "numpy"
.flake8 file is also required:
[flake8] max-line-length = 88 extend-ignore = 'E203'
You can take advantage of Pre-commit by including a
.pre-commit-config.yaml file like this one in your project:
repos: - repo: https://github.com/psf/black rev: X.Y.Z hooks: - id: black - repo: https://github.com/pycqa/isort rev: X.Y.Z hooks: - id: isort - repo: https://github.com/PyCQA/flake8 rev: X.Y.Z hooks: - id: flake8 - repo: https://github.com/codespell-project/codespell rev: vX.Y.Z hooks: - id: codespell - repo: https://github.com/pycqa/pydocstyle rev: X.Y.Z hooks: - id: pydocstyle additional_dependencies: [toml] exclude: "tests/"
GitHub CI/CD integration#
Finally, you can Test using GitHub Actions and
style.yml workflow file in
name: Style on: pull_request: push: tags: - "*" branches: - main jobs: style: name: Code & Doc runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install requirements run: | python -m pip install -U pip pre-commit - name: Run pre-commit run: | pre-commit run --all-files --show-diff-on-failure