You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2023/08/16 18:38:49 UTC

[GitHub] [superset] betodealmeida commented on a diff in pull request #24994: chore: rename `get_iterable`

betodealmeida commented on code in PR #24994:
URL: https://github.com/apache/superset/pull/24994#discussion_r1296295061


##########
superset/utils/core.py:
##########
@@ -1578,12 +1578,15 @@ def split(
     yield string[i:]
 
 
-def get_iterable(x: Any) -> list[Any]:
+T = TypeVar("T")
+
+
+def get_as_list(x: T | list[T]) -> list[T]:

Review Comment:
   @john-bodley `as_iterable` is super confusing, because there are many things that are already iterable but will still be modified by this function, eg:
   
   ```python
   >>> from typing import Any
   >>> def is_iterable(foo: Any) -> bool:
   ...     try:
   ...         iter(foo)
   ...     except Exception:
   ...         return False
   ...     return True
   ...
   >>>
   >>> a = (1,2,3)
   >>> is_iterable(a)
   True
   >>> as_iterable(a)
   [(1, 2, 3)]
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org