Incorrect return annotation in functions find() and find_all()

Bug #2072767 reported by Lemonade
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
New
Undecided
Unassigned

Bug Description

When I was coding in my IDE I noticed that I get an error here but code still works just fine:

subsections = html.find_all("div", class_="subSection detailBox")
    for subsection in subsections:
        subsection_title: str = subsection.find("div", class_="subSectionTitle").text.strip()

        link_objects = subsection.find_all("a", class_="modalContentLink")
        name_objects = subsection.find_all("b")
        links: list[str] = [obj.get("href") for obj in link_objects]
        names: list[str] = [obj.text for obj in name_objects if obj.text != ""]

Unresolved attribute reference 'find' for class 'PageElement'
Unresolved attribute reference 'find_all' for class 'PageElement'

The reason why is because return annotation in these functions are Optional[PageElement] and ResultSet[PageElement] respectively.

I ran print(isinstance(subsection, bs4.Tag)) and it returned True.
To solve this issue I simply changed [PageElement] to [Tag] in bs4 element.py file

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.