Alir3z4 / html2text

Convert HTML to Markdown-formatted text.
alir3z4.github.io/html2text/
GNU General Public License v3.0
1.85k stars 279 forks source link

Mypy reports ignore_anchors isn't an attribute #415

Open PanderMusubi opened 6 months ago

PanderMusubi commented 6 months ago

Mypy reports this error:

mypy a.py 
a.py:3: error: "HTML2Text" has no attribute "ignore_anchors"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

Version by html2text --version 2024.2.26

Python version python --version Python 3.10.12

Test script a.py

from html2text import HTML2Text
a = HTML2Text()
a.ignore_anchors = True
a.ignore_images = True
a.ignore_emphasis = True
a.ignore_tables = True
genevieve-me commented 5 months ago

I have a similar question about decode_errors. I initialize html2text = html2text.HTML2Text() and set some options html2text.single_line_break = True; html2text.decode_errors = "replace". However, looking at cli.py, it seems that unlike other options, decode_errors can only be passed as an arg, not set in this way?

https://github.com/Alir3z4/html2text/blob/8917f5c83d8cf013110124a6b37331b2c29a0fff/html2text/cli.py#L283

I would like to make use of this option even though I'm not running html2text from the CLI, so please let me know if I'm misunderstanding and how I can set it. Thank you!