From bb6ecb36d8b25125801a7e15fc32b7117a2e5c4d Mon Sep 17 00:00:00 2001 From: Foxerine <54745033+Foxerine@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:39:50 +0800 Subject: [PATCH 1/4] Add ast.Constant support for Python 3.8+ in _ast_eval Updated the _ast_eval function to handle ast.Constant nodes for compatibility with Python 3.8 and newer, where ast.Num is deprecated. This ensures correct evaluation of constants across Python versions. --- hyperpyyaml/core.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hyperpyyaml/core.py b/hyperpyyaml/core.py index caef5f9..62bcad6 100644 --- a/hyperpyyaml/core.py +++ b/hyperpyyaml/core.py @@ -8,6 +8,7 @@ import re import ast +import sys import yaml import copy import pydoc @@ -715,9 +716,18 @@ def _ast_eval(node): ast.Pow: op.pow, ast.Mod: op.mod, } - if isinstance(node, ast.Num): # - return node.n - elif isinstance(node, ast.BinOp): # + + # Compatibility check for Python versions + # In Python 3.8, ast.Num was deprecated and replaced by ast.Constant. + if sys.version_info >= (3, 8): + if isinstance(node, ast.Constant): # , , , + return node.value + else: + # For Python versions older than 3.8 + if isinstance(node, ast.Num): # + return node.n + + if isinstance(node, ast.BinOp): # return ops[type(node.op)](_ast_eval(node.left), _ast_eval(node.right)) elif isinstance(node, ast.UnaryOp): # e.g., -1 return ops[type(node.op)](_ast_eval(node.operand)) From ed333054083afdd94e21871a47b863abbe8de719 Mon Sep 17 00:00:00 2001 From: Foxerine <54745033+Foxerine@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:42:49 +0800 Subject: [PATCH 2/4] workflow trigger --- hyperpyyaml/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyperpyyaml/core.py b/hyperpyyaml/core.py index 62bcad6..6900792 100644 --- a/hyperpyyaml/core.py +++ b/hyperpyyaml/core.py @@ -719,7 +719,7 @@ def _ast_eval(node): # Compatibility check for Python versions # In Python 3.8, ast.Num was deprecated and replaced by ast.Constant. - if sys.version_info >= (3, 8): + if sys.version_info >= (3, 8): if isinstance(node, ast.Constant): # , , , return node.value else: From b486dccf74962bca43c9cc15921d8bd6b80c63e4 Mon Sep 17 00:00:00 2001 From: Foxerine <54745033+Foxerine@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:50:17 +0800 Subject: [PATCH 3/4] Update GitHub Actions workflow for Python Adds Python 3.13 to the test matrix and updates actions/checkout and actions/setup-python to their latest major versions for improved compatibility and security. --- .github/workflows/pythonapp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 48a44d3..4d722bd 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.9, 3.13] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Display Python version From e8aedc7591944ed7485d303699a7d5db46a3ae80 Mon Sep 17 00:00:00 2001 From: Foxerine <54745033+Foxerine@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:56:17 +0800 Subject: [PATCH 4/4] Update workflow to test against Python 3.14 Replaces Python 3.13 with 3.14 in the GitHub Actions matrix to ensure compatibility and testing with the latest Python release. --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 4d722bd..70e1142 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, 3.13] + python-version: [3.9, 3.14] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }}