Skip to content

Conversation

@ocefpaf
Copy link
Member

@ocefpaf ocefpaf commented Jul 8, 2025

Should help with #2167

@ocefpaf
Copy link
Member Author

ocefpaf commented Jul 8, 2025

pre-commit.ci autofix

@ocefpaf
Copy link
Member Author

ocefpaf commented Jul 8, 2025

@hansthen I'd love your help with the mypy failure here.

@hansthen
Copy link
Collaborator

hansthen commented Jul 8, 2025

@hansthen I'd love your help with the mypy failure here.

The issue is upstream in Branca. The offending code returns Element._parent as Element but in Branca that is an object.

I was able to get rid of the error using this:

diff --git a/branca/element.py b/branca/element.py
index 1912aca..ad21bbf 100644
--- a/branca/element.py
+++ b/branca/element.py
@@ -55,7 +55,7 @@ class Element:
         self._name = "Element"
         self._id = hexlify(urandom(16)).decode()
         self._children = OrderedDict()
-        self._parent = None
+        self._parent: Element = None
         self._template_str = template
         self._template_name = template_name

However, Branca does not use much typing so far. Let me check if there is a better way.

(and removed unused typing info from function body)
@hansthen
Copy link
Collaborator

hansthen commented Jul 8, 2025

I could not get typing to work without either changing branca or adding # type: ignore line to the offending function.

@hansthen
Copy link
Collaborator

hansthen commented Jul 8, 2025

I think just disabling typing for this line here is okay. I also removed some unused typing info (in the body of an untyped function) because it triggered a warning.

@ocefpaf
Copy link
Member Author

ocefpaf commented Jul 8, 2025

Thanks! Please merge I'd you are happy with this PR.

@hansthen hansthen merged commit aa74da6 into python-visualization:main Jul 8, 2025
15 checks passed
@ocefpaf ocefpaf deleted the enforce_py39_min branch July 9, 2025 09:45
hansthen added a commit to hansthen/folium that referenced this pull request Nov 2, 2025
* enforce py39 min

* fix all lints

* Fix mypy error messages

(and removed unused typing info from function body)

---------

Co-authored-by: Hans Then <[email protected]>
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.

2 participants