Skip to content

Commit 15d1dfa

Browse files
author
Ashley Scillitoe
committed
Update typings
1 parent aa6b0d3 commit 15d1dfa

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

alibi_detect/base.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from abc import ABC, abstractmethod
2+
import os
23
import copy
34
import json
45
import numpy as np
5-
from typing import Dict, Any, Optional
6+
from typing import Dict, Any, Optional, Union
67
from typing_extensions import Protocol, runtime_checkable
78
from alibi_detect.version import __version__
89

@@ -153,7 +154,7 @@ def from_config(cls, config: dict):
153154
detector.config['meta']['version_warning'] = version_warning
154155
return detector
155156

156-
def _set_config(self, inputs): # TODO - move to BaseDetector once config save/load implemented for non-drift
157+
def _set_config(self, inputs: dict): # TODO - move to BaseDetector once config save/load implemented for non-drift
157158
"""
158159
Set a detectors `config` attribute upon detector instantiation.
159160
@@ -218,11 +219,12 @@ class ConfigurableDetector(Detector, Protocol):
218219
219220
Used for typing save and load functionality in `alibi_detect.saving.saving`.
220221
"""
221-
def get_config(self): ...
222+
def get_config(self) -> dict: ...
222223

223-
def from_config(self): ...
224+
@classmethod
225+
def from_config(cls, config: dict): ...
224226

225-
def _set_config(self): ...
227+
def _set_config(self, inputs: dict): ...
226228

227229

228230
@runtime_checkable
@@ -231,9 +233,9 @@ class StatefulDetectorOnline(ConfigurableDetector, Protocol):
231233
232234
Used for typing save and load functionality in `alibi_detect.saving.saving`.
233235
"""
234-
def save_state(self, filepath): ...
236+
def save_state(self, filepath: Union[str, os.PathLike]): ...
235237

236-
def load_state(self, filepath): ...
238+
def load_state(self, filepath: Union[str, os.PathLike]): ...
237239

238240

239241
class NumpyEncoder(json.JSONEncoder):

0 commit comments

Comments
 (0)