diff --git a/.github/workflows/changelog_check.yml b/.github/workflows/changelog_check.yml index bd34e1d..7476ac1 100644 --- a/.github/workflows/changelog_check.yml +++ b/.github/workflows/changelog_check.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.13' - name: Install Python libraries run: | diff --git a/.github/workflows/documentation_builder.yml b/.github/workflows/documentation_builder.yml index 5bc9aab..9a3cc11 100644 --- a/.github/workflows/documentation_builder.yml +++ b/.github/workflows/documentation_builder.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.13" - name: Install Python libraries run: | diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 7ef9d5e..9279df3 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.13' - name: Install Formatting run: | @@ -42,7 +42,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python: ["3.10", "3.11", "3.12", "3.13"] + python: ["3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: @@ -74,7 +74,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python: ["3.11"] + python: ["3.13"] runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: diff --git a/docs/changelogs/1.2.0.md b/docs/changelogs/1.2.0.md index 522fb00..83a5e71 100644 --- a/docs/changelogs/1.2.0.md +++ b/docs/changelogs/1.2.0.md @@ -11,7 +11,7 @@ :octicons-issue-opened-24: Issue Ref | :fontawesome-solid-thumbtack: Summary | :material-message-text: Description -|-|- [No ref] | Adding flag to detect OneCode Cloud env | Useful flag to handle local vs cloud env when running code using display (e.g. plot show). -[No Ref] | Python version 3.13 now supported | All Python versions ranging from 3.10 through 3.13 are now supported. +[No Ref] | Python version 3.13 and 3.14 are now supported | All Python versions ranging from 3.10 through 3.14 are now supported. [No Ref] | No longer checking modules at startup | `ONECODE_FLAG_CHECK_MODULES` not set to False by default as verbosity is annoying, especially combined with #45. [No Ref] | Avoid warnings on duplicate files with `onecode-zip` | `onecode-zip` checks first if file already added to the archive (in case of duplicates entry in MANIFEST). diff --git a/onecode/__init__.py b/onecode/__init__.py index f51444a..1149f4b 100644 --- a/onecode/__init__.py +++ b/onecode/__init__.py @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2023-2024 DeepLime # SPDX-License-Identifier: MIT -__version__ = "1.2.0.dev" +__version__ = "1.2.0" from .base import * diff --git a/onecode/cli/utils.py b/onecode/cli/utils.py index 6f6718f..69b2220 100644 --- a/onecode/cli/utils.py +++ b/onecode/cli/utils.py @@ -9,7 +9,6 @@ from typing import Dict, List, Optional import pydash -from astunparse import unparse from InquirerPy.base.control import Choice from pycg.pycg import CallGraphGenerator from pycg.utils.constants import CALL_GRAPH_OP @@ -178,7 +177,7 @@ def extract_calls( code.body[0].value.func = ast.parse(fn['normed']) calls.append({ "func": fn['normed'], - "loc": unparse(code).strip() + "loc": ast.unparse(code).strip() }) else: if verbose: diff --git a/pyproject.toml b/pyproject.toml index e6621b8..04d9f25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "onecode" -version = "1.2.0.dev" +version = "1.2.0" description = "Python skeleton and library for OneCode projects" readme = "README.md" authors = ["DeepLime "] @@ -23,7 +23,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = ">=3.8, <3.14" +python = ">=3.8, <3.15" 'flufl.lock' = ">=7.1.1,<9" pandas = ">=1.4.0,<3" pydash = ">=5.1.0,<8" @@ -33,9 +33,8 @@ typeguard = ">=3,<5" requirements-parser = ">=0.10.2,<1" # cli -astunparse = ">=1.6.3,<2" inquirerpy = ">=0.3.3,<1" -onecode-pycg = ">=0.0.7,<1" +onecode-pycg = ">=0.0.7,<2" yaspin = ">=2.1.0,<4" # docs diff --git a/tests/emulations/base/test_run_project.py b/tests/emulations/base/test_run_project.py index 8d5e1b1..02fb44c 100644 --- a/tests/emulations/base/test_run_project.py +++ b/tests/emulations/base/test_run_project.py @@ -73,18 +73,30 @@ def test_output_multiprocess(): flow_dir = os.path.join(tmp, flow_folder) flow_data = os.path.join(flow_dir, 'data') - with open(os.path.join(flow_dir, 'flows', f'{flow_id}.py'), 'a') as f: + with open(os.path.join(flow_dir, 'flows', 'utils.py'), 'w') as f: + f.write(""" +import onecode + + +def write_output(data, flow_name): + onecode.Project().current_flow = flow_name + onecode.Project().write_output({data: '0'}) + """) + + with open(os.path.join(flow_dir, 'flows', f'{flow_id}.py'), 'w') as f: f.write(""" - from multiprocessing import Process +from multiprocessing import Process +from flows.utils import write_output +import onecode - def write_output(data): - onecode.Project().write_output({data: '0'}) +def run(): names = ['b', 'a', 'c'] * 10 procs = [] - + parent_flow = onecode.Project().current_flow + for name in names: - proc = Process(target=write_output, args=(name,)) + proc = Process(target=write_output, args=(name, parent_flow)) procs.append(proc) proc.start() @@ -119,18 +131,30 @@ def test_manifest_cleaning(): flow_dir = os.path.join(tmp, flow_folder) flow_data = os.path.join(flow_dir, 'data') - with open(os.path.join(flow_dir, 'flows', f'{flow_id}.py'), 'a') as f: + with open(os.path.join(flow_dir, 'flows', 'utils.py'), 'w') as f: f.write(""" - from multiprocessing import Process +import onecode + - def write_output(data): - onecode.Project().write_output({data: '0'}) +def write_output(data, flow_name): + onecode.Project().current_flow = flow_name + onecode.Project().write_output({data: '0'}) + """) + + with open(os.path.join(flow_dir, 'flows', f'{flow_id}.py'), 'w') as f: + f.write(""" +from multiprocessing import Process +from flows.utils import write_output +import onecode + +def run(): names = ['b', 'a', 'c'] * 10 procs = [] + parent_flow = onecode.Project().current_flow for name in names: - proc = Process(target=write_output, args=(name,)) + proc = Process(target=write_output, args=(name, parent_flow)) procs.append(proc) proc.start() diff --git a/tests/unit/elements/test_dropdown.py b/tests/unit/elements/test_dropdown.py index 7f5152c..c4cd6e8 100644 --- a/tests/unit/elements/test_dropdown.py +++ b/tests/unit/elements/test_dropdown.py @@ -1,3 +1,5 @@ +import sys + import pytest from onecode import Dropdown, Mode, Project @@ -100,7 +102,11 @@ def test_execute_invalid_single_dropdown_single_choice(): with pytest.raises(TypeError) as excinfo: widget() - assert "Invalid value A, expected: list(typing.Union[str, int, float])" == str(excinfo.value) + if sys.version_info < (3, 14): + assert "Invalid value A, expected: list(typing.Union[str, int, float])" \ + == str(excinfo.value) + else: + assert "Invalid value A, expected: list(str | int | float)" == str(excinfo.value) def test_execute_invalid_single_dropdown_multiple_choice(): @@ -117,8 +123,12 @@ def test_execute_invalid_single_dropdown_multiple_choice(): with pytest.raises(TypeError) as excinfo: widget() - assert "Invalid value type for each element of ['A', 'C'], expected: " \ - "typing.List[typing.Union[str, int, float]]" == str(excinfo.value) + if sys.version_info < (3, 14): + assert "Invalid value type for each element of ['A', 'C'], expected: " \ + "typing.List[typing.Union[str, int, float]]" == str(excinfo.value) + else: + assert "Invalid value type for each element of ['A', 'C'], expected: " \ + "typing.List[str | int | float]" == str(excinfo.value) def text_execute_invalid_optional_dropdown(): diff --git a/tests/unit/elements/test_slider.py b/tests/unit/elements/test_slider.py index cff2197..5b146d9 100644 --- a/tests/unit/elements/test_slider.py +++ b/tests/unit/elements/test_slider.py @@ -1,3 +1,5 @@ +import sys + import pytest from onecode import Mode, Project, Slider @@ -106,7 +108,10 @@ def test_execute_invalid_single_slider(): with pytest.raises(TypeError) as excinfo: widget() - assert "Invalid value 0.6, expected: list(typing.Union[float, int])" == str(excinfo.value) + if sys.version_info < (3, 14): + assert "Invalid value 0.6, expected: list(typing.Union[float, int])" == str(excinfo.value) + else: + assert "Invalid value 0.6, expected: list(float | int)" == str(excinfo.value) def test_execute_invalid_multiple_slider(): @@ -122,8 +127,12 @@ def test_execute_invalid_multiple_slider(): with pytest.raises(TypeError) as excinfo: widget() - assert "Invalid value type for [0.6, 0.3, 0.4], expected: typing.Union[float, int]" == \ - str(excinfo.value) + if sys.version_info < (3, 14): + assert "Invalid value type for [0.6, 0.3, 0.4], expected: typing.Union[float, int]" == \ + str(excinfo.value) + else: + assert "Invalid value type for [0.6, 0.3, 0.4], expected: float | int" == \ + str(excinfo.value) def test_execute_invalid_min_max_single_slider():