Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-106246: Allow the use of unions as match patterns #118644

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

randolf-scholz
Copy link
Contributor

@randolf-scholz randolf-scholz commented May 6, 2024

Fixes #106246

Modified version of #118525 that supports using subpatterns in unions.

added tests:

  1. test_patma_union_type
  2. test_patma_union_no_match
  3. test_union_type_positional_subpattern
  4. test_union_type_keyword_subpattern
  5. test_patma_union_arg
  6. test_patma_union_kwarg
  7. test_patma_union_arg_no_match
  8. test_patma_union_kwarg_no_match
  9. test_union_type_match_second_member
  10. test_generic_type
  11. test_legacy_generic_type
  12. test_class_or_union_not_specialform
  13. test_legacy_union_type
  14. test_expanded_union_mirrors_isinstance_success
  15. test_expanded_union_mirrors_isinstance_failure
  16. test_union_type_mirrors_isinstance_success
  17. test_union_type_mirrors_isinstance_failure
  18. test_generic_union_type

@tmke8
Copy link
Contributor

tmke8 commented May 6, 2024

Thanks for working on this!

Lib/test/test_patma.py Outdated Show resolved Hide resolved
Lib/test/test_patma.py Show resolved Hide resolved
@sobolevn
Copy link
Member

sobolevn commented May 8, 2024

Too late for 3.13 :(
This will go into 3.14

@gvanrossum
Copy link
Member

While you have some time, I recommend adding some great docs for the new feature as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[match-case] Allow matching Union types
5 participants