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

revert #841 #919

Merged
merged 19 commits into from
Feb 21, 2023
Merged

revert #841 #919

merged 19 commits into from
Feb 21, 2023

Conversation

rmorshea
Copy link
Collaborator

@rmorshea rmorshea commented Feb 10, 2023

closes: #920

and reverts changes from #841 as per discussion in #916

but preserve ability to declare attributes with snake_case

Checklist

Please update this checklist as you complete each item:

  • Tests have been included for all bug fixes or added functionality.
  • The changelog.rst has been updated with any significant changes.
  • GitHub Issues which may be closed by this Pull Request have been linked.

src/idom/core/vdom.py Outdated Show resolved Hide resolved
scripts/fix_vdom_constructor_usage.py Show resolved Hide resolved
src/idom/core/vdom.py Outdated Show resolved Hide resolved
src/idom/html.py Outdated Show resolved Hide resolved
src/idom/utils.py Outdated Show resolved Hide resolved
tests/test_core/test_serve.py Outdated Show resolved Hide resolved
@rmorshea rmorshea force-pushed the revert-764a5a8c branch 8 times, most recently from 42eb96d to 1e64cf7 Compare February 13, 2023 00:29
@rmorshea rmorshea marked this pull request as ready for review February 13, 2023 00:45
@rmorshea
Copy link
Collaborator Author

@Archmonger I think we can go forward with the rename after this.

@@ -122,7 +122,7 @@ def Wrapper():
def PrintView():
text, set_text = idom.hooks.use_state(print_buffer.getvalue())
print_buffer.set_callback(set_text)
return idom.html.pre(text, class_name="printout") if text else idom.html.div()
return idom.html.pre({"class": "printout"}, text) if text else idom.html.div()
Copy link
Contributor

Choose a reason for hiding this comment

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

"class" needs a revert to "class_name". Also confirm throughout the docs we aren't missing any of those situations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
return idom.html.pre({"class": "printout"}, text) if text else idom.html.div()
return idom.html.pre({"class_name": "printout"}, text) if text else idom.html.div()

Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to still be unresolved?

docs/source/about/changelog.rst Show resolved Hide resolved
src/idom/_console/rewrite_key_declarations.py Outdated Show resolved Hide resolved
src/idom/core/hooks.py Show resolved Hide resolved
src/idom/core/hooks.py Show resolved Hide resolved
src/idom/html.py Outdated Show resolved Hide resolved
src/idom/html.py Show resolved Hide resolved
src/idom/utils.py Outdated Show resolved Hide resolved
tests/test_core/test_component.py Outdated Show resolved Hide resolved
- but preserve ability to declare attributes with snake_case
- move 'key' to be an attribute rather than keyword argument
  in constructor + make auto converter for this change based
  on the one used for the "new" `*args` and `**kwargs`
  syntax we are reverting.
@rmorshea
Copy link
Collaborator Author

I'd like to get this out, so I'm going to merge and do a pre-release

@rmorshea rmorshea merged commit f0ff025 into main Feb 21, 2023
@rmorshea rmorshea deleted the revert-764a5a8c branch February 21, 2023 08:58
@Archmonger
Copy link
Contributor

Archmonger commented Feb 21, 2023

I'll do a post-merge review tomorrow. If there's any issues we can handle it in a separate release.

src/idom/_console/rewrite_keys.py Show resolved Hide resolved
src/idom/_console/rewrite_camel_case_props.py Show resolved Hide resolved
@@ -122,7 +122,7 @@ def Wrapper():
def PrintView():
text, set_text = idom.hooks.use_state(print_buffer.getvalue())
print_buffer.set_callback(set_text)
return idom.html.pre(text, class_name="printout") if text else idom.html.div()
return idom.html.pre({"class": "printout"}, text) if text else idom.html.div()
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to still be unresolved?

@@ -30,6 +30,7 @@ def get_node_depth(node: Node) -> int:

def register_sections_as_label(app: Sphinx, document: Node) -> None:
docname = app.env.docname
print(docname)
Copy link
Contributor

@Archmonger Archmonger Feb 22, 2023

Choose a reason for hiding this comment

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

Unneeded print?

@@ -66,7 +67,7 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None:
domain.labels[name] = docname, labelid, sectname


def setup(app: Sphinx) -> dict[str, Any]:
def setup(app: Sphinx) -> Dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to use typing.Dict here.

{
"style": {
"position": "absolute",
"backgroundColor": "red",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we convert styles to snake_case?

@@ -15,9 +15,11 @@ def handle_reset(event):

return html.div(
html.button(
"Set Color", on_click=handle_click, style={"background_color": color}
{"on_click": handle_click, "style": {"backgroundColor": color}}, "Set Color"
Copy link
Contributor

Choose a reason for hiding this comment

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

Tons of backgroundColor references in the docs. We might want them to be background_color.

@@ -115,8 +115,8 @@ async def handle_event():
second_event_did_execute.set()

return idom.html.div(
idom.html.button(on_click=block_forever),
idom.html.button(on_click=handle_event),
idom.html.button({"onClick": block_forever}),
Copy link
Contributor

@Archmonger Archmonger Feb 22, 2023

Choose a reason for hiding this comment

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

onClick -> on_click
There's a few instances of unconverted values in the tests. This might indicate the conversion script isn't working in some edge cases.

html.label(
{},
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a handful of these empty dicts in this PR.

I recommend doing a search through this diff page for {}

@Archmonger
Copy link
Contributor

Archmonger commented Feb 23, 2023

Been testing this out in Conreq. I have a couple of comments

  1. Using custom_vdom_constructor on _ and script elements causes pylint errors

    • We should probably handle this through overloads and helper functions instead.
    • image
  2. On some of my idom.html elements, I was constructing the vdom dict using function calls (ex. generate_props(val_1, val_2)). The rewrite-keys script then would add another vdom dict above it, ultimately breaking things.

    • Should we update the script to run a type-check on the first arg of an idom.html call (and then combine them with the pipe | operator if needed)?
    • The following error probably needs more verbosity in order to better catch things like this:
  File "C:\Users\Markg\Documents\Repositories\Conreq\.venv\lib\site-packages\idom\core\layout.py", line 202, in _render_model
    new_state.model.current = {"tagName": raw_model["tagName"]}
KeyError: 'tagName'

@rmorshea
Copy link
Collaborator Author

Unfortunately I don't think there's a good great way handle that case you're experiencing. That first posarg could also be a child rather than a props dict. I think we can just produce a more helpful error.

@Archmonger
Copy link
Contributor

Archmonger commented Feb 23, 2023

Yeah no problem. To be honest it probably doesn't need the extra robustness, since as far as I can tell I'm the only one "stress testing" IDOM.

The error improvement would be a good addition though

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

Successfully merging this pull request may close these issues.

Change key API for idom.html and/or idom.component elements
2 participants