Moved import and added ignore to BeautifulSoup type annotation issues

This commit is contained in:
2025-09-17 17:03:24 +02:00
parent 6bc406b70d
commit 421d635dd3
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -253,16 +253,16 @@ class BrickInstructions(object):
raw: list[tuple[str, str]] = []
for a in soup.find_all('a', href=link_re):
img = a.find('img', alt=True)
if not img or set not in img['alt']:
img = a.find('img', alt=True) # type: ignore
if not img or set not in img['alt']: # type: ignore
continue
# Turn the alt text into a slug
alt_text = img['alt'].removeprefix('LEGO Building Instructions for ')
alt_text = img['alt'].removeprefix('LEGO Building Instructions for ') # type: ignore
slug = re.sub(r'[^A-Za-z0-9]+', '-', alt_text).strip('-')
# Build the absolute download URL
download_url = urljoin('https://rebrickable.com', a['href'])
download_url = urljoin('https://rebrickable.com', a['href']) # type: ignore
raw.append((slug, download_url))
if not raw:
+1 -1
View File
@@ -1,3 +1,4 @@
import re
from sqlite3 import Row
from typing import Any, Generator, Generic, ItemsView, Self, TypeVar, TYPE_CHECKING
@@ -109,7 +110,6 @@ class BrickRecordList(Generic[T]):
main_sql = BrickSQL().load_query(list_query, **count_context)
# Remove ORDER BY, LIMIT, OFFSET clauses for counting
import re
# Remove ORDER BY clause and everything after it that's not part of subqueries
count_sql = re.sub(r'\s+ORDER\s+BY\s+[^)]*?(\s+LIMIT|\s+OFFSET|$)', r'\1', main_sql, flags=re.IGNORECASE)
# Remove LIMIT and OFFSET