From 2347cbbabecd2901b390ef3cc89bb7a35e4057fc Mon Sep 17 00:00:00 2001 From: Spencer Phillip Young Date: Mon, 5 Dec 2022 10:46:49 -0800 Subject: [PATCH] gh-40 work with any version of sly --- .github/workflows/unittests.yml | 2 +- json5/parser.py | 1 + json5/tokenizer.py | 5 +++-- setup.py | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index d646f21..d7c94b2 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -14,7 +14,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install "sly<0.5" coverage regex pytest + python -m pip install sly coverage regex pytest - name: Test with coverage/pytest run: | diff --git a/json5/parser.py b/json5/parser.py index b14cd5e..007c6ee 100644 --- a/json5/parser.py +++ b/json5/parser.py @@ -422,6 +422,7 @@ class tok: value=None lineno=None index=None + end=None return JSON5Token(tok(), None) elif self.last_token: doc = self.last_token.doc diff --git a/json5/tokenizer.py b/json5/tokenizer.py index 0a9322b..efd10e7 100644 --- a/json5/tokenizer.py +++ b/json5/tokenizer.py @@ -18,10 +18,11 @@ def __init__(self, tok, doc): self.lineno = tok.lineno self.index = tok.index self.doc = doc - __slots__ = ('type', 'value', 'lineno', 'index', 'doc') + self.end = getattr(tok, 'end', None) + __slots__ = ('type', 'value', 'lineno', 'index', 'doc', 'end') def __repr__(self): - return f'JSON5Token(type={self.type!r}, value={self.value!r}, lineno={self.lineno}, index={self.index})' + return f'JSON5Token(type={self.type!r}, value={self.value!r}, lineno={self.lineno}, index={self.index}, end={self.end})' class JSONLexer(Lexer): diff --git a/setup.py b/setup.py index 58d45a1..6d08436 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='json-five', - version='0.7.6', + version='0.8.0', packages=['json5'], url='https://github.com/spyoungtech/json-five', license='Apache', @@ -15,7 +15,7 @@ description='A JSON5 parser that, among other features, supports round-trip preservation of comments', long_description=long_description, long_description_content_type='text/markdown', - install_requires=['sly<0.5', 'regex'], + install_requires=['sly', 'regex'], classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 3 :: Only',