Skip to content

Commit

Permalink
Remove support for custom lexers temporarily
Browse files Browse the repository at this point in the history
When tmbo/questionary#70 gets fixed, this commit should be rolled back.

For now, I have to remove this support because [otherwise I cannot publish Copier to Pypi](https://github.com/copier-org/copier/runs/1241180809?check_suite_focus=true).
  • Loading branch information
Jairo Llopis committed Oct 13, 2020
1 parent cda9327 commit 0d5c3e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
9 changes: 0 additions & 9 deletions copier/config/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from iteration_utilities import deepflatten
from jinja2 import UndefinedError
from jinja2.sandbox import SandboxedEnvironment
from prompt_toolkit.lexers import PygmentsLexer
from pydantic import BaseModel, Field, validator
from pygments.lexers.data import JsonLexer, YamlLexer
from questionary import prompt
from questionary.prompts.common import Choice
from yamlinclude import YamlIncludeConstructor
Expand Down Expand Up @@ -208,7 +206,6 @@ def get_placeholder(self) -> str:

def get_questionary_structure(self):
"""Get the question in a format that the questionary lib understands."""
lexer = None
result = {
"default": self.get_default(for_rendering=True),
"filter": self.filter_answer,
Expand All @@ -234,12 +231,6 @@ def get_questionary_structure(self):
if questionary_type == "input":
if self.secret:
questionary_type = "password"
elif self.type_name == "yaml":
lexer = PygmentsLexer(YamlLexer)
elif self.type_name == "json":
lexer = PygmentsLexer(JsonLexer)
if lexer:
result["lexer"] = lexer
result["multiline"] = self.get_multiline()
placeholder = self.get_placeholder()
if placeholder:
Expand Down
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.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jinja2 = "^2.11.2"
pathspec = "^0.8.0"
plumbum = "^1.6.9"
pydantic = "^1.5.1"
# HACK https://github.com/tmbo/questionary/pull/70
questionary = {git = "https://github.com/Yajo/questionary.git", rev = "text-custom-lexer"}
questionary = "^1.6.0"
pyyaml = "^5.3.1"
pyyaml-include = "^1.2"
# packaging is needed when installing from PyPI
Expand Down
12 changes: 12 additions & 0 deletions tests/test_prompt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import inspect
from pathlib import Path

import pexpect
import pytest
import yaml
from plumbum import local
from plumbum.cmd import git
from questionary.prompts.text import text

from .helpers import COPIER_PATH, Keyboard, build_file_tree

Expand Down Expand Up @@ -245,3 +247,13 @@ def test_multiline(tmp_path_factory, spawn, type_):
"question_4": ("answer 4"),
"question_5": ("answer 5"),
}


def questionary_supports_custom_lexer():
"""Check that questionary doesn't support custom lexers.
If this test fails, it means that https://github.com/tmbo/questionary/pull/70
was merged and then you should revert https://github.com/copier-org/copier/pull/289
to enable lexer support.
"""
assert "lexer" not in inspect.signature(text).parameters

0 comments on commit 0d5c3e8

Please sign in to comment.