Skip to content

Commit

Permalink
Merge pull request #584 from ababino/listify-bytes
Browse files Browse the repository at this point in the history
do not list bytes
  • Loading branch information
jph00 authored Jul 27, 2024
2 parents 63953af + a165d2b commit 5077372
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Welcome to fastcore
================
# Welcome to fastcore


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Expand All @@ -19,9 +19,9 @@ Anaconda, which we recommend) or `pip install fastcore`. For an
[editable
install](https://stackoverflow.com/questions/35064426/when-would-the-e-editable-option-be-useful-with-pip-install),
clone this repo and run: `pip install -e ".[dev]"`. fastcore is tested
to work on Ubuntu, macOS and Windows (versions tested are those show
to work on Ubuntu, macOS and Windows (versions tested are those shown
with the `-latest` suffix
[here](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources).
[here](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources)).

`fastcore` contains many features, including:

Expand Down
2 changes: 1 addition & 1 deletion fastcore/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def listify(o=None, *rest, use_list=False, match=None):
if use_list: res = list(o)
elif o is None: res = []
elif isinstance(o, list): res = o
elif isinstance(o, str) or is_array(o): res = [o]
elif isinstance(o, str) or isinstance(o, bytes) or is_array(o): res = [o]
elif is_iter(o): res = list(o)
else: res = [o]
if match is not None:
Expand Down
3 changes: 2 additions & 1 deletion nbs/01_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
" if use_list: res = list(o)\n",
" elif o is None: res = []\n",
" elif isinstance(o, list): res = o\n",
" elif isinstance(o, str) or is_array(o): res = [o]\n",
" elif isinstance(o, str) or isinstance(o, bytes) or is_array(o): res = [o]\n",
" elif is_iter(o): res = list(o)\n",
" else: res = [o]\n",
" if match is not None:\n",
Expand All @@ -296,6 +296,7 @@
"outputs": [],
"source": [
"test_eq(listify('hi'), ['hi'])\n",
"test_eq(listify(b'hi'), [b'hi'])\n",
"test_eq(listify(array(1)), [array(1)])\n",
"test_eq(listify(1), [1])\n",
"test_eq(listify([1,2]), [1,2])\n",
Expand Down

0 comments on commit 5077372

Please sign in to comment.