-
-
Notifications
You must be signed in to change notification settings - Fork 48
BS4 4.13 breaks internal typing #278
Description
BS4 now ships with type hints, but one particular change is wreaking havoc on our typing.
BS4 now returns PageElement for almost everything as Tags and Navigable strings both inherit from these. But these are distinctly different types with their own functions.
So right now, when we expect a Tag object or a NavigableString, we get an error because BS4 says it returns a PageElement.
We have functions that check is_tag etc., but mypy can't see figure this out and requires explicit inline checks for it to be able to figure stuff out. This is some of the pain of Python's typing system, it's helpful, but sometimes too dumb to be helpful in a meaningful sense. Anyway, we have a lot to fix because of this :(. I want to like typing so much, but stuff like this causes unnecessary churn. If only these tools were smart enough to see what was actually being used.