Back to Community
kvetching - the editor seems very buggy when it comes to indentation

does anyone else experience having to manually delete and retab each new line input into the quantopian code editor? If I dont it throws an indentation error. I am using older safari, chrome, firefox browser and its the same for each.

14 responses

All was well, hitting tab would produce spaces until about a month ago, now unpredictable, use ctrl-] for spaces indent avoiding tab characters, clean in external editor.

Thanks for the bug report, we're looking into it. It looks like we had another report recently.

If you have good steps to reproduce the problem, we'd love to get a quick video or other description of how to make it happen.


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks for the reply Blue and Dan,
This may be due to the fact that I am using OSX 10.8, and cant update my Chrome, Safari, or Firefox browser to the current version for some reason. I havent been able to try on a more updated browser.
But to replicate this, just open any algorithm, and try this: go to the end of a line, say a 'for' statement for example (it doesnt have to be a 'for loop' it could be any kind of line). Hit return, and it auto indents the cursor to where it should be. So type what you want in your 'for' loop, then run the algorithm. It will generate an error ' SyntaxError: expected an indented block ' referring to the line you just entered. If you go back to that line, youll see that the indent isnt composed of tabs but rather spaces. To fix the problem, you have to delete all the spaces, then press tab the required amount of times. This is very annoying because I have to do this for every line I write in any algorithm, hence all the kvetching!
Thanks for looking into it!
Maybe its my browser issue - planned obsolescence - I need to fork over some cash for a new laptop even though this one is fine just old! I want to wait until Apple makes a laptop with a detachable touch screen that you can draw on like iPad pro, but that has the OS operating system on it not that iPad operating system (I guess this is the Microsoft Surface, but with a regular laptop keyboard not that weird keyboard, and not made by Microsoft).

Chrome Version 49.0.2623.112 (64-bit)
This computer will no longer receive Google Chrome updates because Mac OS X 10.6, 10.7, and 10.8 are no longer supported. Learn more

While I am at it:
It would also be very useful to be able to add properties to the context.portfolio objects, like for example, to add context.portfolio.positions[security].datepurchased or context.portfolio.positions[security].someothervariable
As far as I can tell this currently isn't possible, and I know people have requested this elsewhere already, but am adding my voice to that chorus.

If you don't mind us looking at that specific algorithm, can you go into the algorithm and hit the "contact support" button and share that algorithm with us to look at more closely? Or if you can reproduce it in a sample algo and share that with us?

Ander it just has to be consistently all tabs or all spaces for Python to be happy I think, and you're leaning toward tabs while this environment is geared for spaces.
Time was, the tab key would always translate into spaces in the IDE unless I'm mistaken, and along the way that changed so that tab characters show up instead of being replaced by spaces, hence the bug in my opinion. By the way I'm on Windows using Firefox, both up-to-date.

For anyone to compare for them what happens on whatever platforms and browsers may be available:
2. 'New Algorithm'
3. Place cursor at the end of def initialize(context):
4. [Enter]
5. Left arrow key (will verify that the IDE made spaces for the indent, as I would expect, it has always been this way)
6. Place keyboard cursor at the end of that indent, the original position
7. [Tab] Hit the tab key on your keyboard
8. Left arrow key again, once

It will jump back as if moving four spaces to the left, an indication of a tab character present.
Expected four spaces instead.

They might return this to the previous behavior, meanwhile, go with spaces. As a workaround instead of using tab, hold down the control key [or Command key on a Mac] and press the right square bracket key. Ctrl-], that will create spaces. Ctrl (or Command) with the left square bracket does unindent, and those can also be used on highlighted blocks of code.

Hi, I am seeing the same problem recently. Sometimes after I type in the if statement and hit enter, it goes to the new line and adds another layer of indent automatically. This looks correct. But when I run it, it says "incorrect indent". I have to manually replace the tab with spaces or spaces with tab (sometimes with half spaces and half tabs). What is worse is, sometimes the next line of if statement will be skipped somehow, which is very dangerous and buggy. Can quantopian just automatically replace all the tab with spaces? This is super annoying.

And I found out that if I copy the code to another editor, delete it in quantopian, and copy it back, all the tabs will be replaced by spaces. I think there is a bug in the quantopian editor which causes tab to be added in some specific situations instead of spaces.

I'm very sorry you are running into this bug. Unfortunately, I haven't been able to reproduce it, despite many attempts.

Attached is a video. In the video you can see me attempting to reproduce it (there have been many other attempts too). Can you look at the video and tell me what you're doing differently to reproduce the problem?

I am facing this issue as well. The indentation causes compile errors when you copy and paste from one algo to another.

I concur.

But there's nothing mysterious about it. The interpreter does not handle tab correctly, Instead it needs indentation to be solely 4 space characters. Also, if a line is tab based, when typing another line, the new line will also be tab based.

I handle this by using the notepad++ 'TAB to space' command.

the editor should perhaps convert all tabs to 4 spaces at save time.

OK, I think we figured it out. The IDE is supposed to convert the tab into spaces on-the-fly when inserted. We had a regression where in some cases the tab wasn't being converted and was just being put in as a tab.

It's now fixed!

If you have existing tabs in your algo, unfortunately, they aren't cleaned up automatically. But new tabs won't be added.

Sorry for the frustration.

Blue Seahawk:
" .... it just has to be consistently all tabs or all spaces for Python to be happy". A thousand thank-you's for this! Thanks x1000, TonyM.