nats.py
nats.py copied to clipboard
KV's `Entry.operation` should have a literal type
Proposed change
Minor thing, but it would be nice if in kv.py in the Entry
dataclass, we instead used literals here for the operation
field:
@dataclass
class Entry:
"""
An entry from a KeyValue store in JetStream.
"""
bucket: str
key: str
value: Optional[bytes]
revision: Optional[int]
delta: Optional[int]
created: Optional[int]
operation: Optional[str]
https://github.com/nats-io/nats.py/blob/main/nats/js/kv.py#L67-L78
I think it would be easier to use if it were:
operation: Optional[Literal[KV_DEL, KV_PURGE]]
Use case
It makes development easier if you're using an editor that autocompletes using type hints. It also makes it a little more self-documenting.
Contribution
Sure