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

support for fstrings in python #21

Open
mchaptel opened this issue Dec 13, 2024 · 1 comment
Open

support for fstrings in python #21

mchaptel opened this issue Dec 13, 2024 · 1 comment

Comments

@mchaptel
Copy link

Hello, I just discovered your extension which totally solve my specific need to combine xml strings and python script perfectly, thanks a lot!

I had a question; would it be possible to support fstring synthax for mixing python and other formats? For ex since xml doesn't use the {} characters, I can inject python script into my strings easily if I use this syntax (sort of like html and js in jsx/react for example).

However, it seems that this is not supported by the extension which doesn't stop formatting the code in between the curly braces like it should.

ex:

my_xml = f"""<!--xml-->
<top_level>
    <my_tag param='{computed_value(arg1, arg2) == "result"}'/>
</top_level>
"""

Here, I would like the computed_value(arg1, arg2) == "result" part to follow python syntax highlighting instead of being formatted like xml. (kind of like we see above)

If that could be fixed, it would be very useful!

I also had a question, not really an issue: it seems code collapsing is blocked if using Pylance for the python intellisense. Is there any workaround?

@Andyrei
Copy link

Andyrei commented Dec 23, 2024

I encountered the same problem! I looked into the extension and there i found the support for the 'fstrings', 'rstrings', 'rfstrings' and so on here.

For some reason it gets through the query. This is my provisory solution till i can find the the reason it happens.

Hope someone with an a bigger intellectual capacity can find a permanent solution 🥲

query = f"""--sql
  SELECT o.date_order_iso 
  FROM orders o 
  WHERE id_platform=1 AND id_store={self.store_id} ORDER BY id_order DESC LIMIT 1
"""

query = query.replace('--sql', '').strip()

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

2 participants