Skip to content

Commit

Permalink
fix: mypy new version's complains
Browse files Browse the repository at this point in the history
  • Loading branch information
chemelli74 committed Sep 17, 2023
1 parent c88d9e4 commit b8a552d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
20 changes: 11 additions & 9 deletions src/aiovodafone/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ async def _find_login_url(self) -> str:
reply_text = await reply.text()
soup = bs4.BeautifulSoup(reply_text, "html.parser")
meta_refresh = soup.find("meta", {"http-equiv": "Refresh"})
if meta_refresh is not None:
meta_content = meta_refresh["content"]
reply_url = urllib.parse.parse_qs(meta_content, separator="; ")["URL"][0]
redirect_url = urllib.parse.urlparse(reply_url)
if type(meta_refresh) is bs4.Tag:
meta_content = meta_refresh.get("content")
reply_url = urllib.parse.parse_qs(str(meta_content), separator="; ")["URL"][
0
]
redirect_url = urllib.parse.urlparse(str(reply_url))
if redirect_url.scheme != self.protocol:
self.protocol = redirect_url.scheme
self.base_url = self._base_url()
Expand All @@ -101,7 +103,7 @@ async def _get_csrf_token(self, reply_text: str) -> None:
soup = bs4.BeautifulSoup(reply_text, "html.parser")
script_tag = soup.find("script", string=True)
try:
token = re.findall("(?<=csrf_token)|[^']+", script_tag.string)[1]
token = re.findall("(?<=csrf_token)|[^']+", str(script_tag))[1]
except IndexError:
raise ModelNotSupported
if not token:
Expand Down Expand Up @@ -141,11 +143,11 @@ async def _reset(self) -> bool:
"""Reset page content before loading."""

payload = {"chk_sys_busy": ""}
reply: aiohttp.ClientResponse = await self._post_page_result(
"/data/reset.json", payload, True
)
reply = await self._post_page_result("/data/reset.json", payload, True)
if type(reply) is aiohttp.ClientResponse:
return reply.status == 200

return reply.status == 200
return False

async def _login_json(self, username: str, password: str) -> bool:
"""Login via json page"""
Expand Down
14 changes: 7 additions & 7 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@


def test_objects_can_be_imported():
assert VodafoneStationDevice
assert VodafoneStationApi
assert VodafoneError
assert AlreadyLogged
assert CannotConnect
assert CannotAuthenticate
assert ModelNotSupported
assert type(VodafoneStationDevice)
assert type(VodafoneStationApi)
assert type(VodafoneError)
assert type(AlreadyLogged)
assert type(CannotConnect)
assert type(CannotAuthenticate)
assert type(ModelNotSupported)

0 comments on commit b8a552d

Please # to comment.