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

Add DivIcon as accepted type of Marker icon #2056

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pixelsapphire
Copy link

A DivIcon works when passed as the icon argument of Marker, but the argument is annotated as Optional[Icon] instead of Optional[Union[Icon, "DivIcon"]].

Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

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

Hi @pixelsapphire, thanks for your PR, that makes sense! Good to improve this.

It's missing an import of that class, can you maybe add that? It will lead to a circular import, so the way to address that is by only importing it for type checking:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from folium.features import DivIcon

One more thing: I assume this argument also accepts CustomIcon objects. Maybe you can add that as well?

Thanks for your help!

@pixelsapphire
Copy link
Author

It's missing an import of that class

My bad, should have checked that first.

I assume this argument also accepts CustomIcon objects. Maybe you can add that as well?

Done and dusted.

@hansthen
Copy link
Collaborator

@Conengmo Do you know what is the issue with the failing mypy checks? It seems mypy is bothered by some method signature redefinitions between Branca and Folium.

@pixelsapphire
Copy link
Author

@hansthen This is something I've been wondering about too. Why does the render method in Folium classes return None, when this method in Branca classes (as in the Element class itself) returns str?

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.

3 participants