Color problem in python script


#1

Hi,

I just switched from Sublime Text to Atom and find it so far great. I have run into an inconvenience, though.

Here is a print screen of a piece of code. As we can see I have a problem in the coloring of the 8th line, where the editor doesn’t consider the string passed to the query variable as a string, or I don’t know what happens, the thing is it considers the rest of the script as a text or at least show it that way:

image

Aside from the styling, the script runs just fine, so there is nothing wrong with it.

For testing purposes, in case, here is the script:

 with open(liste[0], newline='') as f:
    donnees = csv.reader(f, delimiter = ";")
    liste = list(donnees)
    #liste = [sublist for sublist in liste]
    for line in liste[1:]:
        if len(line) >= 3 and line[3] in ('01071','01078') :
            print(line[5])
            query = "INSERT INTO ipe VALUES ("

            for data in line:
                data = data.replace("'","''")
                data = data.replace(',', '.')
                if data == '':
                    data = 'null'
                    query = query + data + ", "
                else :
                    query = query + "'" + data + "'" + ", "
            query = query[:-2] + ");\n"
            cmd_insert = cmd_insert + query
cmd_insert = "TRUNCATE TABLE ipe;" + cmd_insert

Thanks


#2

This is a regression introduced in Atom v1.25 (it works fine in v1.24), which saw some improvements to the Python language package.

The Python and HTML language packages got some love in this release. When editing Python source, the tokenizer now supports function annotations, async functions, string formatting, f-strings, and binary strings. Within HTML documents, style attributes are tokenized as CSS.

See this existing issue on GitHub:


#3

Thank you for your answer. It does indeed looks like exactly the problem I am facing, and as a matter of fact I noticed it happening also in html scripts.

I am new to this, so, what now ? I wait for the next version hoping it will be solved ?


#4

Unless you want to try to solve it, yes. You could also install an old version of the package, or switch to a different one like magicpython (which is what I use).