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

PR: Add an Object Explorer to the Variable Explorer #8852

Merged
merged 47 commits into from
Jun 24, 2019

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Feb 27, 2019

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot (if affecting the UI)

imagen

imagen

Issue(s) Resolved

Fixes #558

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: dalthviz

@pep8speaks
Copy link

pep8speaks commented Feb 27, 2019

Hello @dalthviz! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 156:9: E731 do not assign a lambda expression, use a def

Line 91:9: E731 do not assign a lambda expression, use a def

Comment last updated at 2019-06-24 14:20:26 UTC

@ccordoba12
Copy link
Member

@dalthviz, before you proceed further, please break objecteditor2.py into multiple files (just like the original author of objbrowser organized its code) and make objecteditor2 a module with those files inside it.

@dalthviz dalthviz force-pushed the fixes_issue_558 branch 2 times, most recently from 02ece12 to 31db31d Compare March 4, 2019 01:11
@ccordoba12
Copy link
Member

@dalthviz, this is looking nice, thanks! Jus another note so you keep working on this: I noticed some of the new files you added are using the six library (which seems to be the only external dependency of objbrowser).

Please remove that dependency and instead replace calls to six with calls to our own py3compat module. That way we'll avoid to make Spyder depend on six.

@CAM-Gerlach
Copy link
Member

Overall, good job handling incorporating the external project, aside from a few minor issues I point out in my review. Additionally, one more thing:

Three different headers types are used in three different sets of files:

  • Some places, like in init,py files, you use the one with the (c) copyright, no copyright year and (see LICENSE.txt for details)
  • Elsewhere, e.g. the tests, you use the one with the © copyright, no copyright year and (see spyder/__init__.py for details)
  • Still elsewhere, in files taken from the external project, you use the one with the (c) copyright, beginning copyright year and see NOTICE.txt in the Spyder root directory for details (correctly different, but horribly spliced over two lines instead of putting the line break after the ; where it belongs, and where it is in other such files.

Particularly for new files, we should use one consistent form and stick with it. The canonical form I've been using in new files going forward is:

# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# [Copyright (c) YEARS OTHER AUTHOR(S)]
# Copyright (c) YEAR- Spyder Project Contributors
#
# Distributed under the terms of the LICENSENAME License
# (see [LICENSE.txt [in this directory] [and] [NOTICE.txt in the root] for details)
# -----------------------------------------------------------------------------

(Picking the appropriate bracketed verbiage for the use case). Unless the original file has explicit license-related text in its headers that is substantially different from just a statement that the file is released under the LICENSENAME (which if so, should be preserved) there is no need to repeat the same information (distributed under the MIT License) twice. Any other information should be included below the "see LICENSE.txt..." line separated by one blank line, so the license statement is clean and readable and there is no possibility of missing or misreading it.

In this case since this is included as a self-contained directory, you should include the original LICENSE.txt (as required by the license) in this directory, adding ``Copyright (c) 2019- Spyder Project Contributors (see AUTHORS.txt for details)``` below the original copyright statement line in that file, and use the following form of the above line for files originally from the external project:

# (see LICENSE.txt in this directory and NOTICE.txt in the root for details)

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, @dalthviz ! I tested it and I'm not sure if you already plan to fix these issues or not, but I figured I'd briefly mention them:

  • Regression: The Object should be expanded one level and callable/special attributes hidden by default, so they can be easily spotted like in the previous version of the Object Explorer
  • Regression: Pretty print should be selected by default, not path, since the user is far more likely to be interested in the former than the latter
  • Major Regression: Cannot edit or open a viewer/editor for collections, values, arrays, dataframes etc. that are attributes of objects, like I could before
  • UI: Colors need to be fixed to work with the dark theme
  • UI: Help -> About menu is not necessary and useless as is (as the link is not clickable or even selectable) and should be removed;
  • UX: Settings (in View menu) should be preserved, i.e. new dialogs should launch with the same settings as the last modified dialog; its incredibly tedious to set them every time
  • UI: Column widths should be much narrower (and no wider than the data within), with unicode removed by default as its mostly redundant and type placed second after name
  • UI/UX: "Refresh", "Auto Refresh", "Show callables" and "Show Special" should all be toolbar items, not view mention options, for much easier/quicker access, and make "Table Columns" a top-level menu
  • UX: You should add an option to the NamespaceBrowser context menu to open the object explorer for objects, since the user sometimes might want to view all the extra properties and such of things we open bespoke editors for by default

Also, is there any way to avoid the objecteditor/objecteditor2/objecteditor2.objecteditor situation? It looks a bit like "code smell" and could be confusing, IMO, to someone newer to the codebase. For example, you could rename objecteditor2 and objecteditor to objectexplorer (to match the official name of the feature, and its functionality since it doesn't actually allow editing yet and is different from all the other "editors").

NOTICE.txt Outdated Show resolved Hide resolved
spyder/py3compat.py Outdated Show resolved Hide resolved
NOTICE.txt Outdated Show resolved Hide resolved
@dalthviz
Copy link
Member Author

@CAM-Gerlach thank you for testing this and the detailed list of missing elements! I will take them as a TODO list 👍

@CAM-Gerlach
Copy link
Member

Thanks @dalthviz ! And if any of them are determined not to be in scope here, I can make them a separate (meta)-issue instead.

@dalthviz
Copy link
Member Author

A preview of the menu action for the Object Explorer:

oexplorer

@dalthviz dalthviz marked this pull request as ready for review June 13, 2019 13:55
@ccordoba12
Copy link
Member

ccordoba12 commented Jun 13, 2019

This is looking really good, thanks @dalthviz!

My comments:

  • The object name that appears in the explorer needs to be the actual object name (not Object, as it is shown now, but the one displayed in the Variable Explorer).
  • Let's change the title of the dialog to: <Name> - Object.
  • Let's remove the Refresh and Auto-refresh buttons because they are not doing anything.
  • Let's remove the following columns: summary, repr, str, unicode, inspect predicates, type, inspect.getmodule.
  • Let's rename the following columns:
    • type name: Type
    • is attribute: Attribute
    • is callable: Callable
    • is routine: Routine
    • inspect.getfile: File
    • inspect.getsourcefile: Source file
    • Length: Size
    • path: Path
  • Let's add a column called Value that displays values using the function called value_to_display from spyder-kernels.
  • Let's make the order of columns like this: Name, Type, Size, Value, Callable, Path. The others need to be hidden by default.
  • Let's make showing callables the default.
  • Let's remove the blue color for callables and italics for text. All text must use the same, regular font.
  • Let's hide the dict callables that appear at first level (i.e. at the same level of the object).
  • For the Details section:
    • Let's remove: pretty print, path, unicode, inspect.getcomments.
    • Let's rename:
      • inspect.getdoc: Documentation
      • inspect.getfile: File
      • inspect.getsource: Source code
    • Let's make Documentation the first and default entry.
    • Let's use two instances of CodeEditor for the widget to the right of Details. One should have Python as it's language (for Source Code) and the other should have Rst as its language (for Documentation, File and repr).
    • Let's use the same font used in the editor for those CodeEditor instances.

These are a lot of tasks, but fortunately almost all of them are small.

@dalthviz
Copy link
Member Author

@ccordoba12 also spyder-ide/spyder-kernels#100 needs to be merge for this to be done

@dalthviz
Copy link
Member Author

A new preview:

oe

@dalthviz
Copy link
Member Author

A new preview with the CodeEditor as the details widget:

oe_details

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dalthviz, I left some minor comments about the code, this is almost ready!

NOTICE.txt Outdated Show resolved Hide resolved
spyder/plugins/variableexplorer/plugin.py Outdated Show resolved Hide resolved
NOTICE.txt Outdated Show resolved Hide resolved
NOTICE.txt Outdated Show resolved Hide resolved
NOTICE.txt Outdated Show resolved Hide resolved
@ccordoba12
Copy link
Member

ccordoba12 commented Jun 22, 2019

Some last comments about the organization of the widget:

  • Let's organize the entries in Details like this: Documentation, Source Code, File, repr.
  • Let's add an asterisk next to repr (*).
  • Please add a QLabel at the bottom of Details that expands both its entries and the CodeEditor widget next to it. This QLabel needs to have the following text: (*) Some objects have very large repr's, which can freeze Spyder. Please use this with care.

@dalthviz
Copy link
Member Author

A new preview:

imagen

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @dalthviz for your hard work on this one! It's a fantastic addition to our variable explorer and something I'm sure many of our users will really appreciate.

I only made some minor adjustments and fixed our tests to make them pass.

@ccordoba12 ccordoba12 changed the title PR: Initial implementation of Object Explorer PR: Add an Object Explorer to the Variable Explorer Jun 24, 2019
@ccordoba12 ccordoba12 merged commit 9543582 into spyder-ide:master Jun 24, 2019
@ccordoba12
Copy link
Member

@dalthviz, please don't forget to open an issue about this:

Major Regression: Cannot edit or open a viewer/editor for collections, values, arrays, dataframes etc. that are attributes of objects, like I could before

so you don't forget to address it in beta4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Object Explorer for exploring an object's properties
4 participants