-
Notifications
You must be signed in to change notification settings - Fork 771
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
Semantic Highlighting for Type Hints #335
Comments
Out of curiosity, why are you still using type comments? Are you stuck on an old version of Python? Since Python 3.6, variable type annotations can and should be provided using the new syntax in PEP 526. |
I used the type comments mainly because I was able to give them a different color based on TextMate Scopes. Not being able to customize the color for annotations made Django Model Definitions quite unreadable. I use annotations everywhere else though. |
Thanks. I'll investigate if we can make this customizable. |
@huguesv great 😁 self._identifier: int = MY_CONSTANT |
@huguesv It would be great to have a modifier for annotation type hints (same or different), the reason I went with comment hints in the first place was because TestMate didn't have a scope for annotation hints. Side Note: The reason I'm even putting type hints in Django Models is because even though the class attributes have types that are a subclass of orm |
@hassanselim0, the best way to declare Incidentally, there is a stub package available for django. That might save you a bunch of time. https://pypi.org/project/django-stubs/ |
We ship those stubs with pylance, so I would have expected for this to have worked (if the stub was defined in this way). |
I do have django stubs installed and working, but it doesn't do that behavior in my code. |
This would warrant another issue, yes, as it doesn't really fit within the bounds of the original semantic highlighting issue. |
Yeah, if you think that the type checker is not correctly handling |
Done, I've actually commented on a closed ticket about a very similar issue, so it can be reopened in case it's a regression. Getting back to the original issue, I still think it would be useful to have a semantic modifier for annotation type hints, so you can easily customize the colors for all type hints whether they are in an annotation or a comment. |
@huguesv thank you 😁 |
This issue has been fixed in version 2020.9.6, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202096-23-september-2020 |
@jakebailey @huguesv Thank you for your efforts, I just got around to testing this today and stumbled upon two issues. I set This is the first one: This is the second one: |
That's likely a bug; we'd appreciate a new issue for tracking. |
I recently updated to Pylance 2020.9.0 and I really like the Semantic Highlighting!
However it seems like type hints don't have any special semantic (usually it's a
class
) and I'm wanted type hints to have a different color than classes. Whether it's annotation type hints or comment type hints.Before this update, comment type hints had special TextMate scopes like
comment.typehint
andmeta.typehint
which I've customized, and now these are overridden by the semantic colors. Is it at least possible to still enforce my colors in this case?The text was updated successfully, but these errors were encountered: