-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[colorize_ansi] Remove the possibility to use anything else than a MessageStyle #8412
[colorize_ansi] Remove the possibility to use anything else than a MessageStyle #8412
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8412 +/- ##
==========================================
+ Coverage 95.69% 95.71% +0.02%
==========================================
Files 175 175
Lines 18454 18451 -3
==========================================
+ Hits 17659 17660 +1
+ Misses 795 791 -4
|
pylint/reporters/text.py
Outdated
@@ -37,6 +37,24 @@ class MessageStyle(NamedTuple): | |||
style: tuple[str, ...] = () | |||
"""Tuple of style strings (see `ANSI_COLORS` for available values).""" | |||
|
|||
def get_ansi_code(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little complicated to make a public class function private (then we need to call it with .__MessageStyle_
... I'm wondering if we could use colorama
entirely instead. Or make this a public API, it's unlikely it's ever going away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your comment. We can just make the function private and keep MessageStyle
public right? We have similar patterns for all of our other classes: the class itself is public but not all method are public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> class MessageStyle:
... def __ansi_color(self):
... print("ansi")
...
>>> m = MessageStyle()
>>> m.__ansi_color()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'MessageStyle' object has no attribute '__ansi_color'
>>> m._MessageStyle__ansi_color()
ansi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant _get_ansi_code
. That signals that it is private and not part of MessageStyle
's API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha ok, I call that 'protected'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it could be made private with a small refactor f591319
This comment has been minimized.
This comment has been minimized.
690e59a
to
64e5b95
Compare
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit f591319 |
Type of Changes
Description
I think we could be a lot more liberal with the breaking change for small internal things like that.