File size: 536 Bytes
50231a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from dataclasses import dataclass, field
from threading import Lock


@dataclass
class LabelConfig:
    labels: list[str] = field(default_factory=list)
    _lock: Lock = field(default_factory=Lock)

    def get_labels(self) -> list[str]:
        with self._lock:
            return list(self.labels)

    def set_labels(self, labels: list[str]) -> list[str]:
        cleaned = [label.strip() for label in labels if label and label.strip()]
        with self._lock:
            self.labels = cleaned
            return list(self.labels)