DamnWidget / anaconda

Anaconda turns your Sublime Text 3 in a full featured Python development IDE including autocompletion, code linting, IDE features, autopep8 formating, McCabe complexity checker Vagrant and Docker support for Sublime Text 3 using Jedi, PyFlakes, pep8, MyPy, PyLint, pep257 and McCabe that will never freeze your Sublime Text 3
http://damnwidget.github.io/anaconda/
GNU General Public License v3.0
2.21k stars 260 forks source link

Syntax error with vaild f-string #873

Open ndharper opened 3 years ago

ndharper commented 3 years ago

Hi There,

I had a look and this may be similar to issue 741. I get a syntax error on a print(f'string) although the syntax is actually fine. It's inside a try/except block, last line below. The error displayed is [E] Invalid Sytntax. The same line copied to the end of the module doesn't show an error so I think it's something to do with it being inside the except block.

                        try:
                            if rec['redcap_event_name'] == 'neonatal_scan_arm_1':
                                if float(rec['nscan_ga_at_birth_weeks']) >= 37:
                                    # term scans
                                    out_flags['scans_type_nt'] += 1

                                else:
                                    if float(rec['nscan_ga_at_scan_weeks']) < 37:
                                        out_flags['scans_type_npt'] += 1
                                    else:
                                        out_flags['scans_type_ntt'] += 1
                            else:
                                out_flags['scans_type_f'] += 1
                        except ValueError:
                            print(f'{participationid} invalid gestational or scan age')  # SYNTAX ERROR


print(f'{participationid} invalid gestational or scan age') # NO SYNTAX ERROR.

Python interpreter in user settings is */ "python_interpreter": "python",

/*
    Disable anaconda completion

    WARNING: setting this as true will totally disable anaconda completion.
*/

python --version from terminal is 3.7.3. Running maOS Catalina 10.15.6 SublimeText 3.2.2 Build 3211 Anaconda v2.1.37

No errors on the ST console. I can't find the Anaconda JsonServer logs.

Expected Behaviour

Actual Behaviour

Steps to Reproduce

ST3, Anaconda and OS versions

ST3 Console Logs

Anaconda's JsonServer Logs

Note: Anaconda's JsonServer logs can be found in:

scuml commented 3 years ago

Could you type which python in the terminal and paste that full path to the python_interpreter setting. The standard python install in Catalina is 2.7.16 and most likely, that's what Anaconda is using.

ndharper commented 3 years ago

Hi Stephen,

Here you go.

(base) Nicholass-Air:~ nicholasdharper$ which python \/Users/nicholasdharper/anaconda3/bin/python

Nick On 7 Oct 2020, 22:24 +0100, Stephen Mitchell notifications@github.com, wrote:

Could you type which python in the terminal and paste that full path to the python_interpreter setting. The standard python install in Catalina is 2.7.16 and most likely, that's what Anaconda is using.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDamnWidget%2Fanaconda%2Fissues%2F873%23issuecomment-705202235&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7Cf17eeecd082a41bf649d08d86b076b35%7C8370cf1416f34c16b83c724071654356%7C0&sdata=SkD1YYXapIKkPGo7O6zffeH6HsMb6DfVMopNngZmqOU%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKWQR3OJXWHVQFVDFMYUKRDSJTMB5ANCNFSM4SHFGQJQ&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7Cf17eeecd082a41bf649d08d86b076b35%7C8370cf1416f34c16b83c724071654356%7C0&sdata=HUqbexXwVIxUzFctCjn995yw7bpDnDCFRFeeHBntCmE%3D&reserved=0.

DamnWidget commented 3 years ago

Check which interpreter is configured in your settings for anaconda, this totally looks like anaconda is using a 2.7.x interpreter instead of Python3, also note that the interpreter that gets reported to you while using type python in your terminal does not necessarily has to match what SublimeText 3 gets as default python interpreter as you can have additions to your $PATH environment variable due your SHELL and Terminal of choice.

ndharper commented 3 years ago

Hi Oscar,

Anaconda is using python 3.7.3.

BW Nick On 8 Oct 2020, 11:39 +0100, Oscar Campos notifications@github.com, wrote:

Check with interpreter is configured in your settings for anaconda, this totally looks like anaconda is using a 2.7.x interpreter instead of Python3, also note that the interpreter that gets reported to you while using type python in your terminal does not necessarily has to match what SublimeText 3 gets as default python interpreter as you can have additions to your $PATH environment variable due your SHELL and Terminal of choice.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDamnWidget%2Fanaconda%2Fissues%2F873%23issuecomment-705485267&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=TQVBpsvg8GUGgtt7bsehkvvjjZEP79kjxMzEigZV4QY%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKWQR3PJYBOFXYJF4WOPCULSJWJE3ANCNFSM4SHFGQJQ&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=VZKQXCGAiYap6AKd9%2Bp3vcnXx2exRZlxj6l%2FC1GFT5k%3D&reserved=0.

ndharper commented 3 years ago

Hi Oscar,

Further update.

I’ll refer to Anaconda from anaconda.com as anaconda and anaconda from DammWidget as DW just to avoid confusion. I noticed that listing has stopped working within Spyder under Anaconda. After chasing a bit I decided to reinstall completely and now ST+DW is well and truly jacked up. Listing doesn’t work at all but now when I try to run the python script it actually fails with an Syntax error. Before I did reinstall I was DW was listing the line as an error but it ran fine. It does seem to work if I replace the f-string with a simple string so I think you’ve got the right idea about it finding the wrong python.

Here’s the complete contents of the Anaconda.sublime-settings user settings.

{ "auto_formatting": true, "autoformat_ignore": [ ], "pep8_ignore": [ "E501" ], "anaconda_linter_underlines": false, "anaconda_linter_mark_style": "none", "display_signatures": false, "disable_anaconda_completion": true, "python_interpreter": "/nicholasdharper/opt/anaconda3/python3" }

I will say that Anaconda.com doesn’t play at all nicely with ST+DW but I end up using both and I want to use the same python version.

BW Nick

On 8 Oct 2020, 11:39 +0100, Oscar Campos notifications@github.com, wrote:

Check with interpreter is configured in your settings for anaconda, this totally looks like anaconda is using a 2.7.x interpreter instead of Python3, also note that the interpreter that gets reported to you while using type python in your terminal does not necessarily has to match what SublimeText 3 gets as default python interpreter as you can have additions to your $PATH environment variable due your SHELL and Terminal of choice.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDamnWidget%2Fanaconda%2Fissues%2F873%23issuecomment-705485267&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=TQVBpsvg8GUGgtt7bsehkvvjjZEP79kjxMzEigZV4QY%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKWQR3PJYBOFXYJF4WOPCULSJWJE3ANCNFSM4SHFGQJQ&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=VZKQXCGAiYap6AKd9%2Bp3vcnXx2exRZlxj6l%2FC1GFT5k%3D&reserved=0.

ndharper commented 3 years ago

Hi Oscar,

I’ve reinstalled Anaconda and Spyder and have the listing turned on. Spyder doesn’t flag the line and the code runs fine. Code runs fine but line is flagged with syntax error inside the except block, not outside. Everything indicates that it’s running Python 3.7.

I don’t think it can be using Python 2 interpreter because f-strings weren’t in Python 2 so I’d expect it to flag the statement outside the except block too.

I did try on my Windows machine at work and this doesn’t generate the syntax error.

So I think it’s a bug, albeit a mild irritation rather than a show stopper.

Best wishes Nick

Nick On 8 Oct 2020, 16:27 +0100, Harper, Nicholas nicholas.harper@kcl.ac.uk, wrote: Hi Oscar,

Further update.

I’ll refer to Anaconda from anaconda.com as anaconda and anaconda from DammWidget as DW just to avoid confusion. I noticed that listing has stopped working within Spyder under Anaconda. After chasing a bit I decided to reinstall completely and now ST+DW is well and truly jacked up. Listing doesn’t work at all but now when I try to run the python script it actually fails with an Syntax error. Before I did reinstall I was DW was listing the line as an error but it ran fine. It does seem to work if I replace the f-string with a simple string so I think you’ve got the right idea about it finding the wrong python.

Here’s the complete contents of the Anaconda.sublime-settings user settings.

{ "auto_formatting": true, "autoformat_ignore": [ ], "pep8_ignore": [ "E501" ], "anaconda_linter_underlines": false, "anaconda_linter_mark_style": "none", "display_signatures": false, "disable_anaconda_completion": true, "python_interpreter": "/nicholasdharper/opt/anaconda3/python3" }

I will say that Anaconda.com doesn’t play at all nicely with ST+DW but I end up using both and I want to use the same python version.

BW Nick

On 8 Oct 2020, 11:39 +0100, Oscar Campos notifications@github.com, wrote:

Check with interpreter is configured in your settings for anaconda, this totally looks like anaconda is using a 2.7.x interpreter instead of Python3, also note that the interpreter that gets reported to you while using type python in your terminal does not necessarily has to match what SublimeText 3 gets as default python interpreter as you can have additions to your $PATH environment variable due your SHELL and Terminal of choice.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDamnWidget%2Fanaconda%2Fissues%2F873%23issuecomment-705485267&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=TQVBpsvg8GUGgtt7bsehkvvjjZEP79kjxMzEigZV4QY%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKWQR3PJYBOFXYJF4WOPCULSJWJE3ANCNFSM4SHFGQJQ&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C3ec9b8683d084804daca08d86b76648a%7C8370cf1416f34c16b83c724071654356%7C0&sdata=VZKQXCGAiYap6AKd9%2Bp3vcnXx2exRZlxj6l%2FC1GFT5k%3D&reserved=0.

DamnWidget commented 3 years ago

Sorry for the delay, I've been just busy as usual,

As far as I know AnacondaST3 does not works with Anaconda the Python distribution or so I've been told in the past, I never had opportunity to check it out as I never used Anaconda (the Python distribution) and I don't really use Python since around 6 years ago.

If you need to use the Anaconda Python distribution I suggest you to try some other plugin (I am not sure how rich is the Python ecosystem in ST3 nowadays), or even try another editor.

Sorry about that mate

ndharper commented 3 years ago

Hi Oscar,

No worries. Like I said, this isn’t exactly a deal breaker and I fully accept that the ultimate problem is probably something on the anaconda.com side.

I do find I use anaconda, or more specifically spyder partly because it’s got such a rich set of scientific python modules and because it really does the trick when I need a complete IDE for things like setting breakpoints and when I need to pass command line parameters. OTOH, the editor isn’t nearly as powerful as ST so I use both. I was running on the Mac with ST using the native mac python but I was too much of a pain to keep track of which modules were installed in which environment.

Cheers Nick

Nick On 11 Oct 2020, 00:23 +0100, Oscar Campos notifications@github.com, wrote:

Sorry for the delay, I've been just busy as usual,

As far as I know AnacondaST3 does not works with Anaconda the Python distribution or so I've been told in the past, I never had opportunity to check it out as I never used Anaconda (the Python distribution) and I don't really use Python since around 6 years ago.

If you need to use the Anaconda Python distribution I suggest you to try some other plugin (I am not sure how rich is the Python ecosystem in ST3 nowadays), or even try another editor.

Sorry about that mate

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDamnWidget%2Fanaconda%2Fissues%2F873%23issuecomment-706624847&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C1d0f7aace4fc44a85fc608d86d736eb0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=%2B0ZU5ENxIB5NIxaaNrxrgdK1AkrWSAV5gY1Njy2wIZo%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKWQR3JBZFS6MLQUAOFZTX3SKDUFJANCNFSM4SHFGQJQ&data=01%7C01%7Cnicholas.harper%40kcl.ac.uk%7C1d0f7aace4fc44a85fc608d86d736eb0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=8N2DADOC58sejRIWdKzf%2F%2BUwRN4ckg2d%2FYbfCqwdb%2Fk%3D&reserved=0.