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
Export types from library for type checking #62
Comments
It's hard to use termcolor 2.4 in statically typed codebases without this. Personally, I think it might be nice to not use literal types here at all, not sure it's worth the pain. |
At the end I copied the literal types. Is there a better solution? Color = Literal[
"black",
# ...
"white",
]
Highlight = Literal[
"on_black",
# ...
"on_white",
]
def color(
text: str, color: Optional[Color] = None, on_color: Optional[Highlight] = None
) -> str:
"""Wrapper function around ``termcolor.colored()`` to easily turn off and
on colorized terminal output on the command line.
"""
settings = get_args()
if settings.general_colorize:
return termcolor.colored(text, color, on_color)
else:
return text |
+1 |
Maybe we should remove/replace these literal types? @hauntsaninja Would you like to propose something in a PR? (Ref to where they were added: #44) |
I am writing a logger with termcolor, and want to use
Attribute
,Color
&Highlight
fromtermcolor._types
.I am using mypy with aggressive type-checking so it will not type check unless I import the types (or ignore the error).
Is it possible to export the types from
__init__.py
?The text was updated successfully, but these errors were encountered: