Support 'oxford comma' format and non-string types in listing#690
Support 'oxford comma' format and non-string types in listing#690staticdev merged 8 commits intostaticdev:mainfrom
Conversation
|
@staticdev The test case for coverage for listing fail before because |
src/human_readable/lists.py
Outdated
| from typing import TYPE_CHECKING | ||
|
|
||
|
|
||
| if TYPE_CHECKING: |
There was a problem hiding this comment.
I guess it is much simpler to just remove this if statement and always import this. It is the standard approach.
| assert lists.listing(*params) == expected | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
Would also be great to explain this in our examples documentation.
@zwimer I did a review, and I have a suggestion to deal with this in a simpler way. |
Fixes: #693
This PR:
listing. Depending on location etc., some people list items using an oxford comma. For example:Prints out
The default is
oxford=Falseto avoid changing the default behavior.strinlisting. The code for this function almost entirely already allowed this, this PR mostly changes type annotations and adds a couple ofstr()calls to fully support it. This allows for things like:Which may print:
items. Python defineslisttype as invariant; we should useSequenceinstead as that is covariant. That is: