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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ jobs:
- name: Test with pytest
run: |
python -c "import sys; print(sys.version, '\n', sys.prefix)";
pytest -v --cov pscript --cov-config=.coveragerc --cov-report=term --cov-report=html tests
pytest -v --cov pscript --cov-report=term --cov-report=html tests
1 change: 0 additions & 1 deletion CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2020, PScript developers
Copyright (c) 2015-2025, Almar Klein
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ also be useful by itself.
Installation
------------

PScript is pure Python and requires Python 2.7 or 3.5+ (including Pypy).
PScript is pure Python and requires Python 3.6+ (including Pypy).
It has no further dependencies.

* ``pip install pscript``, or
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
sys.path.insert(0, ROOT_DIR)
sys.path.insert(0, os.path.abspath('scripts'))

import pscript

Check failure on line 25 in docs/conf.py

View workflow job for this annotation

GitHub Actions / Linting

Ruff (E402)

docs/conf.py:25:1: E402 Module level import not at top of file

Check failure on line 25 in docs/conf.py

View workflow job for this annotation

GitHub Actions / Linting

Ruff (F401)

docs/conf.py:25:8: F401 `pscript` imported but unused


# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -59,7 +59,7 @@

# General information about the project.
project = 'PScript'
copyright = '2015-2020, PScript contributors'
copyright = '2015-2025, Almar Klein'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
10 changes: 5 additions & 5 deletions docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Getting started
Installation
------------

PScript has no dependencies except Python. It requires Python 2.7 or 3.4+.
PScript has no dependencies except Python. It requires Python 3.6+.
Use either of these to install PScript:

* ``pip install pscript``
* ``conda install pscript``

Expand All @@ -21,16 +21,16 @@ A short example:
.. code-block:: py

from pscript import py2js

def foo(a, b=2):
print(a - b)

print(py2js(foo))

Gives:

.. code-block:: js

var foo;
foo = function flx_foo (a, b) {
b = (b === undefined) ? 2: b;
Expand Down
9 changes: 1 addition & 8 deletions pscript/testing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016, Almar Klein
# Distributed under the (new) BSD License.

"""
Functionality used for testing, based on pytest. This module is designed
to just work, without modification, in most projects.
Expand All @@ -16,9 +12,6 @@
and report coverage. Magic!
"""


from __future__ import absolute_import, print_function, division

import os
import sys
import inspect
Expand Down Expand Up @@ -50,7 +43,7 @@

def run_tests_if_main(show_coverage=False):
""" Run tests in a given file if it is run as a script

Coverage is reported for running this single test. Set show_coverage to
launch the report in the web browser.
"""
Expand Down
75 changes: 75 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Notes on how to do a release.
#
# * Write release notes in docs/releasenotes.txt
# * Bump `__version__` and commit.
# * git tag vx.y
# * git push origin main vx.y
# * flit publish

# ===== Project info

[project]
dynamic = ["version"]
name = "pscript"
description = "Python to JavaScript compiler."
readme = "README.md"
license = { file = "LICENSE" }
authors = [{ name = "Almar Klein" }]
keywords = ["Python", "JavaScript", "compiler", "transpiler", "parser"]
requires-python = ">= 3.6"
dependencies = []
[project.optional-dependencies]
lint = ["ruff"]
tests = ["pytest"]
docs = ["sphinx"]
dev = ["pscript[lint,tests, docs]"]

[project.urls]
Homepage = "https://github.com/flexxui/pscript"
Documentation = "http://pscript.readthedocs.io"
Repository = "https://github.com/flexxui/pscript"


# ===== Building

# Flit is great solution for simple pure-Python projects.
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"


# ===== Tooling

[tool.ruff]
line-length = 88

[tool.ruff.lint]
select = ["F", "E", "W", "B", "RUF"]
ignore = [
# "RUF005", # Consider iterable unpacking instead of concatenation
]


[tool.coverage.report]

exclude_also = [
# Have to re-enable the standard pragma, plus a less-ugly flavor
"pragma: no cover",
"no-cover",
"raise NotImplementedError",
"raise AssertionError",
"raise JSError",
# Don't complain if non-runnable code isn't run:
"if 0:",
"if False:",
"if __name__ == .__main__.:",
"if this_is_js():",

# Don't complain for platform specific code
"sys\\.platform.startswith\\(\\'win\\'\\)",
"sys\\.platform.startswith\\(\\'darwin\\'\\)",
"getattr\\(sys, \\'frozen\\'\\,\\ None\\)",

# Don't complain about caught import fails
"except ImportError:",
]
69 changes: 0 additions & 69 deletions setup.cfg

This file was deleted.

98 changes: 0 additions & 98 deletions setup.py

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test_commonast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

from __future__ import print_function, absolute_import

import os
import sys
import bz2
Expand Down
3 changes: 0 additions & 3 deletions tests/test_parser1.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ def test_string_formatting2(self):
assert py2jslight("'hi %f %1.2f' % (a, b)") == py2jslight("'hi {:f} {:1.2f}'.format(a, b)")
assert py2jslight("'hi %s %r' % (a, b)") == py2jslight("'hi {} {!r}'.format(a, b)")

if sys.version_info < (3, 6):
return

# Verify that f-string formatting produces same JS as str.format - Python 3.6+
assert py2jslight("f'hi {a:i}'") == py2jslight("'hi {:i}'.format(a)")
assert py2js("f'hi {a:i} {b:+i}'") == py2js("'hi {:i} {:+i}'.format(a, b)")
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,6 @@ def func(a, b):
assert code.count('// docstring') == 1

def test_async_and_await(self):
if sys.version_info < (3, 6):
return

foo = py2js('async def foo(): return 42\n\n')
spam = py2js('async def spam(): print(await foo())\n\n')
Expand Down
Loading