Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor example does not work #70

Open
igor-egorov opened this issue Jul 19, 2019 · 7 comments
Open

Editor example does not work #70

igor-egorov opened this issue Jul 19, 2019 · 7 comments

Comments

@igor-egorov
Copy link

igor-egorov commented Jul 19, 2019

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

@CITGuru
Copy link
Owner

CITGuru commented Aug 7, 2019

Can you please share your environment details. @igor-egorov

@nicola-zanardi
Copy link

Same here, Python 3.7.1 64 bits on win10, clean virtualenv

@CITGuru
Copy link
Owner

CITGuru commented Aug 21, 2019

I will check this, been off coding for two months.

@ghost
Copy link

ghost commented Oct 25, 2019

I was getting the same error. You fixed the source of the error on May 28, 2019 (9e9efaa), 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.

@halloleo
Copy link

halloleo commented Dec 13, 2019

Same here. I get the error with the PyPI version of PyInquirer under Python 3.7.

@jessedp
Copy link

jessedp commented May 17, 2020

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)

@cachedout
Copy link

@CITGuru Could we please get a new release to PyPi that includes 9e9efaa ? Many uses of the editor prompt are broken otherwise. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants