Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BS4 4.13 breaks internal typing #278

Closed
facelessuser opened this issue Feb 18, 2025 · 2 comments · Fixed by #279
Closed

BS4 4.13 breaks internal typing #278

facelessuser opened this issue Feb 18, 2025 · 2 comments · Fixed by #279
Labels
S: triage Issue needs triage.

Comments

@facelessuser
Copy link
Owner

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.

@gir-bot gir-bot added the S: triage Issue needs triage. label Feb 18, 2025
@facelessuser
Copy link
Owner Author

It should be noted that nothing functionally is broken, all tests pass, just not type checks.

@facelessuser
Copy link
Owner Author

Despite my complaints, we are finding some good type errors, so it isn't all bad :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: triage Issue needs triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants