4 | {{cookiecutter.project_short_description}} 5 |
6 | 7 | []({{cookiecutter.repository_url}}/actions) 8 | [](https://codecov.io/gh/{{cookiecutter.repository_name}}) 9 | [](https://badge.fury.io/py/{{cookiecutter.dist_name}}) 10 | 11 | --- 12 | 13 | **Documentation**: {{cookiecutter.docs_url}} 14 | 15 | **Source Code**: {{cookiecutter.repository_url}} 16 | 17 | --- 18 | 19 | ## Development 20 | 21 | ### Setup environment 22 | 23 | We use [Hatch](https://hatch.pypa.io/latest/install/) to manage the development environment and production build. Ensure it's installed on your system. 24 | 25 | ### Run unit tests 26 | 27 | You can run all the tests with: 28 | 29 | ```bash 30 | hatch run test 31 | ``` 32 | 33 | ### Format the code 34 | 35 | Execute the following command to apply linting and check typing: 36 | 37 | ```bash 38 | hatch run lint 39 | ``` 40 | 41 | ### Publish a new version 42 | 43 | You can bump the version, create a commit and associated tag with one command: 44 | 45 | ```bash 46 | hatch version patch 47 | ``` 48 | 49 | ```bash 50 | hatch version minor 51 | ``` 52 | 53 | ```bash 54 | hatch version major 55 | ``` 56 | 57 | Your default Git text editor will open so you can add information about the release. 58 | 59 | When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft. 60 | 61 | ## Serve the documentation 62 | 63 | You can serve the Mkdocs documentation with: 64 | 65 | ```bash 66 | hatch run docs-serve 67 | ``` 68 | 69 | It'll automatically watch for changes in your code. 70 | 71 | ## License 72 | 73 | This project is licensed under the terms of the {{cookiecutter.open_source_license}}. 74 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/docs/index.md: -------------------------------------------------------------------------------- 1 | --8<-- "README.md" 2 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/docs/reference/{{cookiecutter.package_name}}.md: -------------------------------------------------------------------------------- 1 | # Reference 2 | 3 | ::: {{ cookiecutter.package_name }} 4 | options: 5 | show_root_heading: false 6 | show_source: false 7 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: {{ cookiecutter.project_name }} 2 | site_description: {{ cookiecutter.project_short_description }} 3 | 4 | repo_url: {{ cookiecutter.repository_url }} 5 | repo_name: {{ cookiecutter.repository_name }} 6 | 7 | theme: 8 | name: material 9 | icon: 10 | logo: {{ cookiecutter.docs_icon }} 11 | palette: 12 | # Palette toggle for automatic mode 13 | - media: "(prefers-color-scheme)" 14 | toggle: 15 | icon: material/brightness-auto 16 | name: Switch to light mode 17 | 18 | # Palette toggle for light mode 19 | - media: "(prefers-color-scheme: light)" 20 | scheme: default 21 | primary: {{ cookiecutter.docs_color_primary }} 22 | accent: {{ cookiecutter.docs_color_accent }} 23 | toggle: 24 | icon: material/brightness-7 25 | name: Switch to dark mode 26 | 27 | # Palette toggle for dark mode 28 | - media: "(prefers-color-scheme: dark)" 29 | scheme: slate 30 | primary: {{ cookiecutter.docs_color_primary }} 31 | accent: {{ cookiecutter.docs_color_accent }} 32 | toggle: 33 | icon: material/brightness-4 34 | name: Switch to light mode 35 | 36 | markdown_extensions: 37 | - toc: 38 | permalink: true 39 | - pymdownx.highlight: 40 | anchor_linenums: true 41 | - pymdownx.tasklist: 42 | custom_checkbox: true 43 | - pymdownx.inlinehilite 44 | - pymdownx.snippets 45 | - pymdownx.superfences 46 | 47 | plugins: 48 | - search 49 | - mkdocstrings: 50 | handlers: 51 | python: 52 | import: 53 | - https://docs.python.org/{{ cookiecutter.python_version }}/objects.inv 54 | options: 55 | docstring_style: google 56 | 57 | watch: 58 | - docs 59 | - {{ cookiecutter.package_name }} 60 | 61 | nav: 62 | - About: index.md 63 | - Reference: 64 | - {{ cookiecutter.package_name }}: reference/{{ cookiecutter.package_name }}.md 65 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.ruff] 2 | target-version = "py{{ cookiecutter.python_version | replace(".", "") }}" 3 | 4 | [tool.ruff.lint] 5 | extend-select = ["I", "TRY", "UP"] 6 | 7 | [tool.mypy] 8 | warn_redundant_casts = true 9 | warn_unused_ignores = true 10 | disallow_any_generics = true 11 | check_untyped_defs = true 12 | no_implicit_reexport = true 13 | strict_equality = true 14 | disallow_untyped_defs = true 15 | 16 | [tool.pytest.ini_options] 17 | addopts = "--cov={{ cookiecutter.package_name }}/ --cov-report=term-missing" 18 | {% if cookiecutter.async == "asyncio" -%} 19 | asyncio_default_fixture_loop_scope = "function" 20 | asyncio_mode = "strict" 21 | {% elif cookiecutter.async == "anyio" -%} 22 | {%- endif %} 23 | 24 | [tool.hatch] 25 | 26 | [tool.hatch.metadata] 27 | allow-direct-references = true 28 | 29 | [tool.hatch.version] 30 | source = "regex_commit" 31 | commit_extra_args = ["-e"] 32 | path = "{{ cookiecutter.package_name }}/__init__.py" 33 | 34 | [tool.hatch.envs.default] 35 | installer = "uv" 36 | python = "{{ cookiecutter.python_version }}" 37 | dependencies = [ 38 | "mypy", 39 | "ruff", 40 | "pytest", 41 | "pytest-cov", 42 | "mkdocs-material", 43 | "mkdocstrings[python]", 44 | {% if cookiecutter.async == "asyncio" -%} 45 | "pytest-asyncio", 46 | {%- endif %} 47 | ] 48 | 49 | [tool.hatch.envs.default.scripts] 50 | test = "pytest" 51 | test-cov-xml = "pytest --cov-report=xml" 52 | lint = [ 53 | "ruff format .", 54 | "ruff check --fix .", 55 | "mypy {{ cookiecutter.package_name }}/", 56 | ] 57 | lint-check = [ 58 | "ruff format --check .", 59 | "ruff check .", 60 | "mypy {{ cookiecutter.package_name }}/", 61 | ] 62 | docs-serve = "mkdocs serve" 63 | docs-build = "mkdocs build" 64 | 65 | [build-system] 66 | requires = ["hatchling", "hatch-regex-commit"] 67 | build-backend = "hatchling.build" 68 | 69 | [project] 70 | name = "{{ cookiecutter.dist_name }}" 71 | authors = [ 72 | { name = "{{ cookiecutter.dist_name }}", email = "{{ cookiecutter.email }}" } 73 | ] 74 | description = "{{ cookiecutter.project_short_description }}" 75 | readme = "README.md" 76 | dynamic = ["version"] 77 | classifiers = [ 78 | "Programming Language :: Python :: 3 :: Only", 79 | "Programming Language :: Python :: {{ cookiecutter.python_version }}", 80 | ] 81 | requires-python = ">={{ cookiecutter.python_version }}" 82 | dependencies = [ 83 | {% if cookiecutter.async == "anyio" -%} 84 | "anyio", 85 | {%- endif %} 86 | ] 87 | 88 | [project.urls] 89 | Documentation = "{{ cookiecutter.docs_url }}" 90 | Source = "{{ cookiecutter.repository_url }}" 91 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankie567/cookiecutter-hipster-pypackage/f99966d68e1f21903415518bd68fa11acd97b511/{{cookiecutter.dist_name}}/tests/__init__.py -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/tests/conftest.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankie567/cookiecutter-hipster-pypackage/f99966d68e1f21903415518bd68fa11acd97b511/{{cookiecutter.dist_name}}/tests/conftest.py -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/tests/test_add.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from {{ cookiecutter.package_name }} import add 4 | 5 | 6 | @pytest.mark.parametrize( 7 | "a,b,result", 8 | [ 9 | (0, 0, 0), 10 | (1, 1, 2), 11 | (3, 2, 5), 12 | ], 13 | ) 14 | def test_add(a: int, b: int, result: int): 15 | assert add(a, b) == result 16 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/{{cookiecutter.package_name}}/__init__.py: -------------------------------------------------------------------------------- 1 | """{{cookiecutter.project_short_description}}""" 2 | 3 | __version__ = "0.0.0" 4 | 5 | 6 | def add(a: int, b: int) -> int: 7 | """ 8 | Add two integers. 9 | 10 | Args: 11 | a: 12 | The first operand. 13 | b: 14 | The second operand. 15 | 16 | Examples: 17 | Add two integers 18 | 19 | r = add(2, 3) 20 | print(r) # 5 21 | """ 22 | return a + b 23 | -------------------------------------------------------------------------------- /{{cookiecutter.dist_name}}/{{cookiecutter.package_name}}/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankie567/cookiecutter-hipster-pypackage/f99966d68e1f21903415518bd68fa11acd97b511/{{cookiecutter.dist_name}}/{{cookiecutter.package_name}}/py.typed --------------------------------------------------------------------------------