timofurrer / colorful

Terminal string styling done right, in Python :snake: :tada:
MIT License
525 stars 23 forks source link

Please provide type stubs! #13

Closed devxpy closed 4 years ago

devxpy commented 6 years ago

Hello, thanks for this wonderful module!

Can we please have type stubs (.pyi files), to enable code-completion in IDEs?

timofurrer commented 5 years ago

You're very welcome!

Good point! I'll have a look at those!

devxpy commented 5 years ago

Apparently, this is physically impossible.

The package has a total of 4283792079344 possible permutations of methods available. Even if we wrote a script that automatically generate type stubs, this would be too large for anyone to parse xD

Fun stuff: Here is the script I used to arrive at that number -

from colorful.ansi import MODIFIERS 
from colorful.rgb import parse_rgb_txt_file 

num_colors = len(parse_rgb_txt_file("./colorful/data/rgb.txt")) 
num_modifers = len(MODIFIERS) 

modifier_permuations = 0 

for i in range(1, num_modifers + 1): 
    m = 1 
    for j in range(num_modifers, num_modifers - i, -1): 
        m *= j 
    modifier_permuations += m 

total = ( 
    modifier_permuations 
    + num_colors * 2 
    + modifier_permuations * num_colors * 2 
    + num_colors * num_colors * 2 
    + modifier_permuations * num_colors * num_colors 
) 

print(total) 
devxpy commented 5 years ago

Wait, maybe we can have at least a subset of the API that's commonly used.

timofurrer commented 5 years ago

Yes, that's right - big number 😄

Wait, maybe we can have at least a subset of the API that's commonly used.

Which API did you have in mind? "common" like the "common" colors people might use?

devxpy commented 5 years ago

Yes common colors and modifiers..

bmoeskau commented 5 years ago

A simple templated file would be useful. I use a dozen or so color combos, and I would be happy to add type definitions manually to make PyCharm happy if I knew the proper location and format to use. Thanks for the useful library!

github-actions[bot] commented 5 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] commented 5 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] commented 4 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days