Replies: 6 comments 15 replies
-
I think we could clean this up by renaming the @Conengmo what do you think? |
Beta Was this translation helpful? Give feedback.
-
Before diving into the technical side of this, I wanted to mention that we have to consider the downstream ecosystem. The most prominent example is streamlit-folium, that has hard-coded assumptions about the object tree structure: https://github.com/randyzwitch/streamlit-folium/blob/master/streamlit_folium/__init__.py#L431. Or FEMlium: https://github.com/FEMlium/FEMlium/blob/eca24f8b1123d2f60d34c5f30ef621fb508b3ddd/femlium/utils/geojson_with_arrows.py#L64. Or a plugin like folium-glify-layer: https://github.com/onaci/folium-glify-layer/blob/main/folium_glify_layer/__init__.py. Any changes we consider must take into account their impact on neighboring projects. We should then evaluate whether the potential improvements justify the challenges they might introduce for others. |
Beta Was this translation helpful? Give feedback.
-
How does rendering work? In this example we have:
When I say 'figure attributes' I mean the Full step description
Summary
|
Beta Was this translation helpful? Give feedback.
-
Can we somehow rename either But renaming things threatens backwards compatibility. As a first step we could make sure at least the methods don't conflict with each other: We could do:
That way we are backwards compatible since we are not renaming any methods. But it's clear that there are two different types of render methods. |
Beta Was this translation helpful? Give feedback.
-
Another possible simplification is to consolidate some of the logic in the
|
Beta Was this translation helpful? Give feedback.
-
That's true and not explicitly in the code! It should be! |
Beta Was this translation helpful? Give feedback.
-
Currently we have a mypy warning that we redefine the
render
method ofbranca.element
in several places in Folium. I have been trying to understand why this is for a few days now.The signature redefinition seems to start already in Branca. See
branca.element.Figure
for instance. The children are void rendered (without actually returning anything). Then the_template
ofFigure
is rendered. This will render just the header, html and script attributes and return the result.In branca.element.MacroElement, the children are also void rendered, but here the render method itself also has a void signature.
What it looks like is that as soon as we reach
Figure
andMacroElement
therender
method changes signature. All children of Figure need to beMacroElements
. Therender
method of aMacroElement
has a different purpose than that of anElement
.Element.render
will just generate the template of that element.MacroElement.render
performs structural manipulation. It adds template parts to theheader
,html
andscript
attributes.Beta Was this translation helpful? Give feedback.
All reactions