GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-43224: Add more tests for typevar substitution by mrahtz · Pull Request #31844 · python/cpython

Conversation

@mrahtz

@mrahtz mrahtz commented Mar 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Here are some more tests for the updated type variable substitution logic in #31800 (along with a fix for converting e.g. *tuple[int] into just int).

There are existing tests for some of this in e.g. TypeVarTests.test_var_substitution, but I think we can keep those tests as something more like integration tests (checking whether substitution is correct on actual aliases), regarding the tests in this PR as something closer to unit tests (testing only typing._determine_typevar_substitution).

One thing worth explaining: I've moved the place we call _check_generic so that we're doing all the checking for incorrect arity in one place (in _determine_typevar_substitution). This also makes testing easier - we can test for both correct and incorrect substitutions in TypeVarSubstitutionTests.

These aren't yet complete. In particular:

  • I haven't checked how this interacts with Annotated, which @JelleZijlstra thinks there could be some issues with.
  • These don't check for cases where an unpacked arbitrary-length tuple might have to be split between a TypeVar and a TypeVarTuple - e.g. substituting *tuple[int, ...] into T, *Ts and *Ts, T (since I've yet to confirm with @pradeep90 what should even happen in these cases)

Even so, I'll put this out there now so that @serhiy-storchaka has a reference of what we need to test for #31828.

https://bugs.python.org/issue43224

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mrahtz added 3 commits March 13, 2022 11:38
@mrahtz
Refactor typevar substitution into separate helper for easier testing
eb1a7ab
@mrahtz
Deal properly with e.g. *tuple[int]
f500d59
@mrahtz
Add more tests for typevar substitution
8611053
@mrahtz
mrahtz requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners March 13, 2022 11:50
@bedevere-bot bedevere-bot added the awaiting review label Mar 13, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 13, 2022
serhiy-storchaka
serhiy-storchaka approved these changes Mar 17, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Mar 17, 2022
@serhiy-storchaka

serhiy-storchaka commented Mar 17, 2022

Copy link
Copy Markdown
Member

I think that it would be better to add these tests in TypeVarTests.test_var_substitution and like, because it will be easy to make it testing the C code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrahtz

mrahtz commented Apr 5, 2022

Copy link
Copy Markdown
Contributor Author

(I'll close this PR because I'd forgotten it also makes some changes to typing.py. I'll make a new PR that's purely tests-only.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrahtz mrahtz closed this Apr 5, 2022
@mrahtz mrahtz mannequin mentioned this pull request Apr 11, 2022
Add support for PEP 646 #87390
Closed
@mrahtz
mrahtz deleted the typevartuple-subst-tests branch May 1, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra JelleZijlstra is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting merge

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@mrahtz @serhiy-storchaka @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.