Skip to content

Commit

Permalink
🔧 CI: added black, ruff and docs (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubmarco committed Aug 23, 2023
1 parent e04d7a8 commit 0a54043
Show file tree
Hide file tree
Showing 18 changed files with 1,285 additions and 757 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/format_lint_docs.yml
@@ -0,0 +1,35 @@
name: format, lint, docs
on: [pull_request]

jobs:
format_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python -m pip install poetry
poetry install -E dev
- name: Check black formatting
run: poetry run black --check --diff --config pyproject.toml sphinx_performance
- name: Check ruff linting
run: poetry run ruff check sphinx_performance
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python docs dependencies
run: |
python -m pip install poetry
poetry install -E docs
- name: Check docs build
working-directory: ./docs
run: poetry run sphinx-build -b html . _build/html -W
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -26,6 +26,7 @@ docs/_images/need_pie_*.png
.devcontainer/
.vscode/*
!.vscode/*.template.json
!.vscode/extensions.json
.dockerignore

need_bar_*.png
Expand Down
5 changes: 4 additions & 1 deletion .readthedocs.yml
Expand Up @@ -6,8 +6,11 @@ sphinx:
python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs

sphinx:
builder: html
fail_on_warning: true
12 changes: 12 additions & 0 deletions .vscode/extensions.json
@@ -0,0 +1,12 @@
{
"recommendations": [
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"lextudio.restructuredtext",
"ms-python.black-formatter",
"ms-python.python",
"tamasfe.even-better-toml",
"trond-snekvik.simple-rst"
]
}

17 changes: 17 additions & 0 deletions .vscode/settings.template.json
@@ -0,0 +1,17 @@
{
"black-formatter.args": ["--config", "${workspaceFolder}/pyproject.toml"],
"black-formatter.path": ["${workspaceFolder}/.venv/bin/black"],
"editor.formatOnSave": true,
"editor.rulers": [88],
"python.formatting.provider": "none",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
}
2 changes: 0 additions & 2 deletions docs/requirements.txt

This file was deleted.

930 changes: 539 additions & 391 deletions poetry.lock

Large diffs are not rendered by default.

107 changes: 83 additions & 24 deletions pyproject.toml
Expand Up @@ -7,43 +7,102 @@ license = "MIT"
readme = "README.rst"
repository = "https://github.com/useblocks/sphinx-performance"
documentation = "https://sphinx-performance.readthedocs.io/en/latest/"
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Documentation',
'Topic :: Utilities',
'Framework :: Sphinx',
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Documentation',
'Topic :: Utilities',
'Framework :: Sphinx',
]

[tool.poetry.dependencies]
python = "^3.7.0"
python = ">=3.8,<4"
click = "^8.0.3"
rich = "^11.2.0"
Jinja2 = "^3.0.3"
memray = "^1.3.1"
sphinx = "^5.3.0"
pyinstrument = "^4.3.0"
rich = "^11.2.0"
snakeviz = "^2.1.1"
sphinx = "^5.3.0"
# docs and dev dependencies
sphinxcontrib-programoutput = { version = "^0.17", optional = true }
black = { version = "^23.7.0", optional = true }
ruff = { version = "^0.0.285", optional = true }

[tool.poetry.dev-dependencies]
[tool.poetry.extras]
docs = ["sphinxcontrib-programoutput"]
dev = ["black", "ruff"]
all = ["black", "ruff", "sphinxcontrib-programoutput"]

[tool.poetry.scripts]
sphinx-performance = 'sphinx_performance.performance:cli_performance'
sphinx-analysis = 'sphinx_performance.analysis:cli_analysis'
sphinx-performance = 'sphinx_performance.performance:cli_performance'

[tool.poetry.extras]
docs = ["sphinx"]
[tool.ruff]
select = ["ALL"] # Enable all checks and maintain an ignore list
# a lot of ignores here due to activation of ruff linting in an established project
# candidates for reactivation are marked with a star
ignore = [
"ANN001", # missing-type-function-argument *
"ANN003", # missing-type-kwargs *
"ANN101", # missing-type-self
"ANN201", # missing-return-type-undocumented-public-function *
"ANN202", # missing-return-type-private-function *
"B905", # zip-without-explicit-strict *
"C901", # complex-structure *
"D100", # undocumented-public-module *
"D101", # undocumented-public-class *
"D102", # undocumented-public-method *
"D107", # no docstring needed for __init__
"D203", # D203 and D211 are mutually exclusive: https://github.com/PyCQA/pydocstyle/issues/141
"D212", # D212 and D213 are mutually exclusive: https://stackoverflow.com/a/45990465
"FBT002", # boolean-default-value-positional-argument *
"PERF401", # manual-list-comprehension *
"PLR0912", # too-many-branches *
"PLR0913", # too-many-arguments *
"PLR0915", # too-many-statements *
"PLW0603", # global-statement *
"PLW1510", # subprocess-run-without-check *
"S603", # subprocess-without-shell-equals-true *
"S607", # start-process-with-partial-path *
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
# unfixable = []

# a bit longer than black for e.g. long docstrings that black did not shorten
line-length = 100

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# lint against oldest supported Python version
target-version = "py38"

[tool.ruff.pydocstyle]
convention = "pep257"

[tool.ruff.mccabe]
max-complexity = 20

[tool.ruff.per-file-ignores]
"sphinx_performance/projects/basic/performance.py" = ["INP001"] # template dir
"sphinx_performance/projects/needs/performance.py" = ["INP001"] # template dir
"sphinx_performance/projects/theme/performance.py" = ["INP001"] # template dir

[tool.black]
target-version = ["py38"]
preview = true

[build-system]
requires = ["poetry_core>=1"]
build-backend = "poetry.core.masonry.api"

2 changes: 1 addition & 1 deletion sphinx_performance/__init__.py
@@ -1 +1 @@

"""Make sphinx_performance a package."""

0 comments on commit 0a54043

Please sign in to comment.