Skip to content

Commit

Permalink
Merge branch 'master' into feature/date
Browse files Browse the repository at this point in the history
  • Loading branch information
kiancross committed Aug 15, 2022
2 parents 65c7968 + 87a891c commit b8893cd
Show file tree
Hide file tree
Showing 45 changed files with 849 additions and 570 deletions.
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ jobs:

steps:
- name: Checkout git repository 🕝
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python 3.7 🐍
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install poetry 🦄
uses: Gr1N/setup-poetry@v7

- name: Load Poetry Cached Libraries ⬇
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -57,21 +57,28 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
promttoolkit: [3.*, 2.*]
include:
- promttoolkit: 3.0.29
os: ubuntu-latest
python-version: '3.10'
- promttoolkit: 3.0.19
os: ubuntu-latest
python-version: '3.10'

steps:
- name: Checkout git repository 🕝
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }} 🐍
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry 🦄
uses: Gr1N/setup-poetry@v7

- name: Load Poetry Cached Libraries ⬇
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
Expand Down Expand Up @@ -111,18 +118,18 @@ jobs:

steps:
- name: Checkout git repository 🕝
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python 3.7 🐍
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install poetry 🦄
uses: Gr1N/setup-poetry@v7

- name: Load Poetry Cached Libraries ⬇
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -144,10 +151,10 @@ jobs:

steps:
- name: Checkout git repository 🕝
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python 3.7 🐍
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7

Expand Down
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/humitos/mirrors-autoflake
rev: v1.1
hooks:
- id: autoflake
args: ['-i', '--remove-all-unused-imports']

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ['-l', '88']

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ['-sl', '--profile', 'black']

- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: ['--max-line-length', '120', '--max-doc-length', '140']
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.PHONY: clean install formatter lint test types docs livedocs
.PHONY: clean install develop lint test types docs livedocs

JOBS ?= 1

help:
@echo "make"
@echo " clean"
@echo " Remove Python/build artifacts."
@echo " develop"
@echo " Configure development environment for questionary."
@echo " install"
@echo " Install questionary."
@echo " formatter"
@echo " Apply black formatting to code."
@echo " lint"
@echo " Check the code style."
@echo " Check the code style and apply black formatting."
@echo " test"
@echo " Run the unit tests."
@echo " types"
Expand All @@ -34,14 +34,14 @@ clean:
install:
poetry install --extras "docs"

formatter:
poetry run black .
develop: install
poetry run pre-commit install

lint:
poetry run black --check --diff .
poetry run pre-commit run -a

test:
poetry run pytest --pycodestyle --cov questionary -v
poetry run pytest --cov questionary -v

types:
poetry run mypy questionary
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

sys.path.insert(0, os.path.abspath("../"))
from questionary import __version__
from questionary import __version__ # noqa: E402

project = "Questionary"
copyright = "2021, Questionary"
Expand Down
26 changes: 18 additions & 8 deletions docs/pages/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,36 @@ counts, so do not hesitate!
2. Fork `the repository <https://github.com/tmbo/questionary>`_ on GitHub to
start making your changes.

3. Write some tests that show the bug is fixed or that the feature works as
3. `Install Poetry <https://python-poetry.org/docs/#installation>`_.

4. Configure development environment.

.. code-block:: console
make develop
5. Write some tests that show the bug is fixed or that the feature works as
expected.

4. Ensure your code passes the style checks by running
6. Ensure your code passes the code quality checks by running

.. code-block:: console
$ black questionary
$ make lint
5. Check all of the unit tests pass by running
7. Check all of the unit tests pass by running

.. code-block:: console
$ pytest --pycodestyle --cov questionary -v
$ make test
6. Check the type checks pass by running
8. Check the type checks pass by running

.. code-block:: console
$ mypy questionary
$ make types
7. Send a pull request and bug the maintainer until it gets merged and
9. Send a pull request and bug the maintainer until it gets merged and
published 🙂

.. _`contributor friendly tag`: https://github.com/tmbo/questionary/issues?direction=desc&labels=good+first+issue&page=1&sort=upd
Expand Down Expand Up @@ -81,13 +89,15 @@ Create a Command Line Recording
$ npm install --global asciicast2gif
2. Start the recording with ``asciinema``:

.. code-block:: console
$ asciinema rec
3. Do the thing you want to record.

4. Convert to gif using ``asciicast2gif``:

.. code-block:: console
$ asciicast2gif -h 7 -w 120 -s 2 <recording> output.gif
22 changes: 20 additions & 2 deletions examples/advanced_workflow.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from pprint import pprint
from questionary import Separator, prompt

from questionary import Separator
from questionary import prompt


def ask_dictstyle(**kwargs):
questions = [
{
# just print a message, don't ask a question
# does not require a name (but if provided, is ignored) and does not return a value
"type": "print",
"name": "intro",
"message": "This example demonstrates advanced features! 🦄",
"style": "bold italic",
},
{
"type": "confirm",
"name": "conditional_step",
Expand All @@ -25,6 +35,14 @@ def ask_dictstyle(**kwargs):
"message": "Select item",
"choices": ["item1", "item2", Separator(), "other"],
},
{
# just print a message, don't ask a question
# does not require a name and does not return a value
"type": "print",
"message": "Please enter a value for 'other'",
"style": "bold italic fg:darkred",
"when": lambda x: x["second_question"] == "other",
},
{
"type": "text",
# intentionally overwrites result from previous question
Expand All @@ -33,7 +51,7 @@ def ask_dictstyle(**kwargs):
"when": lambda x: x["second_question"] == "other",
},
]
return prompt(questions)
return prompt(questions, **kwargs)


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions examples/autocomplete_ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import questionary
from examples import custom_style_fancy

from questionary import Validator, ValidationError, prompt
from questionary import ValidationError
from questionary import Validator
from questionary import prompt


class PolyergusValidator(Validator):
Expand Down
4 changes: 3 additions & 1 deletion examples/checkbox_separators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import questionary
from examples import custom_style_dope
from questionary import Separator, Choice, prompt
from questionary import Choice
from questionary import Separator
from questionary import prompt


def ask_pystyle(**kwargs):
Expand Down
2 changes: 1 addition & 1 deletion examples/checkbox_toppings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from examples import custom_style_dope
import questionary
from examples import custom_style_dope

if __name__ == "__main__":
toppings = (
Expand Down
2 changes: 1 addition & 1 deletion examples/password_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import questionary
from examples import custom_style_dope
from questionary import Separator, Choice, prompt
from questionary import prompt


def ask_pystyle(**kwargs):
Expand Down
3 changes: 2 additions & 1 deletion examples/rawselect_separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import questionary
from examples import custom_style_dope
from questionary import Separator, Choice, prompt
from questionary import Separator
from questionary import prompt


def ask_pystyle(**kwargs):
Expand Down
4 changes: 3 additions & 1 deletion examples/select_restaurant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import questionary
from examples import custom_style_dope
from questionary import Separator, Choice, prompt
from questionary import Choice
from questionary import Separator
from questionary import prompt


def ask_pystyle(**kwargs):
Expand Down
4 changes: 3 additions & 1 deletion examples/text_phone_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import questionary
from examples import custom_style_dope
from questionary import Validator, ValidationError, prompt
from questionary import ValidationError
from questionary import Validator
from questionary import prompt


class PhoneNumberValidator(Validator):
Expand Down

0 comments on commit b8893cd

Please sign in to comment.