From 1714b617ffc6788564ead5e835c4d4269a22c7a0 Mon Sep 17 00:00:00 2001 From: almenon Date: Sun, 17 Nov 2024 10:05:29 -0800 Subject: [PATCH 1/5] ignore files that do not need to be in final package --- .vscodeignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.vscodeignore b/.vscodeignore index f717712..c2a5c7d 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -13,6 +13,14 @@ tsconfig.json personal/** .travis.yml dependencygraph.svg +.hypothesis +.env +.vscode-test.js +areplDemoGif2.gif +copy_backend.bat +notes.txt +*.code-workspace +tslint.json #pycharm dir .idea/** # coverage output From 18ac84f97d82a36e1fd94a3e13d93e5a8fc22de6 Mon Sep 17 00:00:00 2001 From: almenon Date: Sun, 17 Nov 2024 10:06:01 -0800 Subject: [PATCH 2/5] remove saved feature --- README.md | 32 -------------------------------- changelog.md | 3 +++ package-lock.json | 14 +++++++------- package.json | 7 +------ src/PreviewManager.ts | 2 -- src/pythonPanelPreview.ts | 10 +++++++--- src/toAREPLLogic.ts | 13 ++----------- 7 files changed, 20 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index e4afcba..2fe8b65 100644 --- a/README.md +++ b/README.md @@ -145,38 +145,6 @@ I have [overridden the display](https://github.com/Almenon/AREPL-backend/blob/ma If you want a type to be displayed in a particular manner just [file an issue](https://github.com/Almenon/AREPL-vscode/issues) -### #$save - -*This is buggy and I would suggest using the [arepl_store variable](https://github.com/Almenon/AREPL-vscode/wiki/Caching-data-between-runs) instead* - -If you want to avoid a section of code being executed in real-time (due to it being slow or calling external resources) you can use \#\$save. For example: - -```python -def largest_prime_factor(n): - i = 2 - while i * i <= n: - if n % i: - i += 1 - else: - n //= i - return n - -# this takes a looonnggg time to execute -result = largest_prime_factor(8008514751439999) - -#$save -print("but now that i saved i am back to real-time execution") -``` - -```python -import random -x = random.random() -#$save -print(x) # this number will not change when editing below the #$save line -``` - -Please note that \#\$save [does not work](https://github.com/Almenon/AREPL-vscode/issues/53) with certain types, like generators. If #$save fails in pickling the code state [file an issue](https://github.com/Almenon/AREPL-vscode/issues) so I can look into it. - ### More Stuff Check out the [wiki](https://github.com/Almenon/AREPL-vscode/wiki)! diff --git a/changelog.md b/changelog.md index 0eeb39b..9488d24 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ 🐛 As a consequence of above, AREPL will no longer crash when there is a infinite loop 🐛 As a consequence of above, pandas now works better 🐛 As a consequence of above, boto3 now works better +🔧 `#$save` feature has been removed +🔧 Removed `keepPreviousVars` setting +🔧 `arepl_store` variable has been removed. ## v2.0.5 (3/5/2023) 🐛🚀 🐛 [Fixed inconsistent variable display in certain cases](https://github.com/Almenon/AREPL-vscode/issues/3716) diff --git a/package-lock.json b/package-lock.json index 297513a..ad7bbfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "SEE LICENSE IN ", "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.3" + "arepl-backend": "^3.0.4" }, "devDependencies": { "@types/mocha": "^10.0.9", @@ -631,9 +631,9 @@ } }, "node_modules/arepl-backend": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.3.tgz", - "integrity": "sha512-ruzBMW4/szcfkxlpuroWiJsnI1Rc9odFZOjh60tvLbrFC7dFhchWiB9SVRDve5XMIW6spkp2a/oN7t/SBzCCJw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.4.tgz", + "integrity": "sha512-HSVWEpttvhbpLWAZ8pxJdYRs29iviaS8qncQUMLFRDnQtQrwxZqeMzOb9sg2OqvAc2vy8yK1PtIvTshWvICcDw==", "dependencies": { "python-shell": "^5.0.0" } @@ -2934,9 +2934,9 @@ } }, "arepl-backend": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.3.tgz", - "integrity": "sha512-ruzBMW4/szcfkxlpuroWiJsnI1Rc9odFZOjh60tvLbrFC7dFhchWiB9SVRDve5XMIW6spkp2a/oN7t/SBzCCJw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.4.tgz", + "integrity": "sha512-HSVWEpttvhbpLWAZ8pxJdYRs29iviaS8qncQUMLFRDnQtQrwxZqeMzOb9sg2OqvAc2vy8yK1PtIvTshWvICcDw==", "requires": { "python-shell": "^5.0.0" } diff --git a/package.json b/package.json index 585dd99..c9aa4ea 100644 --- a/package.json +++ b/package.json @@ -193,11 +193,6 @@ "type": "boolean", "default": false, "description": "Whether to automatically load django models. This setting doesn't actually do anything yet. See https://github.com/Almenon/AREPL-vscode/issues/279" - }, - "AREPL.keepPreviousVars": { - "type": "boolean", - "default": false, - "description": "If set to true AREPL will add onto the local state each run instead of clearing it and starting fresh." } } }, @@ -292,7 +287,7 @@ }, "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.3" + "arepl-backend": "^3.0.4" }, "bugs": { "url": "https://github.com/almenon/arepl-vscode-wordcount/issues", diff --git a/src/PreviewManager.ts b/src/PreviewManager.ts index 5580b99..831bdb6 100644 --- a/src/PreviewManager.ts +++ b/src/PreviewManager.ts @@ -142,8 +142,6 @@ export default class PreviewManager { const data: ExecArgs = { evalCode: codeLines, filePath, - savedCode: '', - usePreviousVariables: true, show_global_vars: settingsCached.get('showGlobalVars'), default_filter_vars: settingsCached.get('defaultFilterVars'), default_filter_types: settingsCached.get('defaultFilterTypes') diff --git a/src/pythonPanelPreview.ts b/src/pythonPanelPreview.ts index 9ffded0..d4225ba 100644 --- a/src/pythonPanelPreview.ts +++ b/src/pythonPanelPreview.ts @@ -31,6 +31,9 @@ export default class PythonPanelPreview {
@@ -84,11 +87,12 @@ turtle.left(90) import requests import datetime as dt +# We don't want to spam an API with calls every time we stop typing +# so we use #$end to deactivate real-time mode for everything afterwords +# then we can run blocks of code as desired with command-enter or control-enter +#$end r = requests.get("https://api.github.com") -#$save -# #$save saves state so request is not re-executed when modifying below - now = dt.datetime.now() if r.status_code == 200: print("API up at " + str(now)) diff --git a/src/toAREPLLogic.ts b/src/toAREPLLogic.ts index 4480c62..a974b4a 100644 --- a/src/toAREPLLogic.ts +++ b/src/toAREPLLogic.ts @@ -7,7 +7,6 @@ import {settings} from "./settings" */ export class ToAREPLLogic{ - lastSavedSection = "" lastCodeSection = "" lastEndSection = "" @@ -33,16 +32,11 @@ export class ToAREPLLogic{ let codeLines = text.split(eol) - let savedLines: string[] = [] let startLineNum = 0 let endLineNum = codeLines.length codeLines.forEach((line, i) => { - if(line.trimRight().endsWith("#$save")){ - savedLines = codeLines.slice(0, i + 1) - startLineNum = i+1 - } - if(line.trimRight().endsWith("#$end")){ + if(line.trimEnd().endsWith("#$end")){ endLineNum = i+1 return } @@ -60,8 +54,6 @@ export class ToAREPLLogic{ const data: ExecArgs = { evalCode: codeLines.join(eol), filePath, - savedCode: savedLines.join(eol), - usePreviousVariables: settingsCached.get('keepPreviousVars'), show_global_vars: showGlobalVars, default_filter_vars: settingsCached.get('defaultFilterVars'), default_filter_types: settingsCached.get('defaultFilterTypes') @@ -69,12 +61,11 @@ export class ToAREPLLogic{ // user should be able to rerun code without changing anything // only scenario where we dont re-run is if just end section is changed - if(endSection != this.lastEndSection && data.savedCode == this.lastSavedSection && data.evalCode == this.lastCodeSection){ + if(endSection != this.lastEndSection && data.evalCode == this.lastCodeSection){ return false } this.lastCodeSection = data.evalCode - this.lastSavedSection = data.savedCode this.lastEndSection = endSection this.PythonExecutor.execCode(data) From cd4d67e51c261a1d531cb195e937c5adea6ffb1e Mon Sep 17 00:00:00 2001 From: almenon Date: Sun, 17 Nov 2024 15:59:45 -0800 Subject: [PATCH 3/5] fix format --- src/pythonPanelPreview.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pythonPanelPreview.ts b/src/pythonPanelPreview.ts index d4225ba..70dba24 100644 --- a/src/pythonPanelPreview.ts +++ b/src/pythonPanelPreview.ts @@ -40,15 +40,13 @@ export default class PythonPanelPreview {

Examples

Simple List

- -x = [1,2,3] +x = [1,2,3] y = [num*2 for num in x] print(y)

Dumping

- -from arepl_dump import dump +from arepl_dump import dump def milesToKilometers(miles): kilometers = miles*1.60934 @@ -69,8 +67,7 @@ a=2

Turtle

- -import turtle +import turtle # window in right hand side of screen turtle.setup(500,500,-1,0) @@ -83,8 +80,7 @@ turtle.left(90)

Web call

- -import requests +import requests import datetime as dt # We don't want to spam an API with calls every time we stop typing From 6bb109513fccaf5de4b623308e9aafc85898adaf Mon Sep 17 00:00:00 2001 From: almenon Date: Sun, 17 Nov 2024 15:59:52 -0800 Subject: [PATCH 4/5] fix --- src/toAREPLLogic.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/toAREPLLogic.ts b/src/toAREPLLogic.ts index a974b4a..8a2ed2f 100644 --- a/src/toAREPLLogic.ts +++ b/src/toAREPLLogic.ts @@ -41,7 +41,6 @@ export class ToAREPLLogic{ return } }); - const endSection = codeLines.slice(endLineNum).join(eol) codeLines = codeLines.slice(startLineNum, endLineNum) const unsafeKeywords = settingsCached.get('unsafeKeywords') @@ -59,14 +58,12 @@ export class ToAREPLLogic{ default_filter_types: settingsCached.get('defaultFilterTypes') } - // user should be able to rerun code without changing anything - // only scenario where we dont re-run is if just end section is changed - if(endSection != this.lastEndSection && data.evalCode == this.lastCodeSection){ + if(data.evalCode == this.lastCodeSection){ + // nothing changed, no point in rerunning return false } this.lastCodeSection = data.evalCode - this.lastEndSection = endSection this.PythonExecutor.execCode(data) From 95f1acabd39e91841351a6a8cb6f55440a9f46f5 Mon Sep 17 00:00:00 2001 From: almenon Date: Sun, 17 Nov 2024 20:45:51 -0800 Subject: [PATCH 5/5] fix: runAreplBlock --- package-lock.json | 14 +++++++------- package.json | 2 +- src/PreviewManager.ts | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad7bbfa..be65ad5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "SEE LICENSE IN ", "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.4" + "arepl-backend": "^3.0.5" }, "devDependencies": { "@types/mocha": "^10.0.9", @@ -631,9 +631,9 @@ } }, "node_modules/arepl-backend": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.4.tgz", - "integrity": "sha512-HSVWEpttvhbpLWAZ8pxJdYRs29iviaS8qncQUMLFRDnQtQrwxZqeMzOb9sg2OqvAc2vy8yK1PtIvTshWvICcDw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.5.tgz", + "integrity": "sha512-OE/EEmq3uplEDGzAl5V+JTCNU2bIfBGXUTb0ExYO4jkPPB7ZdSRlba0IYGDv0VSyBiVRZWE9gXtZEdet2Ynudw==", "dependencies": { "python-shell": "^5.0.0" } @@ -2934,9 +2934,9 @@ } }, "arepl-backend": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.4.tgz", - "integrity": "sha512-HSVWEpttvhbpLWAZ8pxJdYRs29iviaS8qncQUMLFRDnQtQrwxZqeMzOb9sg2OqvAc2vy8yK1PtIvTshWvICcDw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.5.tgz", + "integrity": "sha512-OE/EEmq3uplEDGzAl5V+JTCNU2bIfBGXUTb0ExYO4jkPPB7ZdSRlba0IYGDv0VSyBiVRZWE9gXtZEdet2Ynudw==", "requires": { "python-shell": "^5.0.0" } diff --git a/package.json b/package.json index c9aa4ea..20f0717 100644 --- a/package.json +++ b/package.json @@ -287,7 +287,7 @@ }, "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.4" + "arepl-backend": "^3.0.5" }, "bugs": { "url": "https://github.com/almenon/arepl-vscode-wordcount/issues", diff --git a/src/PreviewManager.ts b/src/PreviewManager.ts index 831bdb6..a2444ed 100644 --- a/src/PreviewManager.ts +++ b/src/PreviewManager.ts @@ -142,6 +142,7 @@ export default class PreviewManager { const data: ExecArgs = { evalCode: codeLines, filePath, + usePreviousVariables: true, show_global_vars: settingsCached.get('showGlobalVars'), default_filter_vars: settingsCached.get('defaultFilterVars'), default_filter_types: settingsCached.get('defaultFilterTypes')