Skip to content

Return self from DualMap.add_child - #2393

Open
shashank11yadav wants to merge 1 commit into
python-visualization:mainfrom
shashank11yadav:fix/dualmap-add-child-return-self
Open

shashank11yadav wants to merge 1 commit into
python-visualization:mainfrom
shashank11yadav:fix/dualmap-add-child-return-self

Conversation

@shashank11yadav

Copy link
Copy Markdown

DualMap.add_child returned None, so a chained call such as DualMap(...).add_child(a).add_child(b) could not work. This change adds return self at the end of DualMap.add_child in folium/plugins/dual_map.py, matching Marker.add_child.

The child is still added to m1 and stored for m2 as before. Only the return value changes.

A regression test, test_dual_map_add_child_returns_self in tests/plugins/test_dual_map.py, checks that add_child returns the map and that a chained call stores both children for the second map.

How it was tested (commit a2e7883):

  • The new test fails without the fix and passes with it.
  • The test suite, with the selenium, playwright and snapshot test folders left out and five tests deselected for environment reasons (network access, a browser driver, and a read-only cache directory): 429 passed.
  • ruff check: all checks passed.
  • black --check: 112 files unchanged.
  • codespell on folium and tests: no findings.
  • mypy folium: no issues found in 51 source files.
  • Not run: pre-commit run --all-files. The checks above are the closest equivalents I ran over the whole repo.

Fixes #2392

DualMap.add_child returned None, so calls could not be chained, unlike
add_child on other elements. Return self at the end, as Marker.add_child
does.

This branch has not been deployed

No deployments
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.

DualMap.add_child returns None, so chained add_child calls fail

1 participant