-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
IDE support #276
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
IDE support #276
Conversation
I've thought about the solution we discussed last stand-up, which would look something like this in a dash component
and the current solution in this PR looks like this:
the The object based solution has two benefits over the solution I have implemented in this PR,
and two drawback that I can think of:
The current solution also may work better if the default arguments were included, for example if a property had Anybody have thoughts on this or other drawbacks I haven't thought of, or have on opinion on which solution you prefer? I am personally for the current solution since I think the actual default value should be explicitly stated in the class code for documentation purposes (right now it is not in the docstring, the best place I know to look for it is the src/components/component.js). |
I think it might be nice to have a family of default values like It's definitely not Pythonic, but it would make for a nicer experience than |
(PS: the proposal above isn't just mine, it's something that was discussed briefly after the last call!) |
That seems better than I think we have all the functionality of this already, albeit without the default value type being written out as they would be if we included those class names as default arguments (but that information is written in the docstring, the actual default value is not included there currently). E.g., errors are thrown if required arguments are not included, and optional and not included values are not passed to the base |
Added more meaningful default arguments as discussed last standup, |
else: | ||
return ( | ||
'Table(' + | ||
repr(getattr(self, self._prop_names[0], None)) + ')') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see room for improvement in making these classes even more minimal? I don't think we have to do it in this PR, but in the future it might be nice if these classes were able to inherit more of this logic, mainly because it looks pretty gnarly 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a lot of it could be moved into the base component (pretty much everything that is not an attribute assignment, and even some of those appear to be the same). I'll make a new issue for this
Alright, I'm very happy with this. 💃 from me! |
Awesome! any docs or hint on how to integrate this with our IDE or editor? |
What editor are you using? A lot of editors I tested work out the box if you install |
I'm using geany. |
This builds on #271 and adds explicit arguments to generated dash component python class
__init__
functions (rather than**kwargs
), which improves experience in an IDE.Atom example
Pycharm example
Jupyter Notebook example
Notes
dash_html_components
ordash_core_components
are updated build using this version of thedash
module, a user must also updatedash
since a new function_explicitize_args
is added todash.development.base_component
. There are workarounds for this (putting the new function in the archetype generator or into the init.py file, or any shared file in a component module), but I think they are messy since it separates base component code into multiple repositories. I will add an exception to both of thedash-*-components
packages that say to download the newdash
version.inspect
would not work for python2. They work for python 3 since we are able to change the function signature ofComponent.__init__
to be correct even though it is actually(*args, **kwargs)
after the_explicitize_args
decorator is applied. This did not matter for Atom and PyCharm, but it seems Jupyter uses the inspect module to perform autocomplete.dash
version and keeping olddash_*_components
modules auto-magically adds the auto-complete functionality to Jupyter notebooks, but not Atom or PyCharm.