question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't open Dict in variable explorer with mixed data types as keys.

See original GitHub issue

Description

What steps will reproduce the problem?

1: Create a dictionary with a mixture of strings and numeric values as keys. eg. colors = {1: ‘red’,‘Y’: ‘yellow’}

2: Attempt to open the dictionary in the variable explorer.

3: no profit.

EDIT: Using this function:

def mixs(self, num):
    try:
        ele = int(num)
        return (0, ele, '')
    except ValueError:
        return (1, num, '')

as a key for the sorted() here:

File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))

fixes the problem, but probably not in the best way.

Traceback

  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 160, in createEditor
    readonly=readonly)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1310, in setup
    remote=remote)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1250, in __init__
    title)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1117, in __init__
    minmax=minmax)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 143, in __init__
    self.set_data(data)
  File "C:\Users\ifeed\anaconda3\envs\spyder\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 173, in set_data
    self.keys = sorted(list(data.keys()))
TypeError: '<' not supported between instances of 'str' and 'int'

Versions

  • Spyder version: 4.1.4
  • Python version: 3.7.7
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.4.1 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.16.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.0.0 (OK)
paramiko >=2.4.0               :  2.7.1 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.4.4 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.5 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.1.1 (OK)
spyder_kernels >=1.9.2;<1.10.0 :  1.9.2 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  None (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  None (OK)
sympy >=0.7.3                  :  None (OK)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Aug 6, 2020

@jitseniesen, we still need to sort them to avoid the problem reported on issue #10702.

0reactions
ccordoba12commented, Aug 13, 2020

@skjerns, I like that idea! I’ll fix this bug first, then you can give it a try in a different pull request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't Spyder open the Dictionary variable when I click on it?
This is a known issue in spyder: #8856. The fix for it is under development for Spyder 4.0, according to the developers.
Read more >
Variable Explorer — Spyder 5 documentation
Dictionaries. Double-clicking on dictionaries will show a viewer displaying each of its keys with its associated value. You can double click any of...
Read more >
Model Explorer - MathWorks
Use the Model Explorer to view, modify, and add elements of Simulink models, Stateflow charts, and workspace variables.
Read more >
Tuple types - C# reference - Microsoft Learn
Learn about C# tuples: lightweight data structures that you can use to ... a tuple variable, initialize it, and access its data members:....
Read more >
BuiltIn - Robot Framework
Items are typically given using the key=value syntax same way as &{dictionary} variables are created in the Variable table. Both keys and values ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found