Sublime Forum

Broken python syntax highlighting

#1

Hi,

When using Python3 type hints ( “: str”) like in :

[code]def loadControllerConfigFromFile(filename : str) -> dict:

with open(filename) as f:
    data = f.read()

    data = toml.loads( data )

    return data

Node

- virtual

- physical

[/code]
Sublime’s highlighting gets crazy and for instance the comments are not recognized as such. I am using SublimeText3
Any idea how to fix this ?

Regards
Matt

0 Likes

#2

ST Python doesn’t support all of the Python 3 features, but I recently added support in MattDMo’s plugin sublime.wbond.net/packages/Python%20Improved

[pre=#232628]def loadControllerConfigFromFile(filename : str) -> dict:

with open(filename) as f:
    data = f.read()

    data = toml.loads( data )

    return data

Node

- virtual

- physical[/pre]

0 Likes

#3

Brilliant ! Thanks a lot it works.

0 Likes

#4

Just in case you wanna improve your highlighter, NotImplementedError() used to be in Blue with ST3 native highlighter while with yours it does not seem recognized (blank).
http://img4.hostingpics.net/thumbs/mini_82049020131218161230428x245scrot.png

0 Likes

#5

Works fine here (probably your theme doesn’t support the changes in Python Improved):

[pre=#232628] def _make(self, iterable):
raise NotImplementedError

    def _replace(self, **kwargs):
        raise NotImplementedError

    def __lt__(self, other):
        raise NotImplementedError("Cannot compare enumvalue differences directly! use enumvalue.value or int(enumvalue) instead.")[/pre]
0 Likes