Improve type annotations (add more and fix wrong ones) by oprypin · Pull Request #1394 · Python-Markdown/markdown (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation14 Commits6 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

oprypin

The origins of these are three-fold:

@oprypin

The origins of these are three-fold:

@waylan

So there appears to be a couple code changes included in this (I don't mean adjustments to whitespace/line length). Could you please remove those? They should be submitted separately.

@oprypin

@oprypin

I only recognized one change that's clearly not about type annotations and reverted it.

I'm not sure if you also mean the NamedTuple change (which I think is on topic, as it's just the way to spell the same thing but with type annotations) or if there was something else.

waylan

@waylan

I was thinking of the NameTuples, but you are correct, they do have type annotations. So nevermind on that.

oprypin

@oprypin

waylan

@waylan

Thanks for this. Some of the wrong annotations I completely missed.

I'll merge this after a changelog entry is added.

@oprypin

@oprypin

@oprypin

@oprypin

For future reference:

  1. The main reason that nobody complained about the current type annotations is probably that they aren't actually used by type checkers. Unless a file named py.typed exists, the dominant type checker "mypy" ignores the types and asks you to install https://pypi.org/project/types-Markdown/ anyway.
  2. If you are interested in a fully correct type-checked codebase (according to "mypy") as well as official external-facing type annotations support (by adding py.typed), let me know anytime, I can take up that task and help maintain this going forward. Otherwise that's all for now.

@waylan

Note that you have a conflict with the changelog (presumably with #1392).

Regarding a fully correct type-checked codebase (according to "mypy") that is probably a reasonable goal. Personally, I haven't really explored what's involved given that this is a rather new thing for Python. So contributions are welcome.

@oprypin

@oprypin

Note that you have a conflict with the changelog

Hm? I had already merged to resolve the conflict. There was just the spelling check failing

Regarding a fully correct type-checked codebase (according to "mypy") that is probably a reasonable goal.

Great, so I'll continue looking into this soon (in a separate PR)

@pawamoy

This PR almost closes #1389 🙂

@oprypin

Oh I didn't see that!
No there are still like 100 mypy errors so maybe not "almost" 😅

@pawamoy

Oh OK I thought there was just the py.typed file missing 😅