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

Documentation & autocomplete work for code inside string literals #1226

Open
ForceBru opened this issue Apr 25, 2024 · 2 comments
Open

Documentation & autocomplete work for code inside string literals #1226

ForceBru opened this issue Apr 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ForceBru
Copy link

Describe the bug

I have this multiline string literal in a single cell:

"""
def thing(self):
    return str
"""
  • When I mouse over return and str, corresponding documentation windows pop up. However, there's no documentation popup for def.
  • When I start typing + o| after str, I get autocomplete suggestions for object, oct, etc.
  • Basically I get the entire code editing experience within this string.

Another piece of code put into a multiline string:

"""
class Thing:
  def thing(self):
      return str
"""

With this, I'm now getting documentation for def, along with the above.

However, these are just strings, not code, so autocomplete & documentation popups probably shouldn't be active here.

Environment

{
  "marimo": "0.4.4",
  "OS": "Darwin",
  "OS Version": "22.6.0",
  "Processor": "i386",
  "Python Version": "3.12.1",
  "Binaries": {
    "Browser": "--",
    "Node": "--"
  },
  "Requirements": {
    "click": "8.1.7",
    "importlib-resources": "missing",
    "jedi": "0.19.1",
    "markdown": "3.6",
    "pymdown-extensions": "10.7.1",
    "pygments": "2.17.2",
    "tomlkit": "0.12.4",
    "uvicorn": "0.29.0",
    "starlette": "0.37.2",
    "websocket": "missing",
    "typing-extensions": "4.10.0",
    "black": "24.2.0"
  }
}

Code to reproduce

No response

@ForceBru ForceBru added the bug Something isn't working label Apr 25, 2024
@mscolnick
Copy link
Contributor

Is this annoying or unexpected? I havent noticed this since I don't write too many comments in notebooks. It could be seen as a nice feature to have autocomplete in the docs though (assuming its not annoying)

We send only the code prior to the cursor to jedi, so it may not consider the string being closed and hence thinking it actual code.

@ForceBru
Copy link
Author

Is this annoying or unexpected?

Not annoying at all, it's just something I found a little weird and indeed unexpected because string literals probably aren't meant to be parsed at all. Perhaps some resources are wasted by parsing them. Otherwise it could very well be a feature because it doesn't really break anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants