Skip to content

Commit 1533703

Browse files
committed
Replace base_state counter with a custom picklable one
1 parent 1913754 commit 1533703

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

jsf/parser.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from collections import ChainMap
55
from copy import deepcopy
66
from datetime import datetime
7-
from itertools import count
87
from pathlib import Path
98
from types import MappingProxyType
109
from typing import Any, Dict, List, Optional, Tuple, Union
@@ -68,7 +67,7 @@ def __init__(
6867
self.root_schema = schema
6968
self.definitions = {}
7069
self.base_state = {
71-
"__counter__": count(start=1),
70+
"__counter__": _PicklableCounter(),
7271
"__all_json_paths__": [],
7372
"__depth__": 0,
7473
**initial_state,
@@ -371,3 +370,15 @@ def to_json(self, path: Path, **kwargs) -> None:
371370
output to the given path."""
372371
with open(path, "w") as f:
373372
json.dump(self.generate(), f, **kwargs)
373+
374+
375+
class _PicklableCounter:
376+
def __init__(self):
377+
self._counter = 0
378+
379+
def __iter__(self):
380+
return self
381+
382+
def __next__(self):
383+
self._counter += 1
384+
return self._counter

0 commit comments

Comments
 (0)