Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unfortunately that prevents Mypy from loading the type hints for 'markdown'

    from types import ModuleType

    markdown: ModuleType | None

    try:
        import markdown  # type: ignore [no-redef]
    except ImportError:
        markdown = None

    if markdown is not None:
        reveal_type(markdown.markdown)
Running Mypy:

    example.py:11: note: Revealed type is "Any"
Whereas when correctly imported:

    example.py:3: note: Revealed type is "def (text: builtins.str, *, extensions: Union[typing.Sequence[Union[builtins.str, markdown.extensions.Extension]], None] =, extension_configs: Union[typing.Mapping[builtins.str, typing.Mapping[builtins.str, Any]], None] =, output_format: Union[Literal['xhtml'], Literal['html'], None] =, tab_length: Union[builtins.int, None] =) -> builtins.str"


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: