[New-bugs-announce] [issue46396] Invalid usage of `Concatenate` is not covered at all

Nikita Sobolev report at bugs.python.org
Sun Jan 16 03:38:58 EST 2022

New submission from Nikita Sobolev <mail at sobolevn.me>:

Right now if I remove these lines:

    if parameters == ():
        raise TypeError("Cannot take a Concatenate of no types.")
    if not isinstance(parameters, tuple):
        parameters = (parameters,)
    if not isinstance(parameters[-1], ParamSpec):
        raise TypeError("The last parameter to Concatenate should be a "
                        "ParamSpec variable.")

from here: https://github.com/python/cpython/blob/09087b8519316608b85131ee7455b664c00c38d2/Lib/typing.py#L601-L607

And run the test suite - it passes.

To increase coverage I plan to:
1. Add a test for empty `Concatenate[]`
2. Add a test case when `ParamSpec` is not the last item of `Concatenate`
3. When passed parameter to `Concatenate` is not `tuple`

PR is on its way :)

components: Tests
messages: 410682
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Invalid usage of `Concatenate` is not covered at all
type: behavior
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list