language-python icon indicating copy to clipboard operation
language-python copied to clipboard

False positive for % formatting characters in strings

Open mcandre opened this issue 10 years ago • 1 comments

screenshot

language-python assumes that percent (%) characters always begin a C-style formatting string, though HTML-encoded strings are also common.

What's the best way to deal with this issue? Check for infix modulo % operator / .format method call? Turn C-style format highlighting off by default?

mcandre avatar Jul 15 '15 18:07 mcandre

Bumping this issue. Seems like this happens in regular strings that include the percent character as well: screen shot 2018-06-12 at 8 00 13 am This is on version 0.49.5 of language-python.

To verify the syntax, here's the shell output for the above command:

~ $ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> delayPct = 20.578
>>> print('{:3.1f}% delay'.format(delayPct))
20.6% delay

I checked some other editors, and it looks like this also happens in Sublime, but not in IDLE.

yahiaali avatar Jun 12 '18 12:06 yahiaali