Skip to content

Export types from library for type checking #62

@charpercyr

Description

@charpercyr

I am writing a logger with termcolor, and want to use Attribute, Color & Highlight from termcolor._types.
I am using mypy with aggressive type-checking so it will not type check unless I import the types (or ignore the error).

class ColorFormatter:
    FORMATS: ClassVar[dict[int, tuple[Color, list[Attribute] | None]]] = {
        logging.DEBUG: ("grey", None),
        logging.INFO: ("white", None),
        logging.WARNING: ("yellow", ["bold"]),
        logging.ERROR: ("red", ["bold"]),
        logging.CRITICAL: ("magenta", ["underline", "bold"]),
    }

Is it possible to export the types from __init__.py?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions