diff --git a/.copier-answers/pre-commit.yml b/.copier-answers/pre-commit.yml new file mode 100644 index 0000000..600a98b --- /dev/null +++ b/.copier-answers/pre-commit.yml @@ -0,0 +1,9 @@ +# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY +_commit: 418d39a +_src_path: https://github.com/westerveltco/pre-commit-template +django_version: 3.2 +include_django: true +include_javascript: false +include_python: true +include_tailwind: false +python_version: 3.8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bb497e..6c55b63 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.11 + python: python3.8 repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -11,39 +11,40 @@ repos: - id: check-yaml - repo: https://github.com/adamchainz/django-upgrade - rev: 1.15.0 + rev: "1.15.0" hooks: - id: django-upgrade - args: [--target-version, "4.2"] + args: [--target-version, "3.2"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.2 - hooks: - - id: ruff-format - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.2 + rev: v0.1.3 hooks: - id: ruff - args: [ --fix, --exit-non-zero-on-fix ] + args: [ --fix ] + - id: ruff-format - repo: https://github.com/adamchainz/blacken-docs - rev: 1.16.0 + rev: "1.16.0" hooks: - id: blacken-docs alias: autoformat additional_dependencies: - black==22.12.0 - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + - repo: https://github.com/rtts/djhtml + rev: "3.0.6" + hooks: + - id: djhtml + entry: djhtml --tabwidth 2 + alias: autoformat + + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.11.0 + hooks: + - id: pretty-format-toml + args: [--autofix] + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.15 hooks: - - id: prettier - # lint the following with prettier: - # - javascript - # - typescript - # - JSX/TSX - # - CSS - # - yaml - # ignore any minified code - files: '^(?!.*\.min\..*)(?P[\w-]+(\.[\w-]+)*\.(js|jsx|ts|tsx|yml|yaml|css))$' + - id: validate-pyproject diff --git a/Justfile b/Justfile index 249ca25..c6f7d5d 100644 --- a/Justfile +++ b/Justfile @@ -118,3 +118,19 @@ lint: mypy: python -m nox --reuse-existing-virtualenvs --session "mypy" + +# ---------------------------------------------------------------------- +# COPIER +# ---------------------------------------------------------------------- + +# create a copier answers file +copier-copy TEMPLATE_PATH DESTINATION_PATH=".": + pipx run copier copy {{ TEMPLATE_PATH }} {{ DESTINATION_PATH }} + +# update the project using a copier answers file +copier-update ANSWERS_FILE *ARGS: + pipx run copier update --answers-file {{ ANSWERS_FILE }} {{ ARGS }} + +# loop through all answers files and update the project using copier +@copier-update-all *ARGS: + for file in `ls .copier-answers/`; do just copier-update .copier-answers/$file "{{ ARGS }}"; done diff --git a/pyproject.toml b/pyproject.toml index 90e7206..44de1f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["hatchling"] [project] authors = [ - {name = "Josh Thomas", email = "josh@joshthomas.dev"}, + {name = "Josh Thomas", email = "josh@joshthomas.dev"} ] classifiers = [ "Development Status :: 3 - Alpha", @@ -24,13 +24,13 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: CPython" ] dependencies = ["django>=3.2"] description = "A simple, flexible, and extensible navigation menu for Django." dynamic = ["version"] keywords = [] -license = "MIT" +license = {file = "LICENSE"} name = "django-simple-nav" readme = "README.md" requires-python = ">=3.8" @@ -49,7 +49,7 @@ dev = [ "pytest-django", "pytest-randomly", "pytest-reverse", - "pytest-xdist", + "pytest-xdist" ] docs = [ "cogapp", @@ -58,7 +58,7 @@ docs = [ "sphinx", "sphinx-autobuild", "sphinx-copybutton", - "sphinx-inline-tabs", + "sphinx-inline-tabs" ] lint = ["pre-commit"] @@ -67,37 +67,20 @@ Documentation = "https://django-simple-nav.westervelt.dev" Issues = "https://github.com/westerveltco/django-simple-nav/issues" Source = "https://github.com/westerveltco/django-simple-nav" -[tool.hatch.build] -exclude = [ - ".github/*", - ".dockerfiles/*", - ".dockerignore", - ".editorconfig", - ".pre-commit-config.yaml", - "Justfile", - "src/service/*", -] - -[tool.hatch.build.targets.wheel] -packages = ["src/simple_nav"] - -[tool.hatch.version] -path = "src/simple_nav/__init__.py" - [tool.bumpver] commit = true commit_message = ":bookmark: bump version {old_version} -> {new_version}" current_version = "0.1.0dev0" -push = false # set to false for CI +push = false # set to false for CI tag = false version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]" [tool.bumpver.file_patterns] "src/simple_nav/__init__.py" = [ - '__version__ = "{version}"', + '__version__ = "{version}"' ] "tests/test_version.py" = [ - 'assert __version__ == "{version}"', + 'assert __version__ == "{version}"' ] [tool.coverage.paths] @@ -109,7 +92,7 @@ fail_under = 85 [tool.coverage.run] omit = [ "src/simple_nav/migrations/*", - "tests/*", + "tests/*" ] source = ["simple_nav"] @@ -117,14 +100,31 @@ source = ["simple_nav"] django_settings_module = "tests.settings" strict_settings = false +[tool.hatch.build] +exclude = [ + ".github/*", + ".dockerfiles/*", + ".dockerignore", + ".editorconfig", + ".pre-commit-config.yaml", + "Justfile", + "src/service/*" +] + +[tool.hatch.build.targets.wheel] +packages = ["src/simple_nav"] + +[tool.hatch.version] +path = "src/simple_nav/__init__.py" + [tool.mypy] +check_untyped_defs = true exclude = "docs/.*\\.py$" mypy_path = "src/" namespace_packages = false -check_untyped_defs = true no_implicit_optional = true plugins = [ - "mypy_django_plugin.main", + "mypy_django_plugin.main" ] warn_redundant_casts = true warn_unused_configs = true @@ -139,27 +139,16 @@ module = "tests.*" ignore_missing_model_attributes = true [tool.pytest.ini_options] -django_find_project = false -pythonpath = "src" addopts = "--create-db -n auto --dist loadfile --doctest-modules" +django_find_project = false norecursedirs = ".* bin build dist *.egg htmlcov logs node_modules templates venv" python_files = "tests.py test_*.py *_tests.py" +pythonpath = "src" testpaths = ["tests"] [tool.ruff] -ignore = ["E501", "E741"] # temporary -select = [ - "B", # flake8-bugbear - "E", # Pycodestyle - "F", # Pyflakes - "I", # isort - "UP", # pyupgrade -] - -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["A", "B", "C", "D", "E", "F", "I"] -unfixable = [] - +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" # Exclude a variety of commonly ignored directories. exclude = [ ".bzr", @@ -181,34 +170,34 @@ exclude = [ "migrations", "node_modules", "static", - "venv", + "venv" ] extend-include = ["*.pyi?"] - -per-file-ignores = {} - +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "I"] +ignore = ["E501", "E741"] # temporary +indent-width = 4 # Same as Black. line-length = 88 -indent-width = 4 - -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - +per-file-ignores = {} +select = [ + "B", # flake8-bugbear + "E", # Pycodestyle + "F", # Pyflakes + "I", # isort + "UP" # pyupgrade +] # Assume Python >3.8. target-version = "py38" +unfixable = [] [tool.ruff.format] -# Like Black, use double quotes for strings. -quote-style = "double" - # Like Black, indent with spaces, rather than tabs. indent-style = "space" - -# Like Black, respect magic trailing commas. -# magic-trailing-comma = "respect" - # Like Black, automatically detect the appropriate line ending. line-ending = "auto" +# Like Black, use double quotes for strings. +quote-style = "double" [tool.ruff.isort] force-single-line = true