New submission from Nikita Sobolev <m...@sobolevn.me>:
There are several important cases that are missing from current `repr()` tests of `typing.Union` and `typing.Optional`: 1. This condition is not covered at all: `if args[0] is type(None):` https://github.com/python/cpython/blob/7cf285d82ec722d4225297366013e924805171f2/Lib/typing.py#L1236 3. `repr()` of `Union[str, None]` is not directly tested as well 3. `repr()` of `Union` with more that 2 parameters with `None` is not covered. This is an important corner case because of this condition: `if len(args) == 2:` https://github.com/python/cpython/blob/7cf285d82ec722d4225297366013e924805171f2/Lib/typing.py#L1235 I will send a PR with new assertions. ---------- components: Tests messages: 411715 nosy: gvanrossum, kj, sobolevn priority: normal severity: normal status: open title: Improve test coverage of `Union` and `Optional` repr() type: behavior versions: Python 3.10, Python 3.11, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46529> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com