Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ruff config for type annotations and fix a doc publishing problem #53

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/.github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Build doc with Sphinx
run: |
poetry run sphinx-build -W docs docs/_build
poetry run sphinx-build docs docs/_build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_name}}/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_name}}/noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand Down
41 changes: 26 additions & 15 deletions {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,23 @@ force-exclude = true # Apply excludes to pre-commit
show-fixes = true
src = ["src", "tests"]
target-version = "py39" # Minimum Python version supported
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
extend-exclude = [
"__pycache__",
"old",
".ipynb_checkpoints",
"noxfile.py",
"docs/conf.py",
]

# Ruff rules may be customized as desired: https://docs.astral.sh/ruff/rules/
[tool.ruff.lint]
{% if cookiecutter.code_quality_level == "High" %}
select = ["ALL"]
{% elif cookiecutter.code_quality_level == "Medium" %}
select = [
"A", # prevent using keywords that clobber python builtins
"ANN", # check type annotations
"B", # bugbear: security warnings
"D", # documentation
"E", # pycodestyle
Expand All @@ -100,40 +110,41 @@ select = [
{% endif %}
ignore = [
"ANN101", # Supress missing-type-self.
"ANN102", # Supress missing-type-cls.
"ANN202", # Don't requiere return type annotation for private functions.
"ANN401", # Allow type annotation with type Any.
"D100", # Supress undocumented-public-module. Only doc of public api required.
"E402", # Supress module-import-not-at-top-of-file, needed in jupyter notebooks.
"E501", # Supress line-too-long warnings: trust black's judgement on this one.
]
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
extend-exclude = [
"__pycache__",
"old",
".ipynb_checkpoints",
"noxfile.py",
"docs/conf.py",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google" # You can also use "numpy".

[tool.ruff.pep8-naming]
[tool.ruff.lint.pep8-naming]
classmethod-decorators = ["classmethod", "validator", "root_validator", "pydantic.validator"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"*/__init__.py" = ["F401"]
"**/tests/*" = [
"S101", # asserts are encouraged in pytest
"ANN201", # return annotations don't add value for test functions
"ANN001", # type annotations don't add value for test functions
"ANN002", # type annotations don't add value for test functions
"ANN003", # type annotations don't add value for test functions
"ANN201", # type annotations don't add value for test functions
"ANN204", # type annotations don't add value for test functions
"ANN205", # type annotations don't add value for test functions
"ANN206", # type annotations don't add value for test functions
"D100", # docstrings are overkill for test functions
"D101",
"D102",
"D103",
"S101", # asserts are encouraged in pytest
]

[build-system]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line interface."""

import click


Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_name}}/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test cases for the __main__ module."""

import pytest
from click.testing import CliRunner

Expand Down
Loading