Skip to content

Commit

Permalink
fixed PR comments and merged with magmax:main
Browse files Browse the repository at this point in the history
  • Loading branch information
NivEz committed Feb 3, 2023
1 parent bf20f55 commit fc055c1
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 25 deletions.
1 change: 0 additions & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pip==22.3.1
nox==2022.11.21
nox-poetry==1.0.2
poetry==1.2.2
virtualenv==20.17.1
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
pip --version
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/python-constraints.txt poetry
poetry --version
- name: Install Nox
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry==1.3.2
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pip install --constraint=.github/workflows/python-constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/python-constraints.txt poetry
poetry --version
- name: Install Nox
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/python-constraints.txt poetry
poetry --version
- name: Install Nox
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
furo==2022.12.7
myst_parser==0.18.1
sphinx==5.3.0
sphinx==6.1.3
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "inquirer"
version = "3.1.1"
version = "3.1.2"
description = "Collection of common interactive command line user interfaces, based on Inquirer.js"
authors = ["Miguel Ángel García <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions src/inquirer/render/console/_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Checkbox(BaseConsoleRender):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.locked = self.question.locked or []
self.selection = [k for (k, v) in enumerate(self.question.choices) if v in self.set_default_choices()]
self.selection = [k for (k, v) in enumerate(self.question.choices) if v in self.default_choices()]
self.current = 0

def set_default_choices(self):
def default_choices(self):
default = self.question.default or []
return default + self.locked

Expand Down
3 changes: 2 additions & 1 deletion src/inquirer/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def __init__(self):
self.Editor = collections.namedtuple("editor", "opening_prompt")
self.Checkbox = collections.namedtuple(
"common",
"selection_color selection_icon selected_color unselected_color selected_icon unselected_icon",
"selection_color selection_icon selected_color unselected_color "
"selected_icon unselected_icon locked_option_color",
)
self.List = collections.namedtuple("List", "selection_color selection_cursor unselected_color")

Expand Down
6 changes: 5 additions & 1 deletion tests/acceptance/test_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ def test_default_selection(self):
self.sut.send(key.ENTER)
self.sut.expect(r"{'courses': \['Programming fundamentals'\]}", timeout=1)

def test_locked_option(self):
def test_locked_option_space(self):
self.sut.send(key.SPACE)
self.sut.send(key.ENTER)
self.sut.expect(r"{'courses': \['Programming fundamentals'\]}", timeout=1)

def test_locked_option_left_key(self):
self.sut.send(key.LEFT)
self.sut.send(key.ENTER)
self.sut.expect(r"{'courses': \['Programming fundamentals'\]}", timeout=1)
Expand Down
18 changes: 16 additions & 2 deletions tests/integration/console_render/test_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,22 @@ def test_double_invert_all(self):

assert result == []

def test_unselect_locked(self):
stdin_array = [key.SPACE, key.LEFT, key.ENTER]
def test_unselect_locked_space(self):
stdin_array = [key.SPACE, key.ENTER]
stdin = helper.event_factory(*stdin_array)
message = "Foo message"
variable = "Bar variable"
choices = ["foo", "bar", "bazz"]

question = questions.Checkbox(variable, message, choices=choices, locked=["foo"])

sut = ConsoleRender(event_generator=stdin)
result = sut.render(question)

assert result == ["foo"]

def test_unselect_locked_left(self):
stdin_array = [key.LEFT, key.ENTER]
stdin = helper.event_factory(*stdin_array)
message = "Foo message"
variable = "Bar variable"
Expand Down

0 comments on commit fc055c1

Please sign in to comment.