Skip to content
Merged
Show file tree
Hide file tree
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
36 changes: 22 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: CI

on:
workflow_dispatch:
push:
branches: [ main ]
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches: [ main ]
branches:
- main


jobs:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion pscript/commonast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pscript/parser0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pscript/parser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parser0.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F841

from pscript.testing import run_tests_if_main

from pscript.parser0 import unify
Expand Down