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

python line-by-line execution fails to detect closing paren #1811

Closed
jjallaire opened this issue Nov 11, 2023 · 3 comments
Closed

python line-by-line execution fails to detect closing paren #1811

jjallaire opened this issue Nov 11, 2023 · 3 comments
Assignees
Labels
bug Something isn't working lang: python
Milestone

Comments

@jjallaire
Copy link
Contributor

For this code:

from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
    {"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
  ]
)

If I attempt to execute line-by-line, when I get tot the third line the text passed to the console does not include the trailing paren (so it doesn't execute):

Screen Shot 2023-11-11 at 7 14 00 AM
@seeM
Copy link
Contributor

seeM commented Nov 13, 2023

I'm happy to look into this next, after finishing off my current work on improved support in Positron for the %% cell format.

This is related to #1260, and seems to be the same bug as described in #1260 (comment).

We could extend our current Python statement range provider to fix these issues, but a more robust course of action may be to look into plumbing into the Python extension's new "smart send" feature as suggested in #1260 (comment). Here's the PR that introduced that: microsoft/vscode-python#21779.

@seeM seeM added the bug Something isn't working label Nov 13, 2023
@seeM seeM added this to the Internal Preview milestone Nov 13, 2023
@jjallaire
Copy link
Contributor Author

I would agree that the best thing to do here is plumb in the Python extensions "smart send"

@juliasilge
Copy link
Contributor

In build 1368 I can use cmd + enter to send the entire statement together, including the closing parenthesis:

openai

Apparently I don't have billing set up correctly for my OpenAI key for this particular model 😄 but the statement range execution is working as expected.

@wesm wesm added lang: python bug Something isn't working and removed bug Something isn't working labels Feb 29, 2024
wesm pushed a commit that referenced this issue Mar 28, 2024
…er statement range detection

Merge pull request #259 from posit-dev/smart-send

Use "smart send" for Cmd+Enter statement range detection
--------------------
Commit message for posit-dev/positron-python@8a7f634:

fix merge issues

--------------------
Commit message for posit-dev/positron-python@a6ead38:

Merge remote-tracking branch 'origin/main' into smart-send

--------------------
Commit message for posit-dev/positron-python@96f3ed2:

fix excluding closing token

Addresses #1811.

--------------------
Commit message for posit-dev/positron-python@7872ce0:

use smart send feature in positron statement range provider


Authored-by: Wasim Lorgat <[email protected]>
Signed-off-by: Wasim Lorgat <[email protected]>
wesm pushed a commit that referenced this issue Mar 28, 2024
…er statement range detection

Merge pull request #259 from posit-dev/smart-send

Use "smart send" for Cmd+Enter statement range detection
--------------------
Commit message for posit-dev/positron-python@8a7f634:

fix merge issues

--------------------
Commit message for posit-dev/positron-python@a6ead38:

Merge remote-tracking branch 'origin/main' into smart-send

--------------------
Commit message for posit-dev/positron-python@96f3ed2:

fix excluding closing token

Addresses #1811.

--------------------
Commit message for posit-dev/positron-python@7872ce0:

use smart send feature in positron statement range provider


Authored-by: Wasim Lorgat <[email protected]>
Signed-off-by: Wasim Lorgat <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lang: python
Projects
None yet
Development

No branches or pull requests

5 participants