Page Source example:
```lang-python
from bs4 import BeautifulSoup, Tag, ResultSet
from re import compile
page_source = """
<html>
<body>
<div class="block_general_statistics">
<table>
<tbody>
<tr>
<th>Header 1</th>
<td class="total">Data 1</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
"""
```
Original use to reduce the number of lines and characters but which generate Type Checking alerts and also note that `find | text | strip` inside the list comprehension all of these the font color is white due to lack of necessary combination:
```lang-pyton
soup = BeautifulSoup(page_source, 'html.parser')
table_stats = soup.find('div', class_=compile('block_general_statistics')).find('table')
table_stats_body = table_stats.find('tbody').find_all('tr')
thead = [th.find('th').text.strip() for th in table_stats_body]
tbody = [th.find('td', class_='total').text.strip() for th in table_stats_body]
```
![cKpgY.png](https://groups.google.com/group/beautifulsoup/attach/2ef7463d6c2b7/cKpgY.png?part=0.1&view=1)
![7TqfR.png](https://groups.google.com/group/beautifulsoup/attach/2ef7463d6c2b7/7TqfR.png?part=0.2&view=1)
The only way that with my basic knowledge I was able to resolve all the alerts and also fix all fonts colored correctly without any being white due to "lack of function":
```lang-python
soup = BeautifulSoup(page_source, 'html.parser')
table_stats = soup.find('div', class_=compile('block_general_statistics'))
if type(table_stats) == Tag:
table_stats = table_stats.find('table')
if type(table_stats) == Tag:
table_stats_body = table_stats.find('tbody')
if type(table_stats_body) == Tag:
table_stats_body = table_stats_body.find_all('tr')
if type(table_stats_body) == ResultSet:
thead = []
for th in table_stats_body:
if type(th) == Tag:
th = th.find('th')
if type(th) == Tag:
thead.append(th.text.strip())
tbody = []
for th in table_stats_body:
if type(th) == Tag:
th = th.find('td', class_='total')
if type(th) == Tag:
tbody.append(th.text.strip())
```
Is there any smarter way that can resolve the alerts but that doesn't make a simple, short code become something so large, detailed and even difficult to make changes in the future?
StackOverflow:
https://stackoverflow.com/questions/78147561/how-working-correctly-with-beautifulsoup-to-not-generate-type-checking-alerts-in