From 8f2941babd91a2eced4f9fc2ed8c6b2638a28687 Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Thu, 25 Apr 2024 07:38:30 -0700 Subject: [PATCH 1/6] =?UTF-8?q?Bump=20version:=201.3.2=20=E2=86=92=201.3.3?= =?UTF-8?q?-dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pvl/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pvl/__init__.py b/pvl/__init__.py index 8b71efd..426431a 100755 --- a/pvl/__init__.py +++ b/pvl/__init__.py @@ -24,7 +24,7 @@ __author__ = "The pvl Developers" __email__ = "rbeyer@rossbeyer.net" -__version__ = "1.3.2" +__version__ = "1.3.3-dev" __all__ = [ "load", "loads", diff --git a/setup.cfg b/setup.cfg index 9302b19..02baa94 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.3.2 +current_version = 1.3.3-dev commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+))? diff --git a/setup.py b/setup.py index a36a36d..29c3538 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='pvl', - version='1.3.2', + version='1.3.3-dev', description=( 'Python implementation for PVL (Parameter Value Language) ' 'parsing and encoding.' From a4c1cf0194226e5f076a8ce0ade9004f16bff678 Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Sat, 4 May 2024 07:57:12 -0700 Subject: [PATCH 2/6] docs(parser.py): Found some typos. --- pvl/parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvl/parser.py b/pvl/parser.py index c7f312a..a6d3bc3 100644 --- a/pvl/parser.py +++ b/pvl/parser.py @@ -390,7 +390,7 @@ def parse_begin_aggregation_statement( the name Block Name as a ``str``. ::= - * '=' * + * '=' * [] Where ::= @@ -401,13 +401,13 @@ def parse_begin_aggregation_statement( if not begin.is_begin_aggregation(): tokens.send(begin) raise ValueError( - "Expecting a Begin-Aggegation-Statement, but " + "Expecting a Begin-Aggregation-Statement, but " f"found: {begin}" ) except StopIteration: raise ValueError( "Ran out of tokens before starting to parse " - "a Begin-Aggegation-Statement." + "a Begin-Aggregation-Statement." ) try: @@ -623,7 +623,7 @@ def _parse_set_seq(self, delimiters, tokens: abc.Generator) -> list: tokens.send(t) tokens.throw( ValueError, - "While parsing, expected a comma (,)" f'but found: "{t}"', + f'While parsing, expected a comma (,) but found: "{t}"', ) def parse_set(self, tokens: abc.Generator) -> frozenset: From 24e4d26d3071736220005733ccbe60d4fec98c9b Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Sat, 4 May 2024 08:09:45 -0700 Subject: [PATCH 3/6] fix(parser.py): Returns better error message to the user if a bare token (a parameter without a value) is encountered (Issue 108). --- HISTORY.rst | 6 ++++++ pvl/parser.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b1e5b23..58ccd53 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -30,6 +30,12 @@ and the release date, in year-month-day format (see examples below). Not Yet Released ---------------- +Fixed ++++++ +* If there was a bare token in the PVL-text (i.e. a parameter with no value assignment), + the returned error message was difficult to understand, should now be clear that + it was looking for an equals sign, and didn't find one (Issue 108). + 1.3.2 (2022-02-05) ------------------ diff --git a/pvl/parser.py b/pvl/parser.py index a6d3bc3..2ec04f7 100644 --- a/pvl/parser.py +++ b/pvl/parser.py @@ -319,12 +319,13 @@ def parse_aggregation_block(self, tokens: abc.Generator): # noqa: C901 present in the End-Aggregation-Statement. """ (begin, block_name) = self.parse_begin_aggregation_statement(tokens) + # print(f"parsed begin agg: {begin} {block_name}") agg = self.aggregation_cls(begin) while True: - self.parse_WSC_until(None, tokens) try: + # print("about to see if these tokens can be an agg block.") agg.append(*self.parse_aggregation_block(tokens)) except LexerError: raise @@ -337,16 +338,21 @@ def parse_aggregation_block(self, tokens: abc.Generator): # noqa: C901 # tokens.send(t) except LexerError: raise - except ValueError: + except ValueError as err: + # print(f"Had a ValueError: {err}") # t = next(tokens) # print(f'parsing agg block, next token is: {t}') # tokens.send(t) + if 'Expecting "="' in str(err): + tokens.throw(ValueError, str(err)) + try: self.parse_end_aggregation(begin, block_name, tokens) break except LexerError: raise except ValueError as ve: + # print(f"In ve: {ve}") try: (agg, keep_parsing) = self.parse_module_post_hook( agg, tokens @@ -399,6 +405,7 @@ def parse_begin_aggregation_statement( try: begin = next(tokens) if not begin.is_begin_aggregation(): + # print(f"{begin} is not a begin aggregation raise ValueError") tokens.send(begin) raise ValueError( "Expecting a Begin-Aggregation-Statement, but " From 411d4352d7eb56da1522aaa69f3ef3cab6d2e966 Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Sat, 15 Mar 2025 11:29:47 -0700 Subject: [PATCH 4/6] build(environment.yml): Removed explicit Python and Pypy versions. Also removed tox. --- environment.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/environment.yml b/environment.yml index a27dd35..d18ce8e 100644 --- a/environment.yml +++ b/environment.yml @@ -5,15 +5,12 @@ dependencies: - bump2version - cookiecutter - flake8 - - pypy3.6 - - python=3.6 - pytest - pytest-cov - sphinx - sphinxcontrib - sphinxcontrib-apidoc - sphinxcontrib-autoprogram - - tox - twine # These are optional dependencies, and pvl should pass all its tests without them. - python-dateutil From dc8076a3bc2568da0bee4c67110054a90852f25e Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Sat, 15 Mar 2025 13:41:27 -0700 Subject: [PATCH 5/6] docs(quantities.rst): Updated the doctests to reflect the new fully-qualified name of pint.util.Quantity. --- docs/quantities.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/quantities.rst b/docs/quantities.rst index edf24d7..da49349 100644 --- a/docs/quantities.rst +++ b/docs/quantities.rst @@ -17,7 +17,7 @@ In order to avoid optional dependencies, the ``pvl`` library provides the :class:`pvl.collections.Quantity` class, implemented as a :class:`collections.namedtuple` with a ``value`` and a ``unit`` parameter. However, the ``unit`` parameter is just a string and -so the ``pvl`` quantity objects doesn't have the super-powers that +so the ``pvl`` quantity object doesn't have the super-powers that the ``astropy`` and ``pint`` quntity objects do. By default, this means that when PVL text is parsed by :func:`pvl.load` @@ -191,7 +191,7 @@ would prefer to use those objects. Here is an example:: ('length', ) ]) >>> print(type(w_pint['length'])) - + Just as with :class:`astropy.units.Quantity`, :class:`pint.Quantity` doesn't recognize the upper case units, and will raise an error like this:: @@ -220,7 +220,7 @@ a registry on-the-fly, you must use the registry's Quantity to the ('INT_UNIT', ) ]) >>> print(type(label['FLOAT_UNIT'])) - .Quantity'> + Similarly, :class:`pint.Quantity` objects can be encoded to PVL text by :func:`pvl.dump` or :func:`pvl.dumps`:: From e345069b0ed81e2c56b2ddb54e3b00300bd4bd54 Mon Sep 17 00:00:00 2001 From: Ross Beyer Date: Wed, 2 Apr 2025 20:24:19 -0700 Subject: [PATCH 6/6] fix(collections.py): The PendingDeprecationWarning() in the Units class was not properly encapsulated in the __init__() function. --- HISTORY.rst | 3 +++ pvl/collections.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 58ccd53..a8b3c19 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -35,6 +35,9 @@ Fixed * If there was a bare token in the PVL-text (i.e. a parameter with no value assignment), the returned error message was difficult to understand, should now be clear that it was looking for an equals sign, and didn't find one (Issue 108). +* Just importing the pvl library would emit the PendingDeprecationWarning about the Units + class, even if a user did not import or instantiate the Units class. + The warn() was not properly issued from the __init__() function, it now is (Issue 109). 1.3.2 (2022-02-05) diff --git a/pvl/collections.py b/pvl/collections.py index 4687f2b..6571de5 100644 --- a/pvl/collections.py +++ b/pvl/collections.py @@ -697,8 +697,12 @@ def __float__(self): class Units(Quantity): - warnings.warn( - "The pvl.collections.Units object is deprecated, and may be removed at " - "the next major patch. Please use pvl.collections.Quantity instead.", - PendingDeprecationWarning, - ) + + def __init__(self, *args, **kwargs): + warnings.warn( + "The pvl.collections.Units object is deprecated, and may be " + "removed at the next major patch. Please use " + "pvl.collections.Quantity instead.", + PendingDeprecationWarning, + stacklevel=2 + )