-
Notifications
You must be signed in to change notification settings - Fork 15
switch to pyproject #193
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
Open
cav71
wants to merge
12
commits into
janluke:master
Choose a base branch
from
cav71:migrate-to-pyproject.toml
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
switch to pyproject #193
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
055089d
switch to pyproject
cav71 5dfedae
lint
cav71 8491a48
legacy fix?
cav71 f18e962
use older tox
cav71 85b3962
lint
cav71 cc2a0bf
fix dependencies
cav71 795c3c9
fix tox twine
cav71 a61a625
fix dependencies
cav71 3757356
remove PYPI_README.rst
cav71 a8d3e17
add docs to pyproject.toml
cav71 beb3fb5
fix building wheel
cav71 662f461
added test section to pyproject
cav71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| .. docs-index-start | ||
|
|
||
| .. |pypi-release| image:: https://img.shields.io/pypi/v/cloup.svg | ||
| :alt: Latest release on PyPI | ||
| :target: https://pypi.org/project/cloup/ | ||
|
|
||
| .. |tests-status| image:: https://github.com/janLuke/cloup/workflows/Tests/badge.svg | ||
| :alt: Tests status | ||
| :target: https://github.com/janLuke/cloup/actions?query=workflow%3ATests | ||
|
|
||
| .. |coverage| image:: https://codecov.io/github/janLuke/cloup/coverage.svg?branch=master | ||
| :alt: Coverage Status | ||
| :target: https://app.codecov.io/github/janluke/cloup/tree/master | ||
|
|
||
| .. |python-versions| image:: https://img.shields.io/pypi/pyversions/cloup.svg | ||
| :alt: Supported versions | ||
| :target: https://pypi.org/project/cloup | ||
|
|
||
| .. |dev-docs| image:: https://readthedocs.org/projects/cloup/badge/?version=latest | ||
| :alt: Documentation Status (master branch) | ||
| :target: https://cloup.readthedocs.io/en/latest/ | ||
|
|
||
| .. |release-docs| image:: https://readthedocs.org/projects/cloup/badge/?version=stable | ||
| :alt: Documentation Status (latest release) | ||
| :target: https://cloup.readthedocs.io/en/stable/ | ||
|
|
||
| .. |downloads| image:: https://static.pepy.tech/personalized-badge/cloup?period=week&units=international_system&left_color=grey&right_color=blue&left_text=downloads%20/%20week | ||
| :alt: PyPI - Downloads | ||
| :target: https://pepy.tech/project/cloup | ||
|
|
||
| ======== | ||
| Overview | ||
| ======== | ||
| |pypi-release| |downloads| |tests-status| |coverage| |dev-docs| | ||
|
|
||
| **Cloup** — originally from "**Cl**\ick + option gr\ **oup**\s" — enriches | ||
| `Click <https://github.com/pallets/click>`_ with several features that make it | ||
| more expressive and configurable: | ||
|
|
||
| - **option groups** and an (optional) help section for positional arguments | ||
|
|
||
| - **constraints**, like ``mutually_exclusive``, that can be applied to option groups | ||
| or to any group of parameters, even *conditionally* | ||
|
|
||
| - **subcommand aliases** | ||
|
|
||
| - **subcommands sections**, i.e. the possibility of organizing the subcommands of a | ||
| ``Group`` in multiple help sections | ||
|
|
||
| - a **themeable HelpFormatter** that: | ||
|
|
||
| - has more parameters for adjusting widths and spacing, which can be provided | ||
| at the context and command level | ||
| - use a different layout when the terminal width is below a certain threshold | ||
| in order to improve readability | ||
|
|
||
| - suggestions like "did you mean <subcommand>?" when you mistype a subcommand. | ||
|
|
||
| Moreover, Cloup improves on **IDE support** providing decorators with *detailed* | ||
| type hints and adding the static methods ``Context.settings()`` and | ||
| ``HelpFormatter.settings()`` for creating dictionaries of settings. | ||
|
|
||
| Cloup is **statically type-checked** with MyPy in strict mode and extensively **tested** | ||
| against multiple versions of Python with nearly 100% coverage. | ||
|
|
||
|
|
||
| A simple example | ||
| ================ | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from cloup import ( | ||
| HelpFormatter, HelpTheme, Style, | ||
| command, option, option_group | ||
| ) | ||
| from cloup.constraints import RequireAtLeast, mutually_exclusive | ||
|
|
||
| # Check the docs for all available arguments of HelpFormatter and HelpTheme. | ||
| formatter_settings = HelpFormatter.settings( | ||
| theme=HelpTheme( | ||
| invoked_command=Style(fg='bright_yellow'), | ||
| heading=Style(fg='bright_white', bold=True), | ||
| constraint=Style(fg='magenta'), | ||
| col1=Style(fg='bright_yellow'), | ||
| ) | ||
| ) | ||
|
|
||
| # In a multi-command app, you can pass formatter_settings as part | ||
| # of your context_settings so that they are propagated to subcommands. | ||
| @command(formatter_settings=formatter_settings) | ||
| @option_group( | ||
| "Cool options", | ||
| option('--foo', help='This text should describe the option --foo.'), | ||
| option('--bar', help='This text should describe the option --bar.'), | ||
| constraint=mutually_exclusive, | ||
| ) | ||
| @option_group( | ||
| "Other cool options", | ||
| "This is the optional description of this option group.", | ||
| option('--pippo', help='This text should describe the option --pippo.'), | ||
| option('--pluto', help='This text should describe the option --pluto.'), | ||
| constraint=RequireAtLeast(1), | ||
| ) | ||
| def cmd(**kwargs): | ||
| """This is the command description.""" | ||
| pass | ||
|
|
||
| if __name__ == '__main__': | ||
| cmd(prog_name='invoked-command') | ||
|
|
||
|
|
||
| .. image:: https://raw.githubusercontent.com/janLuke/cloup/master/docs/_static/basic-example.png | ||
| :alt: Basic example --help screenshot | ||
|
|
||
| If you don't provide ``--pippo`` or ``--pluto``: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| Usage: invoked-command [OPTIONS] | ||
| Try 'invoked-command --help' for help. | ||
|
|
||
| Error: at least 1 of the following parameters must be set: | ||
| --pippo | ||
| --pluto | ||
|
|
||
| This simple example just scratches the surface. Read more in the documentation | ||
| (links below). | ||
|
|
||
| .. docs-index-end | ||
|
|
||
|
|
||
| Links | ||
| ===== | ||
|
|
||
| * Documentation (release_ | development_) | ||
| * `Changelog <https://cloup.readthedocs.io/en/stable/pages/changelog.html>`_ | ||
| * `GitHub repository <https://github.com/janLuke/cloup>`_ | ||
| * `Q&A and discussions <https://github.com/janLuke/cloup/discussions>`_ | ||
|
|
||
| .. _release: https://cloup.readthedocs.io/en/stable/#user-guide | ||
| .. _development: https://cloup.readthedocs.io/en/latest/#user-guide |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=80", "setuptools-scm>=8"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [tool.setuptools_scm] | ||
| version_file = "cloup/_version.py" | ||
|
|
||
| [project] | ||
| name = "cloup" | ||
| dynamic = ["version"] | ||
|
|
||
| description = "Adds features to Click: option groups, constraints, subcommand sections and help themes." | ||
| readme = { file = "PYPI_README.rst", content-type = "text/x-rst" } | ||
| license = { text = "BSD 3-Clause" } | ||
|
|
||
| requires-python = ">= 3.9" | ||
| authors = [ | ||
| { name = "Gianluca Gippetto", email = "[email protected]" }, | ||
| ] | ||
|
|
||
| classifiers = [ | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: BSD License", | ||
| "Natural Language :: English", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| ] | ||
|
|
||
|
|
||
| dependencies = [ | ||
| "click>=8.0,<9.0", | ||
| ] | ||
|
|
||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "build", | ||
| "flake8", | ||
| "flake8-pyproject", | ||
| "mypy", | ||
| "pytest", | ||
| "pytest-cov", | ||
| "pytest-html", | ||
| "setuptools-scm", | ||
| "typing_extensions; python_version <= '3.10'", | ||
| "tox<4", | ||
| "twine", | ||
| ] | ||
|
|
||
| [tool.flake8] | ||
| exclude = "docs" | ||
| max-line-length = 90 | ||
|
|
||
| ignore = [ | ||
| "E241", | ||
| "E251", | ||
| "W503", | ||
| ] | ||
|
|
||
| [tool.mypy] | ||
| ignore_missing_imports = true | ||
|
|
||
|
|
||
| [tool.coverage.report] | ||
| exclude_lines = [ | ||
| "pragma: no covver", | ||
| "raise NotImplementedError", | ||
| "...", | ||
| "if TYPE_CHECKING:", | ||
| ] | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.