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

Spec generation gives error for Sentinel #2743

Closed
vidartf opened this issue Jan 17, 2020 · 8 comments
Closed

Spec generation gives error for Sentinel #2743

vidartf opened this issue Jan 17, 2020 · 8 comments
Assignees
Milestone

Comments

@vidartf
Copy link
Member

vidartf commented Jan 17, 2020

running the generate spec command, I get

C:\dev\ipywidgets [datetime ↑1]> python ./packages/schema/generate-spec.py -f json-pretty > packages/schema/jupyterwidgetmodels.latest.json
Traceback (most recent call last):
  File "./packages/schema/generate-spec.py", line 208, in <module>
    indent=2, separators=(',', ': ')))
  File "C:\Miniconda3\lib\json\__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "C:\Miniconda3\lib\json\encoder.py", line 201, in encode
    chunks = list(chunks)
  File "C:\Miniconda3\lib\json\encoder.py", line 429, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "C:\Miniconda3\lib\json\encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "C:\Miniconda3\lib\json\encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "C:\Miniconda3\lib\json\encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "C:\Miniconda3\lib\json\encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "C:\Miniconda3\lib\json\encoder.py", line 438, in _iterencode
    o = _default(o)
  File "C:\Miniconda3\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Sentinel is not JSON serializable
@vidartf
Copy link
Member Author

vidartf commented Jan 17, 2020

Note this is on my branch for #2715, not on master

@vidartf
Copy link
Member Author

vidartf commented Jan 17, 2020

After some debugging, it seems the generation code struggles to find the default value for this specification:

Union((CInt(1), Enum("any")))

It thinks it is Undefined, instead of the actual value of 1.

@vidartf
Copy link
Member Author

vidartf commented Jan 17, 2020

There were some other issues as well with unions, fix proposed in #2715.

@jasongrout jasongrout added this to the 8.0 milestone Feb 11, 2020
@jasongrout
Copy link
Member

There were some other issues as well with unions, fix proposed in #2715.

Setting as 8.0, then.

@marimeireles
Copy link
Member

hey @vidartf, I was trying to have a look at this, but I can't reproduce your error...
Building ipywidgets with the #2715 PR leads to the following error for me:

(ipywidgets) mariana@wintermute ~/development/ipywidgets (datetime) $ python ./packages/schema/generate-spec.py -f json-pretty > packages/schema/jupyterwidgetmodels.latest.json
Traceback (most recent call last):
  File "/home/mariana/development/ipywidgets/./packages/schema/generate-spec.py", line 232, in <module>
    spec = create_spec(widgets_to_document)
  File "/home/mariana/development/ipywidgets/./packages/schema/generate-spec.py", line 213, in create_spec
    widget_data.append(jsonify(widget_name, widget, widget_list))
  File "/home/mariana/development/ipywidgets/./packages/schema/generate-spec.py", line 193, in jsonify
    default=jsdefault(trait)
  File "/home/mariana/development/ipywidgets/./packages/schema/generate-spec.py", line 116, in jsdefault
    default = trait.make_dynamic_default()
AttributeError: 'Union' object has no attribute 'make_dynamic_default'

@vidartf
Copy link
Member Author

vidartf commented Feb 19, 2021

@marimeireles I think that code was changed with traitlets 5, good catch.

@marimeireles
Copy link
Member

Is the issue still valid @vidartf ?

@vidartf
Copy link
Member Author

vidartf commented Jul 6, 2021

Closed in #2715.

@vidartf vidartf closed this as completed Jul 6, 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

3 participants