Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError in snippets extension #15960

Closed
MJV1989 opened this issue Jul 1, 2021 · 3 comments
Closed

AttributeError in snippets extension #15960

MJV1989 opened this issue Jul 1, 2021 · 3 comments

Comments

@MJV1989
Copy link

MJV1989 commented Jul 1, 2021

I have no clue as I am a beginner. Hopefully, someone else understands what might have gone wrong. QTextCursor::setPosition: Position '147' out of range QTextCursor::setPosition: Position '147' out of range Traceback (most recent call last): File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/editor/extensions/snippets.py", line 52, in wrapper return f(self, *args, **kwargs) File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/editor/extensions/snippets.py", line 241, in _process_text self.insert_text(text, line, column) File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/editor/extensions/snippets.py", line 383, in insert_text text_node_tokens = list(text_node.tokens) AttributeError: 'NoneType' object has no attribute 'tokens'
@ccordoba12
Copy link
Member

Hey @MJV1989, thanks for reporting. Could you let us know what text you introduced in the editor that generated this error?

@ccordoba12 ccordoba12 added this to the v5.1.0 milestone Jul 1, 2021
@ccordoba12 ccordoba12 changed the title Some Internal Error AttributeError in snippets Jul 1, 2021
@MJV1989
Copy link
Author

MJV1989 commented Jul 2, 2021

Hi @ccordoba12, I believe I was writing the following when this happened:

-- coding: utf-8 --

"""
Spyder Editor

This is a temporary script file.
"""

animals = {'a' : 'aardvark', 'b' : 'baboon', 'c' : 'coati'}

animals['d'] = ['donkey']
animals['d'].append('dog')
animals['d'].append('dingo')

def biggest(aDict):
'''

Parameters
----------
aDict : A dictionary where all the values are lists.

Returns
-------
The key with the largest number of values associated with it.

'''
if aDict == {}:
    return None
else:
    return max(aDict, key = lambda x : len(aDict[x]))

@ccordoba12
Copy link
Member

Thanks for your help @MJV1989! We'll fix this in our next version (5.1.0), to be released at the end of the month.

@ccordoba12 ccordoba12 changed the title AttributeError in snippets AttributeError in snippets extension Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants