I played around with the new colorful types and there is a interesting problem.
Colorful takes full advantage of __getattr__ and im a bit out of ideas how to type this.
Common usage is (also seen in the readme):
import colorful as cf
print(cf.bold_white('Hello World'))
Where bold_white is dynamically build with the dynamically loadable color plate and a modifier.
Which makes this valid working python code:
import colorful as cf
print(cf.bold_underlined_struckthrough_italic_bold_red("typeshed"))
where the color from the pallet is red and the modifiers are separated by a _ and need to be out of a list of MODIFIERS but otherwise can be combined in any order and even be repeated.
MODIFIERS = {
'reset': (0, 0),
'bold': (1, 22),
'dimmed': (2, 22),
'italic': (3, 23),
'underlined': (4, 24),
'blinkslow': (5, 25),
'blinkrapid': (6, 25),
'inversed': (7, 27),
'concealed': (8, 28),
'struckthrough': (9, 29)
}
Is there any good solution to type something this dynamic?
Or is the only way to kinda allow everything after colorful.<anything>
I played around with the new colorful types and there is a interesting problem.
Colorful takes full advantage of
__getattr__and im a bit out of ideas how to type this.Common usage is (also seen in the readme):
Where
bold_whiteis dynamically build with the dynamically loadable color plate and a modifier.Which makes this valid working python code:
where the color from the pallet is
redand the modifiers are separated by a_and need to be out of a list ofMODIFIERSbut otherwise can be combined in any order and even be repeated.Is there any good solution to type something this dynamic?
Or is the only way to kinda allow everything after
colorful.<anything>