We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8dfd93 commit 3b2ae11Copy full SHA for 3b2ae11
1 file changed
adaptive/utils.py
@@ -1,5 +1,6 @@
1
# -*- coding: utf-8 -*-
2
3
+import abc
4
import functools
5
import gzip
6
import os
@@ -67,3 +68,14 @@ def decorator(method):
67
68
return functools.wraps(other)(method)
69
70
return decorator
71
+
72
73
+class _RequireAttrsABCMeta(abc.ABCMeta):
74
+ required_attributes = []
75
76
+ def __call__(self, *args, **kwargs):
77
+ obj = super().__call__(*args, **kwargs)
78
+ for name in obj.required_attributes:
79
+ if not hasattr(obj, name):
80
+ raise ValueError(f"Required attribute {name} not set in __init__.")
81
+ return obj
0 commit comments