Closed dunkmann00 closed 1 year ago
Hi @tancnle! Any thoughts on this or #1920?
Hi @tancnle! Any thoughts on this or #1920?
@dunkmann00 I will have a look at the PR sometime today. Sorry for the delay 🙇🏼♂️
@dunkmann00 Thank you for the contribution. The PR looks great to me.
Before | After |
---|---|
I have left a comment on the removal of self
.
Please let me know what you think about 2 and 3. 🙏🏼
@tancnle The added visual samples look great! I added one more to show that classes also get highlighted when they are created.
Before | After |
---|---|
Thank you for your effort on this @dunkmann00 🙇🏼 🚀
Thanks for reviewing, helping, and merging @tancnle!
This includes three changes to the Python lexer:
1) Move the
decorator
rule before theoperator
rule.Before this change, decorators were never getting recognized. This was because if there was ever an
@
, it was always satisfying theoperator
rule. This remedies that by first checking for thedecorator
pattern and then the operator pattern.2) Recognize functions and classes when they are called.
Previously, functions and classes were only recognized when they were defined. With this change, they will also be recognized and styled when they are called.
3) Don't recognize imported modules as
Namespace
s.It is not desirable to highlight imported modules like namespaces. With this change, they are simply recognized as the general
Name
token.4) Remove
self
from@builtins_pseudo
to prevent it from getting styledself
is not a built-in special variable in Python. It is just a local variable that is customarily used to indicate the calling object on an instance method. As such, it shouldn't be styled the same as actual built-in objects.