Comments (12)
hey man, First of all, this is a great plugin!! Probably the top plugin. But, unfortunately, this bug is turning out to be a bummer. I use semshi daily since I code in nvim and this is messing up the beautiful highlightings 😞.
I'll definitely try something out from my end but I'm a beginner so let me see.
Also hope your doing well with pandemic going on
well wishes 😄
from semshi.
I filed a bug: https://bugs.python.org/issue35212
from semshi.
Ha! Thanks for catching this. I'll look into it. (Unless someone else wants to supply a patch...)
from semshi.
I'm wondering if that's actually a bug in Python. Compare these two syntax trees:
>>> ast.parse("f'{a}'")
Module(
body=[
Expr(
lineno=1,
col_offset=0,
value=JoinedStr(
lineno=1,
col_offset=0,
values=[
FormattedValue(
lineno=1,
col_offset=0,
value=Name(lineno=1, col_offset=3, id='a', ctx=Load()),
conversion=-1,
format_spec=None,
),
],
),
),
],
)
>>> ast.parse("f'{a:b}'")
Module(
body=[
Expr(
lineno=1,
col_offset=0,
value=JoinedStr( col_offset=0,
lineno=1,
col_offset=0,
values=[
FormattedValue(
lineno=1,
col_offset=0,
value=Name(lineno=1, col_offset=1, id='a', ctx=Load()),
conversion=-1,
format_spec=JoinedStr(
lineno=1,
col_offset=0,
values=[Str(lineno=1, col_offset=0, s='b')],
),
),
],
),
),
],
)
The relevant part here is that the name a
in the first f-string is positioned at
Name(lineno=1, col_offset=3, id='a', ctx=Load())
but in the second one at
Name(lineno=1, col_offset=1, id='a', ctx=Load())
although we're just adding a format specifier, not changing the position of the name in the source. To me it seems like the the column offset should remain at 3 chars. (Because f'{
are three characters.)
Can someone have a look at this as well? I'm tempted to file an issue in the Python tracker, but I may be overlooking something.
from semshi.
Sorry I just went though python tutorial, can't help at all.
from semshi.
hmm I am getting this as well :D... seems like the bug is still not fixed from Python side :(...
from semshi.
I'm currently experimenting with a parser based on tree-sitter instead of relying on Python's AST module. Once implemented, that would also eliminate bugs like this one.
from semshi.
I'm currently experimenting with a parser based on tree-sitter instead of relying on Python's AST module. Once implemented, that would also eliminate bugs like this one.
I suggest putting this behind a feature flag and have a default value to be which ever one is more stable. Sure tree-sitter may work but I think Python AST may stick closer with the language to help with newer syntax(s) in the future
from semshi.
I'm seeing this as well - semshi is a great plugin, but this is really distracting. f-strings are all over my code. Looking into it a little..
Seems there's more going on beyond the case listed above. I think maybe it's not a bug in Python and your logic needs to detect format_spec is not None
and have different behavior in that case.
Integrating a completely different solution (tree-sitter via built-in ast), imo, seems risky.
from semshi.
I have the same problem, does everyone have it? :(
from semshi.
More complaining about this bug. Any updates? This really makes me avoid f-strings, which is a shame.
Otherwise, love this plugin!!
from semshi.
As of August 2021, this has been fixed in python upstream:
bpo-44885 (python/cpython#89048) -- fixed by python/cpython#27729.
- python 3.9.7+
- python 3.10.0 or higher
from semshi.
Related Issues (20)
- SemshiTextChanged Error when enter completion from compe-nvim in nvim 0.5? HOT 14
- AttributeError: 'NoneType' object has no attribute 'viewport' HOT 1
- How to use semshi in venv? HOT 2
- Semshi enable command not recognised HOT 2
- Highlights out of sync after reloading buffer
- Unresolved Global Yellow Underline When Importing * HOT 1
- Does this work with vim or just neovim? HOT 3
- Semshi produces errors with __future__ annotations HOT 11
- Way to disable syntax error highlighting in insert mode? HOT 2
- `and` and `or` how to highlight? HOT 1
- hi semshiLocal is ineffective at changing the highlight for local variables
- Error detected while processing function <SNR>52_filetype_changed HOT 1
- Any plans to python 3.10 new syntax support? HOT 3
- Is there a license for this project?
- Is there any chance of implementing new tree sitter functionality? HOT 3
- Semshi starts to highlight only after call :PlugInstall HOT 4
- Support for fenced codeblocks in markdown
- Is this repository still actively maintained? HOT 1
- error when using ipdb HOT 1
- Async request caused an error: Invalid buffer id Part 2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semshi.