-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Hello,
I receive the error in the title from LGTM.com when subclassing the HTMLParser class. Should HTMLParser technically be calling: super().__init__()
, or something similar, in its own initialiser? I know adding this call won't improve the functionality as the BaseParser initialiser does nothing of interest for subclasses, but I guess it would stop annoying errors like this.
Relevant code is here:
Lines 62 to 93 in eb81c1a
class HTMLParser(_markupbase.ParserBase): | |
"""Find tags and other markup and call handler functions. | |
Usage: | |
p = HTMLParser() | |
p.feed(data) | |
... | |
p.close() | |
Start tags are handled by calling self.handle_starttag() or | |
self.handle_startendtag(); end tags by self.handle_endtag(). The | |
data between tags is passed from the parser to the derived class | |
by calling self.handle_data() with the data as argument (the data | |
may be split up in arbitrary chunks). If convert_charrefs is | |
True the character references are converted automatically to the | |
corresponding Unicode character (and self.handle_data() is no | |
longer split in chunks), otherwise they are passed by calling | |
self.handle_entityref() or self.handle_charref() with the string | |
containing respectively the named or numeric reference as the | |
argument. | |
""" | |
CDATA_CONTENT_ELEMENTS = ("script", "style") | |
def __init__(self, *, convert_charrefs=True): | |
"""Initialize and reset this instance. | |
If convert_charrefs is True (the default), all character references | |
are automatically converted to the corresponding Unicode characters. | |
""" | |
self.convert_charrefs = convert_charrefs | |
self.reset() |
And here:
Lines 23 to 30 in eb81c1a
class ParserBase: | |
"""Parser base class which provides some common support methods used | |
by the SGML/HTML and XHTML parsers.""" | |
def __init__(self): | |
if self.__class__ is ParserBase: | |
raise RuntimeError( | |
"_markupbase.ParserBase must be subclassed") |
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done