typing_extensions icon indicating copy to clipboard operation
typing_extensions copied to clipboard

Added support for Concatenate with Ellipsis

Open Daraan opened this issue 1 year ago • 1 comments

Fixes #110 for Python 3.9-3.10:

An Ellipsis cannot be used with Concatenate as last parameter must be a ParamSpec in Python 3.11 this is allowed, Python 3.10 does not support this.

Does not fix:

  • #48 : Using Ellipsis as argument for Callable with a generic..
    • <= 3.9: because of typing.Callable limitations
    • For 3.10 could go back to typing_extentions._ConcatenateGenericAlias but also tricky.
  • #110 for Python 3.8 as this is caused by typing.Callable as it does only accepts args that are types, i.e. Ellipsis is not supported.

Changes:

  • Changed _concatenate_getitem to reflect the Python3.11 typing module that allows the Ellipsis parameter.
  • For Python 3.10 uses typing._ConcatenateGenericAlias and an alternate _concatenate_getitem
  • For <=Python 3.9 the typing_extensions._ConcatenateGenericAlias and _concatenate_getitem like before
  • Added tests

Python Versions:

  • 3.8 not fixable, ok but skipped tests.
  • 3.9 ok
    • 3.9.0 ok (locally)
  • 3.10 ok
    • 3.10.0 ok (locally)
  • 3.11 ok - no backport. One new test for #48 that only runs on 3.11+

EDIT: Accounted for changes in Python. 3.9.2 and ~3.10.2, Tests for 3.*.0 should work now.

Daraan avatar Aug 08 '24 16:08 Daraan

All commit authors signed the Contributor License Agreement.
CLA signed

ghost avatar Aug 08 '24 16:08 ghost

I've made a rework (moved the parts to _create_concatenate_alias) that is now simpler and also works for Python 3.8 and fully solves #110 on the current version range.

Daraan avatar Oct 02 '24 09:10 Daraan

Looks like you might have closed this accidentally. Probably this is something to do with the fact that it was a PR from your fork's main branch. I think it's unfortunately impossible to repair PRs when they get to this state — do you want to recreate the PR using a different branch on your fork? :-)

AlexWaygood avatar Oct 05 '24 11:10 AlexWaygood

Thanks for your kind reply. Yep I've just butchered this 🙈, I am sorry. It's as you assume related to the fork from main ...

Daraan avatar Oct 05 '24 12:10 Daraan

We've all been there, pretty sure I've done it at least once :-)

AlexWaygood avatar Oct 05 '24 12:10 AlexWaygood