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

Generate_class issue with plotly dahs 0.23.1 and dangerously_set_inner_html #321

Closed
bnouvelbmll opened this issue Aug 3, 2018 · 9 comments
Assignees

Comments

@bnouvelbmll
Copy link

After updating to 0.23.1, the following code importing "dangerously_set_inner_html" does not work anymore. It seems that some field may be missing / not set correctly and that this is field is used in an exec statement. The same import is working with previous release.

Error:

In [1]: import dash_dangerously_set_inner_html
Traceback (most recent call last):

  File "/miniconda/envs/.../lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-1-8721236f3c51>", line 1, in <module>
    import dash_dangerously_set_inner_html

  File "/miniconda/envs/////lib/python3.4/site-packages/dash_dangerously_set_inner_html/__init__.py", line 10, in <module>
    'dash_dangerously_set_inner_html'

  File "/miniconda/envs/.../lib/python3.4/site-packages/dash/development/component_loader.py", line 51, in load_components
    namespace

  File "/miniconda/envs/...lib/python3.4/site-packages/dash/development/base_component.py", line 441, in generate_class
    exec(string, scope)

  File "<string>", line 27
    def __init__(self, children=None, , **kwargs):
@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 3, 2018

I think dash_dangerously_set_inner_html has to be updated. You can downgrade to dash 0.22.0 in the meantime.

@chriddyp
Copy link
Member

chriddyp commented Aug 3, 2018

Hm, did the latest IDE stuff break the existing components? If so, we should make a new release that is backwards compatible, i.e. doesn't break the existing components that are out there.

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 3, 2018

Yes, I think there is some errors in how the classes generates the constructor arguments you can see the invalid part
def __init__(self, children=None, , **kwargs): have an extra comma. I also have problems with dash_flow_example #319.

@chriddyp
Copy link
Member

chriddyp commented Aug 3, 2018

@rmarren1 - Could you check this out too?

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 3, 2018

I found the issue with dash_flow_example

[('{:s}=Component.REQUIRED'.format(p)
if props[p]['required'] else
'{:s}=Component.UNDEFINED'.format(p))
for p in prop_keys
if not p.endswith("-*") and
p not in ['dashEvents', 'fireEvent', 'setProps']]

Should change the endswith('-*') with endswith('*'), cause the dash_flow_example has data_*.

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 3, 2018

For the dangerously set inner html, we have to remove the , on this line:

default_argtext = "children=None, "

There is already a ',' before the kwargs at

def __init__(self, {default_argtext}, **kwargs):

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 3, 2018

I got this bit working:

    if 'children' in props:
        prop_keys.remove('children')
        default_argtext = "children=None "
        # pylint: disable=unused-variable
        argtext = 'children=children, **args'
    else:
        default_argtext = ""
        argtext = '**args'
    default_argtext = ", ".join([default_argtext] if default_argtext else [] +
        [('{:s}=Component.REQUIRED'.format(p)
          if props[p]['required'] else
          '{:s}=Component.UNDEFINED'.format(p))
         for p in prop_keys
         if p and not p.endswith("*") and
         p not in ['dashEvents', 'fireEvent', 'setProps']]
    )

But it's not pretty.

@rmarren1
Copy link
Contributor

rmarren1 commented Aug 7, 2018

I'll get a patch for this issue soon, it's looks to be breaking on the edge case where a component has no props.

@rmarren1 rmarren1 self-assigned this Aug 7, 2018
@rmarren1
Copy link
Contributor

rmarren1 commented Aug 7, 2018

I left some comments in #319, it looks to be a pre-existing issue that wasn't raised until 0.23.1

rmarren1 added a commit to rmarren1/dash that referenced this issue Aug 7, 2018
HammadTheOne pushed a commit to HammadTheOne/dash that referenced this issue May 28, 2021
HammadTheOne pushed a commit that referenced this issue Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants