Add allow_sets-kwarg to is_list_like
State: closed

- [x] closes ~~#23009~~ #23061 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

This is an attempt responding to https://github.com/pandas-dev/pandas/pull/22486#issuecomment-428159769:
> @h-vetinari why don't you try (separate PR) excluding set from is_list_like and see what the implications of that are.

Following some initial discussion in #23061, I decided to go with a variant that does not break anything - i.e. adding a keyword which defaults to the current behaviour. I've added a warning that's only raised if necessary, to note that this behaviour will be changed in the future -- regardless of whether it is deprecated or not, I think that users *as well as developers* should have to actively choose to include unordered sets (reason i.a. for #23009, and probably some more).

The tedious part of this PR was hunting down all the internal uses of `is_list_like` and adding the kwarg there to avoid raising the warning. Hope I didn't miss any.


Labels:
name: Enhancement
name: API Design

Comments:
as i believe tom commented this is not likely to be worth changing
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=h1) Report
> Merging [#23065](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1546c35dc839b3f6c094ad41d14cda24e9e13a0c?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `75%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23065/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23065      +/-   ##
==========================================
- Coverage   92.19%   92.18%   -0.01%     
==========================================
  Files         169      169              
  Lines       50954    50956       +2     
==========================================
+ Hits        46975    46976       +1     
- Misses       3979     3980       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <75%> (-0.01%)` | :arrow_down: |
| #single | `42.27% <75%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/23065/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `95.11% <ø> (ø)` | :arrow_up: |
| [pandas/core/dtypes/inference.py](https://codecov.io/gh/pandas-dev/pandas/pull/23065/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2luZmVyZW5jZS5weQ==) | `98.38% <100%> (ø)` | :arrow_up: |
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/23065/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `58.36% <50%> (-0.07%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=footer). Last update [1546c35...ab3ce96](https://codecov.io/gh/pandas-dev/pandas/pull/23065?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

> as i believe tom commented this is not likely to be worth changing

As I believe Tom commented that this is not worth *breaking*, but this is not a breaking change.
@h-vetinari it's maybe not breaking, but you still plan to change the default behaviour (the warning). 
Why not only adding the keyword with a default for the current behaviour, and then you can specifically use it there where it is needed to exclude sets. 
Then the diff here would be much smaller, and then we can limit the discussion to whether it is worth adding the keyword vs explicitly checking for sets in those few cases.
@jorisvandenbossche 
Obviously one could add it with the current default - that's easily done. But why not discuss as well if fixing an ambiguous bit of API is worth it?
> Since `list` is ordered in python, the name `is_list_like` suggests the same property. If that's not the case it's good ("explicit is better than implicit") to have to specify it.
@h-vetinari my point in bringing this up would be to see if this is worth it
it is not, given the amount of confusion this would cause
adding a keyword, while solving the backwards compat problem just adds an api that i don’t think we would want at all; no other is_* have any keywords like this (infer_dtype has one but that is a bit different)

this was a good experiment - maybe i wasn’t clear - trying means reporting what happened, then we have a discussion about it
Summarizing how I see things:

1. `is_list_like` is a fundamentally fuzzy concept. It can't do the right thing in every case.
2. The caller knows more about exactly what they need (just iterable?, ordered?, etc.)

So we can either do things like

```python
if is_list_like(x) and not is_unodered(x):
   ...
```

or do things like

```python
if is_list_like(x, require_ordered=True):
    pass
```

Between those to, the keyword to `is_list_like` seems fine.

I don't think changing the default behavior of considering sets as list-like is worth it.
@jreback @TomAugspurger 

OK, not changing the default. I see two options:
* Add kwarg (either `require_ordered`, `strict` etc.) - no strong preference about the name, but shorter is better IMO.
* Add separate method `is_ordered_list_like` (suggestion by @jschendel) in #23061 
i think is_ordered_list_like is nicer here (but just make it internal for now, don’t add to api.types)
Hello @h-vetinari! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/compat/__init__.py`](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/compat/__init__.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/common.py`](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/core/dtypes/common.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/inference.py`](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/core/dtypes/inference.py) !

 - In the file [`pandas/tests/dtypes/test_inference.py`](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py), following                are the PEP8 issues :
> [Line 53:10](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L53): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 53:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L53): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 54:9](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L54): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 54:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L54): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 55:12](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L55): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 55:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L55): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 56:14](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L56): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 56:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L56): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 57:15](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L57): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 57:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L57): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 58:13](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L58): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 58:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L58): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 59:15](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L59): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 60:12](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L60): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 61:26](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L61): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 62:20](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L62): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 63:19](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L63): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 63:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L63): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 64:15](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L64): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 64:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L64): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 65:26](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L65): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 65:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L65): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 66:22](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L66): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 66:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L66): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 67:18](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L67): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 67:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L67): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 68:17](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L68): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 68:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L68): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 69:24](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L69): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 69:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L69): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 70:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L70): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 71:17](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L71): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 71:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L71): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 72:16](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L72): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 72:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L72): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 73:23](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L73): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 73:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L73): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 74:18](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L74): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 74:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L74): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 75:27](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L75): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 75:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L75): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 76:19](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L76): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 76:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L76): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 77:27](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L77): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 77:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L77): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 78:21](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L78): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 78:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L78): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 79:27](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L79): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 79:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L79): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 80:23](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L80): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 80:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L80): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 81:27](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L81): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 81:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L81): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 82:25](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L82): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 82:38](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L82): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 83:18](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L83): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 84:8](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L84): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 85:13](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L85): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 86:10](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L86): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 87:12](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L87): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 88:9](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L88): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 89:10](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L89): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 90:15](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L90): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 91:13](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L91): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 92:11](https://github.com/h-vetinari/pandas/blob/2f5e927bdaea3e0abb2d06c4cbbbc806fffade24/pandas/tests/dtypes/test_inference.py#L92): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','




##### Comment last updated on October 17, 2018 at 16:18 Hours UTC
@h-vetinari is there an actual use case of the checking for ordered dict / dict below 3.6 ? Or just to want to be strict in the checking for orderedness?
Because it also seems very strange to me to handle dicts differently depending on the python version within such a function.

@jorisvandenbossche 

Well, that's what CPython *does*. I thought I'd be thorough about the orderedness thing, but I don't care about the `dicts` here so much.
Then please remove it. If we don't have a use case, there is no point in trying to be strict for the sake of being it, IMO
Another thing, I am personally not sure we should use the term "unordered", instead of just being explicit that it is about Sets (because you can eg still sort a set, or convert it to an orderable list, etc. And what if there then comes up another unordered data structure?)

In that sense, I would find a `is_list_like(..., include_sets=False)` clearer and more explicit. 
@jorisvandenbossche 

Alright, removing dict.

Can you agree with @jreback and @TomAugspurger on whether it's
* `is_ordered_list_like`
* with a kwarg:
  * `require_ordered`
  * `include_sets`
  * `strict`
  * ...

I don't care about which way, but prefer shorter to read/type
Since there are 2/3 devs voting for a kwarg, I went back to that after all. I briefly thought about `ordered_only`, but decided that `strict` is nice and short and actually reads well with the function name: "is this list-like (if one is strict)?"
> I can't magically make you agree amongst each other,

Yes, you cannot, and I understand that that can be annoying, but please be a bit patient and wait with updating again before we have the time to discuss this. With different timezones, different times of the day we look at this, delayed communication on github etc, there is often no way to discuss something in a day, let alone a few hours. That's reality of open source.
@jorisvandenbossche 
I'm not in a hurry. The commits are there to revert to `is_ordered_list_like` if desired, but since the preferences were leaning towards kwarg I decided to cover that base as well.
I am snookered between the following three options and contradictory positions:
1. `is_list_like(some_kwarg=False)` - @jreback doesn't want a keyword
1. `is_ordered_list_like` - @jorisvandenbossche & @TomAugspurger  prefer keywords
1. close this PR and use additional `isinstance(x, set)` checks where necessary - opposed by @jreback in #22486 (and the reason for this PR).

I'm fine with any one choice (with my preferences in the order of the points above) - can you please help reach a conclusion here?
@jreback @TomAugspurger @jorisvandenbossche 
> I'm fine with any one choice (with my preferences in the order of the points [above](https://github.com/pandas-dev/pandas/pull/23065#issuecomment-429482883)) - can you please help reach a conclusion here?
Going back to `is_ordered_list_like` - maybe that will get things moving again. ;-)
Quoting @jreback from a bit above:

> otherwise would just drop this and use isinstance checks for sets in a few places if necessary.

So certainly don't let this discussion block the other PR https://github.com/pandas-dev/pandas/pull/22486

Personally I am rather -1 on adding something like `is_ordered_list_like`. "list_like" is already a vague messy concept, "ordered list_like" does not make it better IMO. 
If we do something, as I said above, I would rather go for a very specific keyword (so not something like "strict", rather something like "allow_sets"). But if that is only used a couple of times throughout the code base, maybe the status quo and doing an explicit isinstance check in those occasions, is also a perfect option.

@jreback @TomAugspurger any additional thoughts on this?
@jorisvandenbossche 
Thanks for the response. Happy to move forward on #22486  in whatever form. I opened #23187 to a) split it off of this PR and b) illustrate how a case using the "no action" route would look like.

I still prefer the `is_list_like(obj, kwarg=False)` solution the best, I dislike the status quo plus adding instance-checks for `set` (applies partly to `is_ordered_list_like` as well), because it keeps the same trap open I fell into with #20347 (and almost #22486) - `is_list_like` IMO makes it easy to overlook that it includes sets as well, and someone might end up using it in cases where orderedness is essential (hence the original drive of this PR to change the default with a deprecation cycle).)
Agreed with @jorisvandenbossche that

- very specific keyword (so not something like "strict", rather something like "allow_sets").
- maybe the status quo and doing an explicit isinstance check in those occasions, is also a perfect option

I don't have a preference between adding a kwarg to `is_list_like` vs. doing those checks independently.
@jreback:
could you live with `is_list_like(obj, allow_sets=True)`? @jorisvandenbossche @TomAugspurger (and myself) would prefer this over `is_ordered_list_like`.

Adding `isinstance(x, set)` also would work (though, as @jschendel notes, wouldn't catch `frozenset` etc.), but is IMO the least preferable solution out of the three, not least re:explicitness (see [my comment](https://github.com/pandas-dev/pandas/pull/23065#issuecomment-430365851)). The current state of #22486 and #23187 follows this last example, so can check it out there "in real life".
i think allow_sets as a kwarg is ok (default is True)
Thanks for the responses / inputs everyone. Changed back to kwarg, renamed it to `allow_sets`.
OK, hoping this last commit is more what you guys were after.

I decided to add the  `ids` to have nice output (in error logs, resp. with `- v`):
```

pandas/tests/dtypes/test_inference.py::test_is_list_like[list] PASSED    [  0%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[list-empty] PASSED [  0%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[tuple] PASSED   [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[tuple-empty] PASSED [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[dict] PASSED    [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[dict-empty] PASSED [  2%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[set] PASSED     [  2%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[set-empty] PASSED [  2%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[frozenset] PASSED [  3%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[frozenset-empty] PASSED [  3%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[iterator] PASSED [  3%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[iterator-empty] PASSED [  4%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[generator] PASSED [  4%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[generator-empty] PASSED [  4%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[Series] PASSED  [  5%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[Series-empty] PASSED [  5%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[StringMethods] PASSED [  5%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[StringMethods-empty] PASSED [  6%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[Index] PASSED   [  6%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[Index-empty] PASSED [  6%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[DataFrame] PASSED [  7%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[DataFrame-empty] PASSED [  7%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-1d] PASSED [  8%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-1d-empty] PASSED [  8%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-2d] PASSED [  8%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-2d-empty] PASSED [  9%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-3d] PASSED [  9%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-3d-empty] PASSED [  9%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-4d] PASSED [ 10%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-4d-empty] PASSED [ 10%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[ndarray-0d] PASSED [ 10%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[int] PASSED     [ 11%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[bytes] PASSED   [ 11%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[bytes-empty] PASSED [ 11%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[string] PASSED  [ 12%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[string-empty] PASSED [ 12%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[string-type] PASSED [ 12%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[object] PASSED  [ 13%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[NaN] PASSED     [ 13%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[None] PASSED    [ 13%]
[...]
```
instead of 
```
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like0] PASSED [  0%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like1] PASSED [  0%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like2] PASSED [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like3] PASSED [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like4] PASSED [  1%]
pandas/tests/dtypes/test_inference.py::test_is_list_like[maybe_list_like5] PASSED [  2%]
[etc...]
```

Of course it would be possible to have separate lists for the list-likes, the expected value, and the ids, but then its really instable that all three need to be edited simultaneously in case there's any change. That's why I opted for defining everything as tuples, and then doing some `zip`-ping
thanks @h-vetinari