Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions jsf/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from collections import ChainMap
from copy import deepcopy
from datetime import datetime
from itertools import count
from pathlib import Path
from types import MappingProxyType
from typing import Any, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -68,7 +67,7 @@ def __init__(
self.root_schema = schema
self.definitions = {}
self.base_state = {
"__counter__": count(start=1),
"__counter__": _PicklableCounter(),
"__all_json_paths__": [],
"__depth__": 0,
**initial_state,
Expand Down Expand Up @@ -371,3 +370,15 @@ def to_json(self, path: Path, **kwargs) -> None:
output to the given path."""
with open(path, "w") as f:
json.dump(self.generate(), f, **kwargs)


class _PicklableCounter:
def __init__(self):
self._counter = 0

def __iter__(self):
return self

def __next__(self):
self._counter += 1
return self._counter