PyInquirer
PyInquirer copied to clipboard
Editor example does not work
PyInquirer/examples/editor.py does not work :(
(newcli-dev) ➜ ~ python cli.py
Traceback (most recent call last):
File "cli.py", line 27, in <module>
answers = prompt(questions, style=custom_style_2)
File "/Users/igor/PythonEnvs/newcli-dev/lib/python3.7/site-packages/PyInquirer/prompt.py", line 67, in prompt
application = getattr(prompts, type).question(message, **_kwargs)
File "/Users/igor/PythonEnvs/newcli-dev/lib/python3.7/site-packages/PyInquirer/prompts/editor.py", line 139, in question
if issubclass(validate_prompt, Validator):
File "/Users/igor/PythonEnvs/newcli-dev/bin/../lib/python3.7/abc.py", line 143, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
Python 3.7.1 PyInquirer==1.0.3
Can you please share your environment details. @igor-egorov
Same here, Python 3.7.1 64 bits on win10, clean virtualenv
I will check this, been off coding for two months.
I was getting the same error. You fixed the source of the error on May 28, 2019 (https://github.com/CITGuru/PyInquirer/commit/9e9efaa13b05925bb055d4aacdee55945717e930), but the latest release on PyPi is from 2018. The error goes away if I change the offending line. I ended up just git cloning the latest commit and installing it from the local folder.
Same here. I get the error with the PyPI version of PyInquirer under Python 3.7.
Instead of @nesadi approach, you can also just pass a Validator into the 'validate' key...
from PyInquirer import prompt, Validator, ValidationError
...
class ValidateEditor(Validator):
def validate(self, document):
if document.text and len(document.text.split('\n')) <= 1:
raise ValidationError(
message='Must be at least 1 line', cursor_position=len(document.text))
...
def askPaste():
questions = [
{
'name': 'content',
'type': 'editor',
'message': 'Opening editor',
# lambda text: len(text.split('\n')) >= 1 or 'Must be at least 1 line',
'validate': ValidateEditor,
'eargs': {
'editor': 'default',
'ext': '.tmp'
},
},
]
return prompt(questions)
@CITGuru Could we please get a new release to PyPi that includes 9e9efaa1 ? Many uses of the editor prompt are broken otherwise. Thanks!