Skip to content

Commit 723610e

Browse files
authored
Merge pull request #2 from ppigazzini/dev
feat: fix bugs and add modern python support
2 parents 8982808 + cd9c549 commit 723610e

9 files changed

Lines changed: 639 additions & 470 deletions

File tree

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "master", "dev" ]
6+
pull_request:
7+
branches: [ "master", "dev" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
tests:
19+
name: Tests (Python ${{ matrix.python-version }})
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
python-version:
25+
- "3.8"
26+
- "3.9"
27+
- "3.10"
28+
- "3.11"
29+
- "3.12"
30+
- "3.13"
31+
- "3.14"
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v5
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
id: setup-python
39+
uses: actions/setup-python@v6
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Show environment
44+
run: |
45+
python --version
46+
which python
47+
python -c "import sys; print('Executable:', sys.executable)"
48+
49+
- name: Run tests (unittest)
50+
run: |
51+
python -m unittest discover -v
52+
53+
test-legacy:
54+
name: Tests (Python 2.7 via container)
55+
runs-on: ubuntu-latest
56+
container:
57+
image: python:2.7
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v5
61+
- name: Install package
62+
run: |
63+
pip install --upgrade pip setuptools
64+
pip install .
65+
- name: Run tests (unittest)
66+
run: |
67+
python -m unittest discover -v || true
68+
- name: Legacy note
69+
run: echo "Python 2.7 run completed (non-blocking)."
70+
71+
summary:
72+
name: Summary
73+
runs-on: ubuntu-latest
74+
needs: [tests, test-legacy]
75+
if: always()
76+
steps:
77+
- name: Aggregate result
78+
run: |
79+
echo "Modern matrix + legacy (2.7) complete. Check job logs for details."

.github/workflows/lint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ "master", "dev" ]
6+
pull_request:
7+
branches: [ "master", "dev" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
ruff:
15+
name: Ruff (Python 3.14)
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Set up Python 3.14
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.14"
25+
26+
- name: Ruff check
27+
id: ruff-check
28+
uses: astral-sh/ruff-action@v3
29+
continue-on-error: true
30+
with:
31+
args: check expression tests
32+
33+
- name: Ruff import order
34+
id: ruff-imports
35+
uses: astral-sh/ruff-action@v3
36+
continue-on-error: true
37+
with:
38+
args: check expression tests --select I
39+
40+
- name: Ruff format check
41+
id: ruff-format
42+
uses: astral-sh/ruff-action@v3
43+
continue-on-error: true
44+
with:
45+
args: format --check
46+
47+
- name: Summary
48+
run: |
49+
echo "ruff check : ${{ steps.ruff-check.outcome }}"
50+
echo "imports : ${{ steps.ruff-imports.outcome }}"
51+
echo "format : ${{ steps.ruff-format.outcome }}"

.gitignore

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
3-
*.py[cod]
3+
*.py[codz]
44
*$py.class
55

66
# C extensions
77
*.so
88

99
# Distribution / packaging
1010
.Python
11-
env/
1211
build/
1312
develop-eggs/
1413
dist/
@@ -21,9 +20,11 @@ parts/
2120
sdist/
2221
var/
2322
wheels/
23+
share/python-wheels/
2424
*.egg-info/
2525
.installed.cfg
2626
*.egg
27+
MANIFEST
2728

2829
# PyInstaller
2930
# Usually these files are written by a python script from a template
@@ -38,13 +39,17 @@ pip-delete-this-directory.txt
3839
# Unit test / coverage reports
3940
htmlcov/
4041
.tox/
42+
.nox/
4143
.coverage
4244
.coverage.*
4345
.cache
4446
nosetests.xml
4547
coverage.xml
4648
*.cover
49+
*.py.cover
4750
.hypothesis/
51+
.pytest_cache/
52+
cover/
4853

4954
# Translations
5055
*.mo
@@ -53,6 +58,8 @@ coverage.xml
5358
# Django stuff:
5459
*.log
5560
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
5663

5764
# Flask stuff:
5865
instance/
@@ -65,27 +72,77 @@ instance/
6572
docs/_build/
6673

6774
# PyBuilder
75+
.pybuilder/
6876
target/
6977

7078
# Jupyter Notebook
7179
.ipynb_checkpoints
7280

81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
7385
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
7488
.python-version
7589

76-
# celery beat schedule file
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
#poetry.toml
110+
111+
# pdm
112+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115+
#pdm.lock
116+
#pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# pixi
121+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122+
#pixi.lock
123+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124+
# in the .venv directory. It is recommended not to include this directory in version control.
125+
.pixi
126+
127+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128+
__pypackages__/
129+
130+
# Celery stuff
77131
celerybeat-schedule
132+
celerybeat.pid
78133

79134
# SageMath parsed files
80135
*.sage.py
81136

82-
# dotenv
137+
# Environments
83138
.env
84-
85-
# virtualenv
139+
.envrc
86140
.venv
141+
env/
87142
venv/
88143
ENV/
144+
env.bak/
145+
venv.bak/
89146

90147
# Spyder project settings
91148
.spyderproject
@@ -99,3 +156,52 @@ ENV/
99156

100157
# mypy
101158
.mypy_cache/
159+
.dmypy.json
160+
dmypy.json
161+
162+
# Pyre type checker
163+
.pyre/
164+
165+
# pytype static type analyzer
166+
.pytype/
167+
168+
# Cython debug symbols
169+
cython_debug/
170+
171+
# PyCharm
172+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174+
# and can be added to the global gitignore or merged into this file. For a more nuclear
175+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
176+
#.idea/
177+
178+
# Abstra
179+
# Abstra is an AI-powered process automation framework.
180+
# Ignore directories containing user credentials, local state, and settings.
181+
# Learn more at https://abstra.io/docs
182+
.abstra/
183+
184+
# Visual Studio Code
185+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188+
# you could uncomment the following to ignore the entire vscode folder
189+
.vscode/
190+
191+
# Ruff stuff:
192+
.ruff_cache/
193+
194+
# PyPI configuration file
195+
.pypirc
196+
197+
# Cursor
198+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200+
# refer to https://docs.cursor.com/context/ignore-files
201+
.cursorignore
202+
.cursorindexingignore
203+
204+
# Marimo
205+
marimo/_static/
206+
marimo/_lsp/
207+
__marimo__/

expression/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818

1919
from .parser import Expression_Parser
2020

21-
__all__ = ['Expression_Parser']
22-
__version__ = '0.0.5'
21+
__all__ = ["Expression_Parser"]
22+
__version__ = "0.0.6"

expression/interpreter.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import cmd
2323
import sys
2424
import traceback
25+
2526
import expression
2627

28+
2729
class Expression_Interpreter(cmd.Cmd):
2830
"""
2931
Interactive command line interpreter that applies the expression line parser
@@ -32,14 +34,14 @@ class Expression_Interpreter(cmd.Cmd):
3234

3335
def __init__(self):
3436
cmd.Cmd.__init__(self)
35-
self.prompt = '>> '
37+
self.prompt = ">> "
3638
self.parser = expression.Expression_Parser(assignment=True)
3739

3840
def default(self, line):
3941
try:
4042
output = self.parser.parse(line)
4143
if output is not None:
42-
self.stdout.write(str(output) + '\n')
44+
self.stdout.write(str(output) + "\n")
4345

4446
variables = self.parser.variables
4547
variables.update(self.parser.modified_variables)
@@ -52,20 +54,22 @@ def do_quit(self, line):
5254
Exit the interpreter.
5355
"""
5456

55-
if line != '' and line != '()':
56-
self.stdout.write(line + '\n')
57+
if line != "" and line != "()":
58+
self.stdout.write(line + "\n")
5759
self._quit()
5860

5961
@staticmethod
6062
def _quit():
6163
sys.exit(1)
6264

65+
6366
def main():
6467
"""
6568
Main entry point.
6669
"""
6770

6871
Expression_Interpreter().cmdloop()
6972

70-
if __name__ == '__main__':
73+
74+
if __name__ == "__main__":
7175
main()

0 commit comments

Comments
 (0)