Skip to content

Commit

Permalink
Improve type safety for latest bs4 version
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffy-critter committed Feb 23, 2025
1 parent 85357f8 commit cfb257d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions publ/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional

import arrow
import bs4
import flask
import itsdangerous
import requests
Expand Down Expand Up @@ -150,9 +151,10 @@ def get_ticket_endpoint(me_url: str):
if req.links and 'canonical' in req.links:
canonical_url = req.links['canonical']['url']
else:
link = content.find('link', rel='canonical')
link = typing.cast(bs4.Tag, content.find('link', rel='canonical'))
if link:
canonical_url = urllib.parse.urljoin(me_url, link.get('href'))
canonical_url = urllib.parse.urljoin(me_url,
typing.cast(str, link.get('href')))
else:
canonical_url = me_url

Expand Down

0 comments on commit cfb257d

Please sign in to comment.