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

Fix typing information to please pyright #644

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flathunter/crawler/wggesucht.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(self, config):
self.config = config

# pylint: disable=too-many-locals
def extract_data(self, soup: BeautifulSoup):
def extract_data(self, soup: BeautifulSoup) -> List[Dict]:
"""Extracts all exposes from a provided Soup object"""
entries = []

Expand Down
8 changes: 5 additions & 3 deletions test/crawler/test_crawl_wggesucht.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import unittest
from typing import Dict
from functools import reduce
from bs4 import BeautifulSoup
from flathunter.crawler.wggesucht import WgGesucht
Expand All @@ -25,9 +26,10 @@ def test(self):
self.assertTrue(entries[0]['url'].startswith("https://www.wg-gesucht.de/wohnungen"), u"URL should be an apartment link")
for attr in [ 'title', 'price', 'size', 'rooms', 'address', 'image', 'from' ]:
self.assertIsNotNone(entries[0][attr], attr + " should be set")
for attr in [ 'to' ]:
found = reduce(lambda i, e: attr in e or i, entries, False)
self.assertTrue(found, "Expected " + attr + " to sometimes be set")
def shrink(i: bool, e: Dict) -> bool:
return 'to' in e or i
found = reduce(shrink, entries, False)
self.assertTrue(found, "Expected 'to' to sometimes be set")

def test_filter_spotahome_ads(self):
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures", "wg-gesucht-spotahome.html")) as fixture:
Expand Down
Loading