Open
Conversation
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been experiencing errors when trying to run mypy checks against code using Marko.
I added some cast() and created type stubs to resolve the following issues:
1. Any Return Type Resolution
element.py:46cast(str, objstr(...))objstr()returnsAny, notstrhelpers.py:132cast(MarkoExtension, module.make_extension(...))Any2. Renderer Return Types
render()returnsAny-> strfor HTML/Markdown,-> dictfor ASTrender_children()ambiguousstr -> str,Element -> str/dictrender_*methods untyped-> strper renderer3. Block Element Attributes
BlockElementchildren,priority,virtual,inline_body,overrideDocumentlink_ref_defs: dict[str, tuple[str, str]]Headinglevel: int,inline_body: strCodeBlock/FencedCodelang: str,extra: str,children: list[Element]Listtight: bool,ordered: bool,start: int,bullet: strListItemParseInfoNamedTuple with typed fieldsLinkRefDeflabel: str,dest: str,title: str | None4. Inline Element Attributes
InlineElementpattern,parse_children,parse_group,children: str | Sequence[Element]Link/Imagedest: str,title: str | NoneCodeSpan/RawTextchildren: strAutoLinkdest: str,title: strLineBreaksoft: bool,children: str5. Inline Parser Infrastructure
Tokenetype,match,start,end,text,childrenDelimiterstart,end,content,can_open,can_closeMatchObjgroup(),start(),end(),span()methodsGroupNamedTuple(start, end, text)parse()ElementType6. Source Overloads
Error fixed:
str | Noneunion couldn't be narrowed based on argument7. Helper Functions
MarkoExtensionrenderer_mixins,parser_mixins,elementsload_extension()-> MarkoExtensionrender_dispatchcamel_to_snake_case()str -> strnormalize_label()str -> str8. Public API
Markdown.convert()str -> strMarkdown.parse()str -> DocumentMarkdown.render()Document -> strconvert,parse,renderSummary by File
block.pyimatch()/parse()returnsinline_parser.pyiinline.pyichildrenunionhelpers.pyimd_renderer.pyi-> strhtml_renderer.pyi-> strsource.pyinext_line()overloadsast_renderer.pyi-> dictvs-> stroverloads__init__.pyiMarkdownclass, module functionsrenderer.pyirender()signatureparser.pyiparse()returnsDocumentelement.pyiget_type(),__repr__()element.py,helpers.pyAny -> str,Any -> MarkoExtension