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

Improve test coverage for is_typeddict #104884

Merged
merged 2 commits into from
May 24, 2023
Merged

Conversation

JelleZijlstra
Copy link
Member

In particular, it's important to test that is_typeddict(TypedDict)
returns False.

In particular, it's important to test that is_typeddict(TypedDict)
returns False.
@bedevere-bot bedevere-bot added awaiting core review tests Tests in the Lib/test dir labels May 24, 2023
@JelleZijlstra JelleZijlstra changed the title Improve test coverage for TypedDict Improve test coverage for is_typeddict May 24, 2023
Comment on lines 7226 to 7227
assert is_typeddict(Point2D) is True
assert is_typeddict(Union[str, int]) is False
self.assertTrue(is_typeddict(Point2D))
self.assertFalse(is_typeddict(Union[str, int]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for using the unittest methods, but note that this isn't a direct translation. assertTrue only asserts that the thing is truthy, not that it actually is the True constant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point, I'll switch to assertIs(..., True).

self.assertIs(is_typeddict(BarGeneric[int]), False)
self.assertIs(is_typeddict(BarGeneric()), False)

class NewGeneric[T](TypedDict):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll manually remove this one from the 3.11 backport

@JelleZijlstra JelleZijlstra merged commit 1497607 into python:main May 24, 2023
@miss-islington
Copy link
Contributor

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@JelleZijlstra JelleZijlstra deleted the istdtests branch May 24, 2023 18:46
@miss-islington
Copy link
Contributor

Sorry @JelleZijlstra, I had trouble checking out the 3.12 backport branch.
Please retry by removing and re-adding the "needs backport to 3.12" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 1497607a8e99f1103c40368dd5f9057f0146a520 3.12

@bedevere-bot
Copy link

GH-104888 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 24, 2023
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 24, 2023
@JelleZijlstra JelleZijlstra added needs backport to 3.12 bug and security fixes and removed needs backport to 3.12 bug and security fixes labels May 24, 2023
@miss-islington
Copy link
Contributor

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-104889 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 24, 2023
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label May 24, 2023
@AlexWaygood
Copy link
Member

We should probably backport these to typing_extensions too

@JelleZijlstra
Copy link
Member Author

Maybe we should get Miss Islington to do that too :)

AlexWaygood pushed a commit that referenced this pull request May 24, 2023
Improve test coverage for is_typeddict (GH-104884)

In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
JelleZijlstra added a commit that referenced this pull request May 24, 2023
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@JelleZijlstra JelleZijlstra restored the istdtests branch September 10, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants