From e5123ebb1d546b0c28f0f7be076f9a3624e41530 Mon Sep 17 00:00:00 2001 From: staticdev Date: Tue, 28 Dec 2021 12:58:53 +0100 Subject: [PATCH] Fix docstrings and RSTs --- .flake8 | 7 +- .github/release-drafter.yml | 1 - .github/workflows/release.yml | 1 - .gitignore | 1 + .pre-commit-config.yaml | 36 ++--- .readthedocs.yml | 12 ++ CODE_OF_CONDUCT.rst | 105 +++++++++++++++ README.rst | 4 +- changes.rst | 125 ----------------- codecov.yml | 1 - docs/changes.rst | 121 ----------------- docs/codeofconduct.rst | 1 + docs/conf.py | 2 + docs/contributing.rst | 4 + docs/examples.rst | 20 +-- docs/index.rst | 9 +- docs/inquirer.rst | 9 -- docs/installation.rst | 2 +- docs/license.rst | 4 +- docs/usage.rst | 11 +- examples/test_questions.json | 21 ++- noxfile.py | 14 +- poetry.lock | 247 +++++++++++++++++++++++++++++++++- pyproject.toml | 6 +- src/inquirer/questions.py | 91 ++++++------- src/inquirer/themes.py | 52 +++---- 26 files changed, 514 insertions(+), 393 deletions(-) create mode 100644 .readthedocs.yml create mode 100644 CODE_OF_CONDUCT.rst delete mode 100644 changes.rst delete mode 100644 docs/changes.rst create mode 100644 docs/codeofconduct.rst create mode 100644 docs/contributing.rst diff --git a/.flake8 b/.flake8 index c057b0f8..300abb4d 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,7 @@ [flake8] -max-line-length=119 +select = B,B9,C,D,DAR,E,F,N,RST,S,W +ignore = RST201,RST203,RST301,W503 +max-line-length = 119 +docstring-convention = google +rst-roles = class,const,func,meth,mod,ref +rst-directives = deprecated diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 494556dd..815fdabc 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -28,4 +28,3 @@ template: | ## Changes $CHANGES - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2068064a..797a9c00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,6 @@ jobs: run: | poetry build --ansi - - name: Publish package on PyPI if: steps.check-version.outputs.tag uses: pypa/gh-action-pypi-publish@v1.4.2 diff --git a/.gitignore b/.gitignore index ff634564..8d42fb68 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ venv/ /.coverage.* /.nox/ /dist/ +/docs/_build/ .cache *.swp __pycache__/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5db20fc..6a6b287b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,33 @@ repos: -# - repo: https://github.com/PyCQA/isort.git -# rev: 5.7.0 -# hooks: -# - id: isort + # - repo: https://github.com/PyCQA/isort.git + # rev: 5.7.0 + # hooks: + # - id: isort - repo: https://github.com/psf/black rev: 21.12b0 hooks: - - id: black - language_version: python3 - require_serial: true - args: - - -l - - "119" + - id: black + language_version: python3 + require_serial: true + args: + - -l + - "119" - repo: https://gitlab.com/pycqa/flake8 rev: 6de8252c035844f1e679f509b5f37340b44d5c39 hooks: - - id: flake8 + - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: - - id: check-yaml - - id: trailing-whitespace + - id: check-yaml + - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade rev: v2.29.1 hooks: - - id: pyupgrade - types: [python] - args: [--py37-plus] + - id: pyupgrade + types: [python] + args: [--py37-plus] + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.4.1 + hooks: + - id: prettier diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..e562369a --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,12 @@ +version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3.9" +sphinx: + configuration: docs/conf.py +formats: all +python: + install: + - requirements: docs/requirements.txt + - path: . diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 00000000..b6954bba --- /dev/null +++ b/CODE_OF_CONDUCT.rst @@ -0,0 +1,105 @@ +Contributor Covenant Code of Conduct +==================================== + +Our Pledge +---------- + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + + +Our Standards +------------- + +Examples of behavior that contributes to a positive environment for our community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +Enforcement Responsibilities +---------------------------- + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + + +Scope +----- + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + + +Enforcement +----------- + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at miguelangel.garcia@gmail.com. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + + +Enforcement Guidelines +---------------------- + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + + +1. Correction +~~~~~~~~~~~~~ + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + + +2. Warning +~~~~~~~~~~ + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + + +3. Temporary Ban +~~~~~~~~~~~~~~~~ + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + + +4. Permanent Ban +~~~~~~~~~~~~~~~~ + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + + +Attribution +----------- + +This Code of Conduct is adapted from the `Contributor Covenant `__, version 2.0, +available at https://www.contributor-covenant.org/version/2/0/code_of_conduct/. + +Community Impact Guidelines were inspired by `Mozilla’s code of conduct enforcement ladder `__. + +.. _homepage: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. diff --git a/README.rst b/README.rst index ccec7b69..3d4657fd 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,11 @@ ==================== ================================================================================= -Tests |Tests| |Codecov| |Documentation| +Tests |Tests| |Codecov| -------------------- --------------------------------------------------------------------------------- Downloads |pip dm| |pip dw| |pip dd| -------------------- --------------------------------------------------------------------------------- About |License| |pip wheel| |pip pyversions| |pip implem| -------------------- --------------------------------------------------------------------------------- -Status |version| |status| +Status |version| |status| |Documentation| ==================== ================================================================================= Collection of common interactive command line user interfaces, based on `Inquirer.js`_. diff --git a/changes.rst b/changes.rst deleted file mode 100644 index 0d2213ff..00000000 --- a/changes.rst +++ /dev/null @@ -1,125 +0,0 @@ -Changelog -========= - -For changes after 2.1.11 see `GitHub Releases `_ - -2.1.11(2014/12/18) ------------------- - -Features -~~~~~~~~ - -* `#18`_ The ``Prompt`` shout raise ``KeyboardInterrupt`` if required. - -2.1.3 (2014/12/27) ------------------- - -Bugs -~~~~ - -* The ``Question`` start was not shown. - -2.1.2 (2014/12/16) ------------------- - -Features -~~~~~~~~ - -* `#7`_ Adding default values for `Checkbox`, by ptbrowne_ - - -2.1.1 (2014/12/11) ------------------- - -Bugs -~~~~ - -* Status bar was hiden by question -* Fixed a :code:`force_new_line` problem with some environments. - - -2.1.0 (2014/12/10) ------------------- - -Features -~~~~~~~~ - -* code refactors -* Adding `ReadTheDocs`_ documentation - -Bugs -~~~~ - -* `#6`_ Removed new line after questions -* Confirmations will not raise an exception on unknown value - - -2.0.2 (2014/11/27) ------------------- - -Features -~~~~~~~~ - -* Using pytest_ instead of nose_ -* Documentation updated -* Added :file:`changes.rst` file with the changelog - -Bugs -~~~~ - -* `#5`_: Fixed :code:`List` and :code:`Checkbox`, that were overriden if there was more :code:`Questions`. - -2.0.1 (2014/10/31) ------------------- - -Features -~~~~~~~~ - -* `#4`_: Instantiate from JSON - - * Internal refactors - * added load_from_dict and load_from_json factories, by mfwarren_ - - -2.0.0 (2014/10/19) ------------------- - -Features -~~~~~~~~ - -* Complete refactor of :code:`Question`, :code:`ConsoleRender` and the way it was rendered with :code:`blessings` library. - -1.X.X ------ - -Special thanks to matiboy_ by his contributions to these releases. - - -Hall Of Fame -============ - -Contributors: - -* matiboy_ -* mfwarren_ -* ptbrowne_ - - -.. _pytest: http://pytest.org/ -.. _nose: https://nose.readthedocs.org/ -.. _ReadTheDocs: https://python-inquirer.readthedocs.org/ - -.. _#1: https://github.com/magmax/python-inquirer/issues/1 -.. _#4: https://github.com/magmax/python-inquirer/pull/2 -.. _#4: https://github.com/magmax/python-inquirer/pull/3 -.. _#4: https://github.com/magmax/python-inquirer/pull/4 -.. _#5: https://github.com/magmax/python-inquirer/issues/5 -.. _#6: https://github.com/magmax/python-inquirer/issues/6 -.. _#7: https://github.com/magmax/python-inquirer/pull/7 -.. _#18: https://github.com/magmax/python-inquirer/issues/18 - -.. _ptbrowne: https://github.com/ptbrowne -.. _mfwarren: https://github.com/mfwarren -.. _matiboy: https://github.com/matiboy -.. _realgam3: https://github.com/realgam3 -.. _jmrubio: https://github.com/jmrubio diff --git a/codecov.yml b/codecov.yml index 4f6dd27d..39c15fc0 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,4 +1,3 @@ - comment: false coverage: status: diff --git a/docs/changes.rst b/docs/changes.rst deleted file mode 100644 index ba00756d..00000000 --- a/docs/changes.rst +++ /dev/null @@ -1,121 +0,0 @@ -Changelog -========= - -2.1.11(2014/12/18) ------------------- - -Features -~~~~~~~~ - -* `#18`_ The ``Prompt`` shout raise ``KeyboardInterrupt`` if required. - -2.1.3 (2014/12/27) ------------------- - -Bugs -~~~~ - -* The ``Question`` start was not shown. - -2.1.2 (2014/12/16) ------------------- - -Features -~~~~~~~~ - -* `#7`_ Adding default values for `Checkbox`, by ptbrowne_ - - -2.1.1 (2014/12/11) ------------------- - -Bugs -~~~~ - -* Status bar was hiden by question -* Fixed a :code:`force_new_line` problem with some environments. - - -2.1.0 (2014/12/10) ------------------- - -Features -~~~~~~~~ - -* code refactors -* Adding `ReadTheDocs`_ documentation - -Bugs -~~~~ - -* `#6`_ Removed new line after questions -* Confirmations will not raise an exception on unknown value - - -2.0.2 (2014/11/27) ------------------- - -Features -~~~~~~~~ - -* Using pytest_ instead of nose_ -* Documentation updated -* Added :file:`changes.rst` file with the changelog - -Bugs -~~~~ - -* `#5`_: Fixed :code:`List` and :code:`Checkbox`, that were overriden if there was more :code:`Questions`. - -2.0.1 (2014/10/31) ------------------- - -Features -~~~~~~~~ - -* `#4`_: Instantiate from JSON - - * Internal refactors - * added load_from_dict and load_from_json factories, by mfwarren_ - - -2.0.0 (2014/10/19) ------------------- - -Features -~~~~~~~~ - -* Complete refactor of :code:`Question`, :code:`ConsoleRender` and the way it was rendered with :code:`blessings` library. - -1.X.X ------ - -Special thanks to matiboy_ by his contributions to these releases. - - -Hall Of Fame -============ - -Contributors: - -* matiboy_ -* mfwarren_ -* ptbrowne_ - - -.. _pytest: http://pytest.org/ -.. _nose: https://nose.readthedocs.org/ -.. _ReadTheDocs: https://python-inquirer.readthedocs.org/ - -.. _#1: https://github.com/magmax/python-inquirer/issues/1 -.. _#4: https://github.com/magmax/python-inquirer/pull/2 -.. _#4: https://github.com/magmax/python-inquirer/pull/3 -.. _#4: https://github.com/magmax/python-inquirer/pull/4 -.. _#5: https://github.com/magmax/python-inquirer/issues/5 -.. _#6: https://github.com/magmax/python-inquirer/issues/6 -.. _#7: https://github.com/magmax/python-inquirer/pull/7 -.. _#18: https://github.com/magmax/python-inquirer/issues/18 - -.. _ptbrowne: https://github.com/ptbrowne -.. _mfwarren: https://github.com/mfwarren -.. _matiboy: https://github.com/matiboy diff --git a/docs/codeofconduct.rst b/docs/codeofconduct.rst new file mode 100644 index 00000000..96e0ba2f --- /dev/null +++ b/docs/codeofconduct.rst @@ -0,0 +1 @@ +.. include:: ../CODE_OF_CONDUCT.rst diff --git a/docs/conf.py b/docs/conf.py index 423936c9..231667da 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,5 +13,7 @@ html_theme = "furo" # workaround for bug: https://github.com/sphinx-doc/sphinx/issues/9383 linkcheck_ignore = [ + "codeofconduct.html", "contributing.html", + "examples.html", ] diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 00000000..c8670b6b --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1,4 @@ +.. include:: ../CONTRIBUTING.rst + :end-before: github-only + +.. _Code of Conduct: codeofconduct.html diff --git a/docs/examples.rst b/docs/examples.rst index 6de1672a..321a4d24 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -5,27 +5,27 @@ You can find all these examples at :code:`examples` directory. text.py ------------ +------- -.. literalinclude:: ../../examples/text.py +.. literalinclude:: ../examples/text.py Result on something like: |inquirer text| confirm.py ------------ +---------- -.. literalinclude:: ../../examples/confirm.py +.. literalinclude:: ../examples/confirm.py Result on something like: |inquirer confirm| list.py ------------ +------- -.. literalinclude:: ../../examples/list.py +.. literalinclude:: ../examples/list.py Result on something like: @@ -34,7 +34,7 @@ Result on something like: checkbox.py ----------- -.. literalinclude:: ../../examples/checkbox.py +.. literalinclude:: ../examples/checkbox.py Result on something like: @@ -43,12 +43,12 @@ Result on something like: The :code:`choices` list can also be a list of tuples. The first value in each tuple should be the label displayed to the user. The second value in each tuple should be the actual value for that option. This allows you to have the user choose options that are not plain strings in the code. -.. literalinclude:: ../../examples/checkbox_tagged.py +.. literalinclude:: ../examples/checkbox_tagged.py theme.py ------------ +-------- -.. literalinclude:: ../../examples/theme.py +.. literalinclude:: ../examples/theme.py Result on something like: diff --git a/docs/index.rst b/docs/index.rst index e099e33a..8f7bffb4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,3 @@ -.. inquirer documentation master file, created by - sphinx-quickstart on Mon Dec 1 20:43:04 2014. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - Welcome to inquirer's documentation! ==================================== @@ -24,6 +19,8 @@ Contents installation usage examples + contributing + Code of Conduct license modules @@ -33,7 +30,7 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` -* :ref:`search` +.. _Contributor Guide: contributing.html .. _Inquirer.js: https://github.com/SBoudrias/Inquirer.js .. _download the code from GitHub: https://github.com/magmax/python-inquirer diff --git a/docs/inquirer.rst b/docs/inquirer.rst index 69db9855..91b3cedb 100644 --- a/docs/inquirer.rst +++ b/docs/inquirer.rst @@ -58,12 +58,3 @@ inquirer.themes module :members: :undoc-members: :show-inheritance: - - -Module contents ---------------- - -.. automodule:: inquirer - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/installation.rst b/docs/installation.rst index c50b3b36..04951f6d 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -9,4 +9,4 @@ To install it, just execute: Usage example: -.. literalinclude:: ../../examples/mixed.py +.. literalinclude:: ../examples/mixed.py diff --git a/docs/license.rst b/docs/license.rst index 54229a01..2732c252 100644 --- a/docs/license.rst +++ b/docs/license.rst @@ -25,5 +25,5 @@ THE SOFTWARE. License taken from `MIT license`_. -.. |MIT license| image:: http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png -.. _`MIT license`: http://opensource.org/licenses/MIT +.. |MIT license| image:: https://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png +.. _`MIT license`: https://opensource.org/licenses/MIT diff --git a/docs/usage.rst b/docs/usage.rst index cddd7115..af0d6ea5 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -28,7 +28,7 @@ Question types |**PATH** | Requires valid path and allows additional validations. | +-------------+--------------------------------------------------------+ -There are pictures of some of them in the :ref:`examples` section. +There are pictures of some of them in the Examples_ section. Question Arguments @@ -85,7 +85,7 @@ default Stores the default value to be used as answer. This allow the user just to press `Enter` to use it. It is optional, using ``None`` if there is no input and no default value. -As in ``message` , you can use a new format string or a function with the sign: +As in ``message``, you can use a new format string or a function with the sign: .. code:: python @@ -164,6 +164,7 @@ where ``answers`` contains the `dict` of previous answers again. Example: .. code:: python + questions = [ inquirer.Text("name", message="What's your name?"), inquirer.Text( @@ -245,7 +246,7 @@ It's possible to load the :code:`Question` objects from a :code:`dict`, or even The method :code:`load_from_json` has been added as commodity to use JSON inputs instead. Here you have an example: -.. literalinclude:: ../../examples/questions_from_json.py +.. literalinclude:: ../examples/questions_from_json.py @@ -269,7 +270,7 @@ Themes You can change the colorscheme and some icons passing a theme object defined in inquirer.themes There are Default and GreenPassion themes, but you can define your own via class, dict or json! -.. literalinclude:: ../../examples/theme.py +.. literalinclude:: ../examples/theme.py Result: @@ -291,3 +292,5 @@ For one-off prompts, you can use the shortcut functions. choices=['public', 'private']) correct = inquirer.confirm("This will delete all your current labels and " "create a new ones. Continue?", default=False) + +.. _Examples: examples.html diff --git a/examples/test_questions.json b/examples/test_questions.json index 09e2c1dc..23fd5695 100644 --- a/examples/test_questions.json +++ b/examples/test_questions.json @@ -1,15 +1,10 @@ [ - { "kind": "text", - "name": "name", - "message": "What's your name" - }, - { "kind": "text", - "name": "surname", - "message": "What's your surname" - }, - { "kind": "list", - "name": "size", - "message": "What size do you need?", - "choices": ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"] - } + { "kind": "text", "name": "name", "message": "What's your name" }, + { "kind": "text", "name": "surname", "message": "What's your surname" }, + { + "kind": "list", + "name": "size", + "message": "What size do you need?", + "choices": ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"] + } ] diff --git a/noxfile.py b/noxfile.py index d8f92daa..42b4bca2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -103,14 +103,14 @@ def precommit(session: Session) -> None: args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"] session.install( "black", - "darglint", + # "darglint", "flake8", - "flake8-bandit", - "flake8-bugbear", + # "flake8-bandit", + # "flake8-bugbear", "flake8-docstrings", "flake8-rst-docstrings", - "isort", - "pep8-naming", + # "isort", + # "pep8-naming", "pre-commit", "pre-commit-hooks", "pyupgrade", @@ -187,7 +187,7 @@ def xdoctest(session: Session) -> None: session.run("python", "-m", "xdoctest", *args) -@session(name="docs-build", python=python_versions[0]) +@session(name="docs-build", python="3.9") def docs_build(session: Session) -> None: """Build the documentation.""" args = session.posargs or [ @@ -211,7 +211,7 @@ def docs_build(session: Session) -> None: session.run("sphinx-build", *args) -@session(python=python_versions[0]) +@session(python="3.9") def docs(session: Session) -> None: """Build and serve the documentation with live reloading on file changes.""" args = session.posargs or ["--open-browser", "docs", "docs/_build"] diff --git a/poetry.lock b/poetry.lock index fc0effd0..05e8707c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -88,6 +88,45 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "flake8" +version = "4.0.1" +description = "the modular source code checker: pep8 pyflakes and co" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +importlib-metadata = {version = "<4.3", markers = "python_version < \"3.8\""} +mccabe = ">=0.6.0,<0.7.0" +pycodestyle = ">=2.8.0,<2.9.0" +pyflakes = ">=2.4.0,<2.5.0" + +[[package]] +name = "flake8-docstrings" +version = "1.6.0" +description = "Extension for flake8 which uses pydocstyle to check docstrings" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +flake8 = ">=3" +pydocstyle = ">=2.1" + +[[package]] +name = "flake8-rst-docstrings" +version = "0.2.5" +description = "Python docstring reStructuredText (RST) validator" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +flake8 = ">=3.0.0" +pygments = "*" +restructuredtext-lint = "*" + [[package]] name = "furo" version = "2021.11.23" @@ -121,6 +160,22 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +[[package]] +name = "importlib-metadata" +version = "4.2.0" +description = "Read metadata from Python packages" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] +testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] + [[package]] name = "jinja2" version = "3.0.3" @@ -166,6 +221,14 @@ category = "dev" optional = false python-versions = ">=3.6" +[[package]] +name = "mccabe" +version = "0.6.1" +description = "McCabe checker, plugin for flake8" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "packaging" version = "21.3" @@ -188,6 +251,18 @@ python-versions = "*" [package.dependencies] ptyprocess = ">=0.5" +[[package]] +name = "pre-commit-hooks" +version = "4.1.0" +description = "Some out-of-the-box hooks for pre-commit." +category = "dev" +optional = false +python-versions = ">=3.6.1" + +[package.dependencies] +"ruamel.yaml" = ">=0.15" +toml = "*" + [[package]] name = "ptyprocess" version = "0.7.0" @@ -196,6 +271,36 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "pycodestyle" +version = "2.8.0" +description = "Python style guide checker" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pydocstyle" +version = "6.1.1" +description = "Python docstring style checker" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +snowballstemmer = "*" + +[package.extras] +toml = ["toml"] + +[[package]] +name = "pyflakes" +version = "2.4.0" +description = "passive checker of Python programs" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + [[package]] name = "pygments" version = "2.10.0" @@ -257,6 +362,40 @@ urllib3 = ">=1.21.1,<1.27" socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] +[[package]] +name = "restructuredtext-lint" +version = "1.3.2" +description = "reStructuredText linter" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +docutils = ">=0.11,<1.0" + +[[package]] +name = "ruamel.yaml" +version = "0.17.19" +description = "ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order" +category = "dev" +optional = false +python-versions = ">=3" + +[package.dependencies] +"ruamel.yaml.clib" = {version = ">=0.2.6", markers = "platform_python_implementation == \"CPython\" and python_version < \"3.11\""} + +[package.extras] +docs = ["ryd"] +jinja2 = ["ruamel.yaml.jinja2 (>=0.2)"] + +[[package]] +name = "ruamel.yaml.clib" +version = "0.2.6" +description = "C version of reader, parser and emitter for ruamel.yaml derived from libyaml" +category = "dev" +optional = false +python-versions = ">=3.5" + [[package]] name = "six" version = "1.16.0" @@ -399,6 +538,14 @@ python-versions = ">=3.5" lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest"] +[[package]] +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + [[package]] name = "tornado" version = "6.1" @@ -407,6 +554,14 @@ category = "dev" optional = false python-versions = ">= 3.5" +[[package]] +name = "typing-extensions" +version = "4.0.1" +description = "Backported and Experimental Type Hints for Python 3.6+" +category = "dev" +optional = false +python-versions = ">=3.6" + [[package]] name = "urllib3" version = "1.22" @@ -427,10 +582,22 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "zipp" +version = "3.6.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] +testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] + [metadata] lock-version = "1.1" python-versions = ">=3.7" -content-hash = "c6eb2f382d3ea8de797ded62a98c07accbed3af6361619437fa6392a0bfa1a4c" +content-hash = "cf8f7bf13cb0e983390dc7142e282399c81851b25f883b675d8cae6f9c0d495b" [metadata.files] alabaster = [ @@ -469,6 +636,18 @@ docutils = [ {file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"}, {file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"}, ] +flake8 = [ + {file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"}, + {file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"}, +] +flake8-docstrings = [ + {file = "flake8-docstrings-1.6.0.tar.gz", hash = "sha256:9fe7c6a306064af8e62a055c2f61e9eb1da55f84bb39caef2b84ce53708ac34b"}, + {file = "flake8_docstrings-1.6.0-py2.py3-none-any.whl", hash = "sha256:99cac583d6c7e32dd28bbfbef120a7c0d1b6dde4adb5a9fd441c4227a6534bde"}, +] +flake8-rst-docstrings = [ + {file = "flake8-rst-docstrings-0.2.5.tar.gz", hash = "sha256:4fe93f997dea45d9d3c8bd220f12f0b6c359948fb943b5b48021a3f927edd816"}, + {file = "flake8_rst_docstrings-0.2.5-py3-none-any.whl", hash = "sha256:b99d9041b769b857efe45a448dc8c71b1bb311f9cacbdac5de82f96498105082"}, +] furo = [ {file = "furo-2021.11.23-py3-none-any.whl", hash = "sha256:6d396451ad1aadce380c662fca9362cb10f4fd85f296d74fe3ca32006eb641d7"}, {file = "furo-2021.11.23.tar.gz", hash = "sha256:54cecac5f3b688b5c7370d72ecdf1cd91a6c53f0f42751f4a719184b562cde70"}, @@ -481,6 +660,10 @@ imagesize = [ {file = "imagesize-1.3.0-py2.py3-none-any.whl", hash = "sha256:1db2f82529e53c3e929e8926a1fa9235aa82d0bd0c580359c67ec31b2fddaa8c"}, {file = "imagesize-1.3.0.tar.gz", hash = "sha256:cd1750d452385ca327479d45b64d9c7729ecf0b3969a58148298c77092261f9d"}, ] +importlib-metadata = [ + {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, + {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, +] jinja2 = [ {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"}, {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"}, @@ -548,6 +731,10 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, ] +mccabe = [ + {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, + {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, +] packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, @@ -556,10 +743,26 @@ pexpect = [ {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"}, {file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"}, ] +pre-commit-hooks = [ + {file = "pre_commit_hooks-4.1.0-py2.py3-none-any.whl", hash = "sha256:ba95316b79038e56ce998cdacb1ce922831ac0e41744c77bcc2b9677bf183206"}, + {file = "pre_commit_hooks-4.1.0.tar.gz", hash = "sha256:b6361865d1877c5da5ac3a944aab19ce6bd749a534d2ede28e683d07194a57e1"}, +] ptyprocess = [ {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, ] +pycodestyle = [ + {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, + {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, +] +pydocstyle = [ + {file = "pydocstyle-6.1.1-py3-none-any.whl", hash = "sha256:6987826d6775056839940041beef5c08cc7e3d71d63149b48e36727f70144dc4"}, + {file = "pydocstyle-6.1.1.tar.gz", hash = "sha256:1d41b7c459ba0ee6c345f2eb9ae827cab14a7533a88c5c6f7e94923f72df92dc"}, +] +pyflakes = [ + {file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"}, + {file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"}, +] pygments = [ {file = "Pygments-2.10.0-py3-none-any.whl", hash = "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380"}, {file = "Pygments-2.10.0.tar.gz", hash = "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6"}, @@ -587,6 +790,36 @@ requests = [ {file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"}, {file = "requests-2.26.0.tar.gz", hash = "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"}, ] +restructuredtext-lint = [ + {file = "restructuredtext_lint-1.3.2.tar.gz", hash = "sha256:d3b10a1fe2ecac537e51ae6d151b223b78de9fafdd50e5eb6b08c243df173c80"}, +] +"ruamel.yaml" = [ + {file = "ruamel.yaml-0.17.19-py3-none-any.whl", hash = "sha256:92ac00b312c9a83ff3253a8f7b86dfe6f9996b4082b103af84b8df99175945bc"}, + {file = "ruamel.yaml-0.17.19.tar.gz", hash = "sha256:b9ce9a925d0f0c35a1dbba56b40f253c53cd526b0fa81cf7b1d24996f28fb1d7"}, +] +"ruamel.yaml.clib" = [ + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-macosx_10_6_intel.whl", hash = "sha256:cfdb9389d888c5b74af297e51ce357b800dd844898af9d4a547ffc143fa56751"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:7b2927e92feb51d830f531de4ccb11b320255ee95e791022555971c466af4527"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-win32.whl", hash = "sha256:ada3f400d9923a190ea8b59c8f60680c4ef8a4b0dfae134d2f2ff68429adfab5"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-win_amd64.whl", hash = "sha256:de9c6b8a1ba52919ae919f3ae96abb72b994dd0350226e28f3686cb4f142165c"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d67f273097c368265a7b81e152e07fb90ed395df6e552b9fa858c6d2c9f42502"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:72a2b8b2ff0a627496aad76f37a652bcef400fd861721744201ef1b45199ab78"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-win32.whl", hash = "sha256:9efef4aab5353387b07f6b22ace0867032b900d8e91674b5d8ea9150db5cae94"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-win_amd64.whl", hash = "sha256:846fc8336443106fe23f9b6d6b8c14a53d38cef9a375149d61f99d78782ea468"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0847201b767447fc33b9c235780d3aa90357d20dd6108b92be544427bea197dd"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:78988ed190206672da0f5d50c61afef8f67daa718d614377dcd5e3ed85ab4a99"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-win32.whl", hash = "sha256:a49e0161897901d1ac9c4a79984b8410f450565bbad64dbfcbf76152743a0cdb"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-win_amd64.whl", hash = "sha256:bf75d28fa071645c529b5474a550a44686821decebdd00e21127ef1fd566eabe"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a32f8d81ea0c6173ab1b3da956869114cae53ba1e9f72374032e33ba3118c233"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7f7ecb53ae6848f959db6ae93bdff1740e651809780822270eab111500842a84"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-win32.whl", hash = "sha256:89221ec6d6026f8ae859c09b9718799fea22c0e8da8b766b0b2c9a9ba2db326b"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-win_amd64.whl", hash = "sha256:31ea73e564a7b5fbbe8188ab8b334393e06d997914a4e184975348f204790277"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:dc6a613d6c74eef5a14a214d433d06291526145431c3b964f5e16529b1842bed"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:1866cf2c284a03b9524a5cc00daca56d80057c5ce3cdc86a52020f4c720856f0"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-win32.whl", hash = "sha256:3fb9575a5acd13031c57a62cc7823e5d2ff8bc3835ba4d94b921b4e6ee664104"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-win_amd64.whl", hash = "sha256:825d5fccef6da42f3c8eccd4281af399f21c02b32d98e113dbc631ea6a6ecbc7"}, + {file = "ruamel.yaml.clib-0.2.6.tar.gz", hash = "sha256:4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -631,6 +864,10 @@ sphinxcontrib-serializinghtml = [ {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, ] +toml = [ + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] tornado = [ {file = "tornado-6.1-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:d371e811d6b156d82aa5f9a4e08b58debf97c302a35714f6f45e35139c332e32"}, {file = "tornado-6.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:0d321a39c36e5f2c4ff12b4ed58d41390460f798422c4504e09eb5678e09998c"}, @@ -674,6 +911,10 @@ tornado = [ {file = "tornado-6.1-cp39-cp39-win_amd64.whl", hash = "sha256:548430be2740e327b3fe0201abe471f314741efcb0067ec4f2d7dcfb4825f3e4"}, {file = "tornado-6.1.tar.gz", hash = "sha256:33c6e81d7bd55b468d2e793517c909b139960b6c790a60b7991b9b6b76fb9791"}, ] +typing-extensions = [ + {file = "typing_extensions-4.0.1-py3-none-any.whl", hash = "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"}, + {file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"}, +] urllib3 = [ {file = "urllib3-1.22-py2.py3-none-any.whl", hash = "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b"}, {file = "urllib3-1.22.tar.gz", hash = "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"}, @@ -682,3 +923,7 @@ wcwidth = [ {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, ] +zipp = [ + {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, + {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"}, +] diff --git a/pyproject.toml b/pyproject.toml index 65e4ad39..db86fdb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ license = "MIT" readme = "README.rst" homepage = "https://github.com/magmax/python-inquirer" repository = "https://github.com/magmax/python-inquirer" -documentation = "https://github.com/magmax/python-inquirer" +documentation = "https://magmax.org/python-inquirer" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", @@ -29,6 +29,10 @@ pexpect = ">=4.8.0" Sphinx = ">=4.3.2" sphinx-autobuild = ">=2021.3.14" furo = ">=2021.11.23" +flake8 = ">=4.0.1" +flake8-docstrings = ">=1.6.0" +flake8-rst-docstrings = ">=0.2.5" +pre-commit-hooks = ">=4.1.0" [tool.coverage.paths] source = ["src", "*/site-packages"] diff --git a/src/inquirer/questions.py b/src/inquirer/questions.py index 67862154..923b8f2e 100644 --- a/src/inquirer/questions.py +++ b/src/inquirer/questions.py @@ -1,6 +1,5 @@ -""" -Module that implements the questions types -""" +"""Module that implements the questions types.""" +from __future__ import annotations import json import os @@ -10,48 +9,6 @@ from . import errors -def question_factory(kind, *args, **kwargs): - for clazz in (Text, Editor, Password, Confirm, List, Checkbox, Path): - if clazz.kind == kind: - return clazz(*args, **kwargs) - raise errors.UnknownQuestionTypeError() - - -def load_from_dict(question_dict): - """ - Load one question from a dict. - It requires the keys 'name' and 'kind'. - :return: The Question object with associated data. - :return type: Question - """ - return question_factory(**question_dict) - - -def load_from_list(question_list): - """ - Load a list of questions from a list of dicts. - It requires the keys 'name' and 'kind' for each dict. - :return: A list of Question objects with associated data. - :return type: List - """ - return [load_from_dict(q) for q in question_list] - - -def load_from_json(question_json): - """ - Load Questions from a JSON string. - :return: A list of Question objects with associated data if the JSON - contains a list or a Question if the JSON contains a dict. - :return type: List or Dict - """ - data = json.loads(question_json) - if isinstance(data, list): - return load_from_list(data) - if isinstance(data, dict): - return load_from_dict(data) - raise TypeError("Json contained a %s variable when a dict or list was expected", type(data)) - - class TaggedValue: def __init__(self, label, value): self.label = label @@ -262,3 +219,47 @@ def normalize_value(self, value): value = os.path.abspath(value) return value + + +def question_factory(kind, *args, **kwargs): + for cl in (Text, Editor, Password, Confirm, List, Checkbox, Path): + if cl.kind == kind: + return cl(*args, **kwargs) + raise errors.UnknownQuestionTypeError() + + +def load_from_dict(question_dict) -> Question: + """Load one question from a dict. + + It requires the keys 'name' and 'kind'. + + Returns: + The Question object with associated data. + """ + return question_factory(**question_dict) + + +def load_from_list(question_list) -> list[Question]: + """Load a list of questions from a list of dicts. + + It requires the keys 'name' and 'kind' for each dict. + + Returns: + A list of Question objects with associated data. + """ + return [load_from_dict(q) for q in question_list] + + +def load_from_json(question_json) -> list | dict: + """Load Questions from a JSON string. + + Returns: + A list of Question objects with associated data if the JSON + contains a list or a Question if the JSON contains a dict. + """ + data = json.loads(question_json) + if isinstance(data, list): + return load_from_list(data) + if isinstance(data, dict): + return load_from_dict(data) + raise TypeError("Json contained a %s variable when a dict or list was expected", type(data)) diff --git a/src/inquirer/themes.py b/src/inquirer/themes.py index e94cacdd..fcc70fe7 100644 --- a/src/inquirer/themes.py +++ b/src/inquirer/themes.py @@ -9,20 +9,20 @@ def load_theme_from_json(json_theme): - """ - Load a theme from a json. + """Load a theme from a json. + Expected format: - { - "Question": { - "mark_color": "yellow", - "brackets_color": "normal", - ... - }, - "List": { - "selection_color": "bold_blue", - "selection_cursor": "->" - } - } + >>> { + ... "Question": { + ... "mark_color": "yellow", + ... "brackets_color": "normal", + ... ... + ... }, + ... "List": { + ... "selection_color": "bold_blue", + ... "selection_cursor": "->" + ... } + ... } Color values should be string representing valid blessings.Terminal colors. """ @@ -30,20 +30,20 @@ def load_theme_from_json(json_theme): def load_theme_from_dict(dict_theme): - """ - Load a theme from a dict. + """Load a theme from a dict. + Expected format: - { - "Question": { - "mark_color": "yellow", - "brackets_color": "normal", - ... - }, - "List": { - "selection_color": "bold_blue", - "selection_cursor": "->" - } - } + >>> { + ... "Question": { + ... "mark_color": "yellow", + ... "brackets_color": "normal", + ... ... + ... }, + ... "List": { + ... "selection_color": "bold_blue", + ... "selection_cursor": "->" + ... } + ... } Color values should be string representing valid blessings.Terminal colors. """