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

walrus detected incorrectly as keyword argument #250

Open
mgzenitech opened this issue Jan 5, 2023 · 6 comments
Open

walrus detected incorrectly as keyword argument #250

mgzenitech opened this issue Jan 5, 2023 · 6 comments

Comments

@mgzenitech
Copy link

    entrypoint_type: str = select(
        next_argument_number := next_argument_number + 1,
        "Please select entrypoint type:",
        [
            {
                "name": item.name,
                "value": item.name
            }
            for item in ENTRYPOINT_TEMPLATE_PATH.glob("*")
            if item.is_dir()
        ]
    )

2023-01-05 11:28:48  569x232
2023-01-05 11:29:13  547x41

@pappasam
Copy link
Owner

pappasam commented Jan 6, 2023

I believe this issue represents a limitation of our current syntax checking, which uses Python's built-in compile function, which is tied to the specific Python version that is running jedi-language-server itself: https://github.com/pappasam/jedi-language-server/pull/242/files

To get around this issue (for now), you'll need to either:

  1. install and run jedi-language-server with a version of Python that supports the Walrus operator and this specific use of it (3.8+, I'd guess)
  2. Disable jedi-language-server-provided diagnostics syntax checking using the provided initialization option (diagnostics.enable: false): https://github.com/pappasam/jedi-language-server#configuration

@davidhalter
Copy link

I feel like the walrus operator should be supported. This was a feature before 3.10... So I'm a bit confused. This is probably using Python pre-3.8.

@mgzenitech
Copy link
Author

mgzenitech commented Jan 6, 2023

2023-01-06 11:38:18  1312x1022
I am using Python 3.10.8

@davidhalter
Copy link

Is there a chance that you have a virtualenv or a way of running pre-3.8? Because it might somehow pick up an older environment for some reason.

@mgzenitech
Copy link
Author

As I said 3.10.8 in virtualenv (you can see the interpreter in screenshot bottom right corner)

@davidhalter
Copy link

Jedi has a separate subprocess, so there was a possibility that that somehow was broken.

However I was able to reproduce it with a very simple:

>>> import jedi
>>> x = jedi.Script('f(a := 1, b)\n').get_syntax_errors()
>>> x[0].get_message()
'SyntaxError: positional argument follows keyword argument'
>>> jedi.Script('f(a := 1)\n').get_syntax_errors()
[]

Note that Jedi/Parso can deal with walruses, it's just a small parso error. Created davidhalter/parso#212 for it.

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

3 participants