# Path: sygnal/exceptions.py
# class InvalidNotificationException(Exception):
#     pass
# 
# class NotificationDispatchException(Exception):
#     pass
# 
# class PushkinSetupException(Exception):
#     pass


import abc
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar, overload
from matrix_common.regex import glob_to_regex
from opentracing import Span
from prometheus_client import Counter
from sygnal.exceptions import (
    InvalidNotificationException,
    NotificationDispatchException,
    PushkinSetupException,
)
    from sygnal.sygnal import Sygnal

        if "counts" in notif:
            self.counts = Counts(notif["counts"])
        else:
            self.counts = Counts({})

        self.devices = [Device(d) for d in notif["devices"]]


class Pushkin(abc.ABC):
    def __init__(self, name: str, sygnal: "Sygnal", config: Dict[str, Any]):
        self.name = name
        self.appid_pattern = glob_to_regex(name, ignore_case=False)
        self.cfg = config
        self.sygnal = sygnal

    @overload
    def get_config(self, key: str, type_: Type[T], default: T) -> T:
        ...

    @overload
    def get_config(self, key: str, type_: Type[T], default: None = None) -> Optional[T]:
        ...

    def get_config(
        self, key: str, type_: Type[T], default: Optional[T] = None
    ) -> Optional[T]:
        if key not in self.cfg:
            return default
        if not isinstance(self.cfg[key], type_):

# Path: sygnal/exceptions.py
# class InvalidNotificationException(Exception):
#     pass
# 
# class NotificationDispatchException(Exception):
#     pass
# 
# class PushkinSetupException(Exception):
#     pass


# Path: sygnal/notifications.py
import abc
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar, overload
from matrix_common.regex import glob_to_regex
from opentracing import Span
from prometheus_client import Counter
from sygnal.exceptions import (
    InvalidNotificationException,
    NotificationDispatchException,
    PushkinSetupException,
)
    from sygnal.sygnal import Sygnal


        if "counts" in notif:
            self.counts = Counts(notif["counts"])
        else:
            self.counts = Counts({})

        self.devices = [Device(d) for d in notif["devices"]]


class Pushkin(abc.ABC):
    def __init__(self, name: str, sygnal: "Sygnal", config: Dict[str, Any]):
        self.name = name
        self.appid_pattern = glob_to_regex(name, ignore_case=False)
        self.cfg = config
        self.sygnal = sygnal

    @overload
    def get_config(self, key: str, type_: Type[T], default: T) -> T:
        ...

    @overload
    def get_config(self, key: str, type_: Type[T], default: None = None) -> Optional[T]:
        ...

    def get_config(
        self, key: str, type_: Type[T], default: Optional[T] = None
    ) -> Optional[T]:
        if key not in self.cfg:
            return default
        if not isinstance(self.cfg[key], type_):

            raise PushkinSetupException(