Hacker Newsnew | past | comments | ask | show | jobs | submit | adamchainz's commentslogin

Yeah, that is odd. Python still has no immutable dict type, except it kinda does: https://adamj.eu/tech/2022/01/05/how-to-make-immutable-dict-...


Within the function, args is a tuple, as your output demonstrates.


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"


Ah yes, nice hint that backports can use sys.version_info.


It will work but Mypy won't know to use the type hints for the markdown module.


Here’s my post summarizing new testing features in Django 4.0: https://adamj.eu/tech/2021/09/28/new-testing-features-in-dja...


Great news. Have been watching for a while and looking forward to using it now that it's fully released.


Awesome, basically a free book chapter. Will definitely fire up the notebook and give this a try.


I learnt a lot from the book Data Science at the Command Line, now free and online at https://www.datascienceatthecommandline.com/


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

Search: