Optimize raw HTML post-processor by pawamoy · Pull Request #1510 · Python-Markdown/markdown (original) (raw)
Users running type checkers on their code is exactly what I expect, yes 😄 So, my opinion is, yes, lets keep lying about the type, and document that prominently (both with code comments and release/changelog notes).
Type correctness would otherwise mean that:
- we type the variables as
_BlockLevelElements
- which in turn means we'd have to document this class properly
- which in turn (probably) means we'd have to make it public
(also we'd likely want to use Self
from typing_extensions
as return annotation of methods retuning self
, which means an additional dependency depending on the Python version)
I know it's far from being exhaustive but a search on GitHub returns only one result for use of md.block_level_elements
(apart from @facelessuser's pymdownx which creates a new set from it, and discarding forks and venvs), and it's using remove, which is both a list and set method. That's IMO a strong indicator that md.block_level_elements
has very few uses in the wild, and so immediately advertising its type as set
should have a very small impact. I could be wrong though 🤷