Skip to content

Commit

Permalink
fix ispell and mypy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mampfes committed Dec 31, 2020
1 parent d894f54 commit 6a4c579
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
hooks:
- id: codespell
args:
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing, Adresse, termine, adresse
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
Expand Down
30 changes: 7 additions & 23 deletions custom_components/waste_collection_schedule/package/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
from itertools import islice
from typing import Dict, List

from .helpers import CollectionAppointment, CollectionAppointmentGroup

Expand Down Expand Up @@ -47,15 +48,15 @@ def __repr__(self):
return f"Customize{{name={self.name}, alias={self.alias}, show={self.show}, icon={self.icon}, picture={self.picture}}}"


def filter_function(entry: CollectionAppointment, customize: {}):
def filter_function(entry: CollectionAppointment, customize:Dict[str,Customize]):
c = customize.get(entry.type)
if c is None:
return True
else:
return c.show


def customize_function(entry: CollectionAppointment, customize: {}):
def customize_function(entry: CollectionAppointment, customize:Dict[str,Customize]):
c = customize.get(entry.type)
if c is not None:
if c.alias is not None:
Expand All @@ -68,9 +69,9 @@ def customize_function(entry: CollectionAppointment, customize: {}):


class Scraper:
def __init__(self, source: str, customize: {}):
def __init__(self, source: str, customize:Dict[str,Customize]):
self._source = source
self._entries = [] # list of entries of type CollectionAppointment
self._entries:List[CollectionAppointment] = []
self._refreshtime = None
self._customize = customize # dict of class Customize

Expand Down Expand Up @@ -179,7 +180,7 @@ def _filter(
return entries

@staticmethod
def create(source_name: str, dir_offset, customize: {}, kwargs):
def create(source_name: str, dir_offset, customize:Dict[str,Customize], kwargs):
# load source module

# for home-assistant, use the last 3 folders, e.g. custom_component/wave_collection_schedule/package
Expand All @@ -193,26 +194,9 @@ def create(source_name: str, dir_offset, customize: {}, kwargs):
return

# create source
source = source_module.Source(**kwargs)
source = source_module.Source(**kwargs) # type: ignore

# create scraper
g = Scraper(source, customize)

return g


if __name__ == "__main__":
scraper = Scraper.create("abfall_kreis_tuebingen", {}, {"ort": 3, "dropzone": 525})
scraper.fetch()
entries = scraper.get_upcoming()
for e in entries:
print(f"{e}, daysTo={e.daysTo}")
print("========")
types = scraper.get_types()
for t in types:
print(t)
print("========")
entries = scraper.get_upcoming_group_by_day()
for e in entries:
print(e)
print("========")
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import datetime
from typing import Dict

from ..helpers import CollectionAppointment

DESCRIPTION = "Example scraper"
URL = ""
TEST_CASES = {}
TEST_CASES:Dict[str, Dict[str, str]] = {}


class Source:
Expand Down

0 comments on commit 6a4c579

Please sign in to comment.