From 8b08ca66a8782be697c3f6cbd8eebe8182eaae0f Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 31 Mar 2026 09:50:38 +0200 Subject: [PATCH 1/3] Support py314 --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++-------------- LICENSE | 2 +- docs/conf.py | 2 +- pyproject.toml | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24ced7b..325ff97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,15 @@ name: CI on: + workflow_dispatch: push: - branches: [ main ] + branches: + - main + tags: + - "v*.*.*" pull_request: - branches: [ main ] + branches: + - main jobs: @@ -15,15 +20,15 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: 3.12 + python-version: 3.14 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: '18' + node-version: '24' - name: Install dependencies run: | python -m pip install --upgrade pip @@ -41,11 +46,11 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: 3.13 + python-version: 3.14 - name: Install dev dependencies run: | python -m pip install --upgrade pip @@ -81,21 +86,24 @@ jobs: - name: Linux py 3.13 os: ubuntu-latest pyversion: '3.13' + - name: Linux py 3.14 + os: ubuntu-latest + pyversion: '3.14' # - name: Linux pypy os: ubuntu-latest pyversion: 'pypy3.9' - name: Windows os: windows-latest - pyversion: '3.13' + pyversion: '3.14' - name: MacOS os: macos-latest - pyversion: '3.13' + pyversion: '3.14' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.pyversion }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.pyversion }} - name: Install dependencies for unit tests diff --git a/LICENSE b/LICENSE index 5f45ebf..90c0cb9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2025, Almar Klein +Copyright (c) 2015-2026, Almar Klein All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/docs/conf.py b/docs/conf.py index f94602b..79f24aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ # General information about the project. project = "PScript" -copyright = "2015-2025, Almar Klein" +copyright = "2015-2026, Almar Klein" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/pyproject.toml b/pyproject.toml index 47cd909..eb524dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ readme = "README.md" license = { file = "LICENSE" } authors = [{ name = "Almar Klein" }] keywords = ["Python", "JavaScript", "compiler", "transpiler", "parser"] -requires-python = ">= 3.6" +requires-python = ">= 3.8" dependencies = [] [project.optional-dependencies] lint = ["ruff"] From ad6c520862e955876c18f2f882c737e015810df3 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 31 Mar 2026 09:53:41 +0200 Subject: [PATCH 2/3] ruff --- pscript/parser0.py | 6 +++--- pscript/parser2.py | 2 +- tests/test_parser0.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pscript/parser0.py b/pscript/parser0.py index 35a71e4..37f5da5 100644 --- a/pscript/parser0.py +++ b/pscript/parser0.py @@ -317,7 +317,7 @@ def push_stack(self, type, name): def pop_stack(self): """Pop the current stack and return the namespace.""" # Pop - nstype, nsname, ns = self._stack.pop(-1) + _nstype, _nsname, ns = self._stack.pop(-1) self.vars.leak_stack(ns) return ns @@ -337,7 +337,7 @@ def get_declarations(self, ns): def with_prefix(self, name, new=False): """Add class prefix to a variable name if necessary.""" - nstype, nsname, ns = self._stack[-1] + nstype, nsname, _ns = self._stack[-1] if nstype == "class": if name.startswith("__") and not name.endswith("__"): name = "_" + nsname + name # Double underscore name mangling @@ -362,7 +362,7 @@ def dummy(self, name=""): return name def _handle_std_deps(self, code): - nargs, function_deps, method_deps = stdlib.get_std_info(code) + _nargs, function_deps, method_deps = stdlib.get_std_info(code) for dep in function_deps: self.use_std_function(dep, []) for dep in method_deps: diff --git a/pscript/parser2.py b/pscript/parser2.py index 44f6e59..7ab0d92 100644 --- a/pscript/parser2.py +++ b/pscript/parser2.py @@ -1177,7 +1177,7 @@ def function_super(self, node): # Find the class of this function. Using this._base_class would work # in simple situations, but not when there's two levels of super(). - nstype1, nsname1, _ = self._stack[-1] + nstype1, _nsname1, _ = self._stack[-1] nstype2, nsname2, _ = self._stack[-2] if not (nstype1 == "function" and nstype2 == "class"): raise JSError("can only use super() inside a method.") diff --git a/tests/test_parser0.py b/tests/test_parser0.py index e410202..07e49e2 100644 --- a/tests/test_parser0.py +++ b/tests/test_parser0.py @@ -1,4 +1,3 @@ -# ruff: noqa: F841 from pscript.testing import run_tests_if_main From 3d39f5c642ad0735f5c1058da7a0e99c9ff33ce3 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 31 Mar 2026 10:05:33 +0200 Subject: [PATCH 3/3] da fix --- pscript/commonast.py | 10 +++++++++- tests/test_parser0.py | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pscript/commonast.py b/pscript/commonast.py index 0988a8d..d95d28f 100644 --- a/pscript/commonast.py +++ b/pscript/commonast.py @@ -29,6 +29,14 @@ docheck = "pytest" in sys.modules +# For older Pythons. Since some of these classes are deprecated or removed in later Python versions, we play it safe. +old_index_types = tuple( + getattr(ast, x) + for x in ("Slice", "Index", "ExtSlice", "Ellipsis") + if getattr(ast, x, None) is not None +) + + def parse(code, comments=False): """Parse Python code to produce a common AST tree. @@ -1032,7 +1040,7 @@ def _convert_Subscript(self, n): def _convert_index_like(self, n): c = self._convert - if isinstance(n, (ast.Slice, ast.Index, ast.ExtSlice, ast.Ellipsis)): + if isinstance(n, old_index_types): return c(n) # Python < 3.8 (and also 3.8 on Windows?) elif isinstance(n, ast.Tuple): assert isinstance(n, ast.Tuple) diff --git a/tests/test_parser0.py b/tests/test_parser0.py index 07e49e2..21dbf78 100644 --- a/tests/test_parser0.py +++ b/tests/test_parser0.py @@ -1,4 +1,3 @@ - from pscript.testing import run_tests_if_main from pscript.parser0 import unify