Skip to content

Commit d7c0736

Browse files
authored
Support py314 (#78)
* Support py314 * ruff * da fix
1 parent e6060e6 commit d7c0736

8 files changed

Lines changed: 38 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
45
push:
5-
branches: [ main ]
6+
branches:
7+
- main
8+
tags:
9+
- "v*.*.*"
610
pull_request:
7-
branches: [ main ]
11+
branches:
12+
- main
813

914

1015
jobs:
@@ -15,15 +20,15 @@ jobs:
1520
strategy:
1621
fail-fast: false
1722
steps:
18-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
1924
- name: Set up Python
20-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
2126
with:
22-
python-version: 3.12
27+
python-version: 3.14
2328
- name: Set up Node
24-
uses: actions/setup-node@v4
29+
uses: actions/setup-node@v6
2530
with:
26-
node-version: '18'
31+
node-version: '24'
2732
- name: Install dependencies
2833
run: |
2934
python -m pip install --upgrade pip
@@ -41,11 +46,11 @@ jobs:
4146
strategy:
4247
fail-fast: false
4348
steps:
44-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@v6
4550
- name: Set up Python
46-
uses: actions/setup-python@v5
51+
uses: actions/setup-python@v6
4752
with:
48-
python-version: 3.13
53+
python-version: 3.14
4954
- name: Install dev dependencies
5055
run: |
5156
python -m pip install --upgrade pip
@@ -81,21 +86,24 @@ jobs:
8186
- name: Linux py 3.13
8287
os: ubuntu-latest
8388
pyversion: '3.13'
89+
- name: Linux py 3.14
90+
os: ubuntu-latest
91+
pyversion: '3.14'
8492
#
8593
- name: Linux pypy
8694
os: ubuntu-latest
8795
pyversion: 'pypy3.9'
8896
- name: Windows
8997
os: windows-latest
90-
pyversion: '3.13'
98+
pyversion: '3.14'
9199
- name: MacOS
92100
os: macos-latest
93-
pyversion: '3.13'
101+
pyversion: '3.14'
94102

95103
steps:
96-
- uses: actions/checkout@v4
104+
- uses: actions/checkout@v6
97105
- name: Set up Python ${{ matrix.pyversion }}
98-
uses: actions/setup-python@v5
106+
uses: actions/setup-python@v6
99107
with:
100108
python-version: ${{ matrix.pyversion }}
101109
- name: Install dependencies for unit tests

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015-2025, Almar Klein
1+
Copyright (c) 2015-2026, Almar Klein
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
# General information about the project.
6060
project = "PScript"
61-
copyright = "2015-2025, Almar Klein"
61+
copyright = "2015-2026, Almar Klein"
6262

6363
# List of patterns, relative to source directory, that match files and
6464
# directories to ignore when looking for source files.

pscript/commonast.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
docheck = "pytest" in sys.modules
3030

3131

32+
# For older Pythons. Since some of these classes are deprecated or removed in later Python versions, we play it safe.
33+
old_index_types = tuple(
34+
getattr(ast, x)
35+
for x in ("Slice", "Index", "ExtSlice", "Ellipsis")
36+
if getattr(ast, x, None) is not None
37+
)
38+
39+
3240
def parse(code, comments=False):
3341
"""Parse Python code to produce a common AST tree.
3442
@@ -1032,7 +1040,7 @@ def _convert_Subscript(self, n):
10321040

10331041
def _convert_index_like(self, n):
10341042
c = self._convert
1035-
if isinstance(n, (ast.Slice, ast.Index, ast.ExtSlice, ast.Ellipsis)):
1043+
if isinstance(n, old_index_types):
10361044
return c(n) # Python < 3.8 (and also 3.8 on Windows?)
10371045
elif isinstance(n, ast.Tuple):
10381046
assert isinstance(n, ast.Tuple)

pscript/parser0.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def push_stack(self, type, name):
317317
def pop_stack(self):
318318
"""Pop the current stack and return the namespace."""
319319
# Pop
320-
nstype, nsname, ns = self._stack.pop(-1)
320+
_nstype, _nsname, ns = self._stack.pop(-1)
321321
self.vars.leak_stack(ns)
322322
return ns
323323

@@ -337,7 +337,7 @@ def get_declarations(self, ns):
337337

338338
def with_prefix(self, name, new=False):
339339
"""Add class prefix to a variable name if necessary."""
340-
nstype, nsname, ns = self._stack[-1]
340+
nstype, nsname, _ns = self._stack[-1]
341341
if nstype == "class":
342342
if name.startswith("__") and not name.endswith("__"):
343343
name = "_" + nsname + name # Double underscore name mangling
@@ -362,7 +362,7 @@ def dummy(self, name=""):
362362
return name
363363

364364
def _handle_std_deps(self, code):
365-
nargs, function_deps, method_deps = stdlib.get_std_info(code)
365+
_nargs, function_deps, method_deps = stdlib.get_std_info(code)
366366
for dep in function_deps:
367367
self.use_std_function(dep, [])
368368
for dep in method_deps:

pscript/parser2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ def function_super(self, node):
11771177

11781178
# Find the class of this function. Using this._base_class would work
11791179
# in simple situations, but not when there's two levels of super().
1180-
nstype1, nsname1, _ = self._stack[-1]
1180+
nstype1, _nsname1, _ = self._stack[-1]
11811181
nstype2, nsname2, _ = self._stack[-2]
11821182
if not (nstype1 == "function" and nstype2 == "class"):
11831183
raise JSError("can only use super() inside a method.")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ readme = "README.md"
1616
license = { file = "LICENSE" }
1717
authors = [{ name = "Almar Klein" }]
1818
keywords = ["Python", "JavaScript", "compiler", "transpiler", "parser"]
19-
requires-python = ">= 3.6"
19+
requires-python = ">= 3.8"
2020
dependencies = []
2121
[project.optional-dependencies]
2222
lint = ["ruff"]

tests/test_parser0.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ruff: noqa: F841
2-
31
from pscript.testing import run_tests_if_main
42

53
from pscript.parser0 import unify

0 commit comments

Comments
 (0)