From a499339b0ce924214e9dcc2de1df4911a46a70bb Mon Sep 17 00:00:00 2001 From: gilch Date: Thu, 25 May 2023 21:57:55 -0600 Subject: [PATCH 1/4] Fix DeprecationWarning Flags not at the start of the expression '\\n$|(?m)^ *;+ ?' --- src/hissp/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hissp/reader.py b/src/hissp/reader.py index cdc438fb..17d99ae4 100644 --- a/src/hissp/reader.py +++ b/src/hissp/reader.py @@ -140,7 +140,7 @@ def __init__(self, token): self.token = token def contents(self): - return re.sub(r"\n$|(?m)^ *;+ ?", "", self.token) + return re.sub(r"(?m)\n$|^ *;+ ?", "", self.token) def __repr__(self): return f"Comment({self.token!r})" From b16f02b43edb9dc97607ee30b958b8a20e836c6a Mon Sep 17 00:00:00 2001 From: gilch Date: Thu, 25 May 2023 22:15:17 -0600 Subject: [PATCH 2/4] Fix RuntimeWarning 'hissp.repl' found in sys.modules after import of package 'hissp', but prior to execution of 'hissp.repl'; this may result in 'unpredictable behaviour Remove direct repl entry point. It is no longer required. Use hissp's __main__.py instead. --- src/hissp/repl.py | 13 +++---------- tests/test_cmd.py | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/hissp/repl.py b/src/hissp/repl.py index be651add..bf222b9d 100644 --- a/src/hissp/repl.py +++ b/src/hissp/repl.py @@ -88,29 +88,22 @@ def interact(locals=None): def force_main(): """:meta private:""" + # Creates a new ``__main__`` to take the place of the current + # ``__main__`` module. __main__ = ModuleType("__main__") sys.modules["__main__"] = __main__ sys.path.insert(0, "") return __main__ -def main(__main__=None): +def main(__main__): """REPL command-line entry point. - If ``__main__`` is not provided, it creates a new one to take the - place of the current ``__main__`` module. - `hissp.macros._macro_` is imported into the module namespace, making the bundled macros immediately available unqualified. """ - if not __main__: - __main__ = force_main() repl = LisspREPL(locals=__main__.__dict__) import hissp.macros # Here so repl can import before compilation. repl.locals["_macro_"] = SimpleNamespace(**vars(hissp.macros._macro_)) repl.interact() - - -if __name__ == "__main__": - main() diff --git a/tests/test_cmd.py b/tests/test_cmd.py index ef67d839..762810b8 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -53,7 +53,7 @@ def test_i_file_args(): def test_repl_read_exception(): - out, err = cmd("python -m hissp.repl", ".#(operator..truediv 1 0)\n") + out, err = cmd("python -m hissp", ".#(operator..truediv 1 0)\n") assert ">>> # Compilation failed!\nTraceback (most recent call last):\n F" in err assert "\nZeroDivisionError: division by zero" in err assert out.count("#> ") == 2 From 4c29cc959fa6a889b9a191283b2dd9a1dccaa41b Mon Sep 17 00:00:00 2001 From: gilch Date: Thu, 25 May 2023 22:29:43 -0600 Subject: [PATCH 3/4] Disable pytest cache in workflow --- .github/workflows/test-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 816038e1..9e7ad0b1 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -56,7 +56,7 @@ jobs: - name: Test install with pytest (including doctests) run: | python -c "import tests" # Compiles hissp.basic on package import. - pytest -v --cov=hissp --cov-report=xml --doctest-modules --doctest-glob *.md src/hissp/*.lissp tests/ docs/ $(python -c "import hissp; print(hissp.__path__[0])") + pytest -p no:cacheprovider -v --cov=hissp --cov-report=xml --doctest-modules --doctest-glob *.md src/hissp/*.lissp tests/ docs/ $(python -c "import hissp; print(hissp.__path__[0])") - name: Codecov uses: codecov/codecov-action@v1.0.4 with: From f55da8d8f59a18d5c853bd82a52ba45a6479f149 Mon Sep 17 00:00:00 2001 From: gilch Date: Thu, 25 May 2023 21:34:25 -0600 Subject: [PATCH 4/4] Set PYTHONWARNINGS to error --- .github/workflows/test-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 9e7ad0b1..cf170eb7 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -54,6 +54,8 @@ jobs: python -m pip install --upgrade pip pip install -r requirements-dev.txt - name: Test install with pytest (including doctests) + env: + PYTHONWARNINGS: error run: | python -c "import tests" # Compiles hissp.basic on package import. pytest -p no:cacheprovider -v --cov=hissp --cov-report=xml --doctest-modules --doctest-glob *.md src/hissp/*.lissp tests/ docs/ $(python -c "import hissp; print(hissp.__path__[0])")