-
-
Notifications
You must be signed in to change notification settings - Fork 121
Make sure isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar)
is unaffected by sys.setprofile()
#407
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9cc0985
Make sure `isinstance(typing_extensions.ParamSpec("P"), typing.TypeVa…
AlexWaygood 211e953
debug
AlexWaygood 652df9c
try shell=True
AlexWaygood 4ebaa08
Revert "try shell=True"
AlexWaygood 4c3ac10
try passing all env vars
AlexWaygood 4c54e15
Revert "try passing all env vars"
AlexWaygood b1d7137
Does this fix things?
AlexWaygood 49cc06a
Does this fix things better?
AlexWaygood ae33db8
this?
AlexWaygood 03a2ade
debug
AlexWaygood 5311208
Revert "debug"
AlexWaygood 0327e20
Revert "this?"
AlexWaygood 729c942
Revert "Does this fix things better?"
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5020,6 +5020,48 @@ def test_eq(self): | |
# won't be the same. | ||
self.assertNotEqual(hash(ParamSpec('P')), hash(P)) | ||
|
||
def test_isinstance_results_unaffected_by_presence_of_tracing_function(self): | ||
# See https://github.com/python/typing_extensions/issues/318 | ||
|
||
code = textwrap.dedent( | ||
"""\ | ||
import sys, typing | ||
|
||
def trace_call(*args): | ||
return trace_call | ||
|
||
def run(): | ||
sys.modules.pop("typing_extensions", None) | ||
from typing_extensions import ParamSpec | ||
return isinstance(ParamSpec("P"), typing.TypeVar) | ||
|
||
isinstance_result_1 = run() | ||
sys.setprofile(trace_call) | ||
isinstance_result_2 = run() | ||
sys.stdout.write(f"{isinstance_result_1} {isinstance_result_2}") | ||
""" | ||
) | ||
|
||
# Run this in an isolated process or it pollutes the environment | ||
# and makes other tests fail: | ||
try: | ||
proc = subprocess.run( | ||
[sys.executable, "-c", code], check=True, capture_output=True, text=True, | ||
) | ||
except subprocess.CalledProcessError as exc: | ||
print("stdout", exc.stdout, sep="\n") | ||
print("stderr", exc.stderr, sep="\n") | ||
raise | ||
Comment on lines
+5047
to
+5054
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried running this in an isolated scope using |
||
|
||
# Sanity checks that assert the test is working as expected | ||
self.assertIsInstance(proc.stdout, str) | ||
result1, result2 = proc.stdout.split(" ") | ||
self.assertIn(result1, {"True", "False"}) | ||
self.assertIn(result2, {"True", "False"}) | ||
|
||
# The actual test: | ||
self.assertEqual(result1, result2) | ||
|
||
|
||
class ConcatenateTests(BaseTestCase): | ||
def test_basics(self): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to make this change or the subprocess wasn't able to
import typing_extensions
. It was raisingModuleNotFoundError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your change it uses the copy of
typing_extensions
in the repo instead of the installed one; that is incorrect. We shouldn't do this.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. Do you have any idea why the subprocess wasn't able to import
typing_extensions
prior to this change, but only for this CI job? I don't fully understand that (see https://github.com/python/typing_extensions/actions/runs/9197903212/job/25299411282?pr=407)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually, this might be fine, since in this job we're not attempting to test an installed version of typing_extensions. I'm not actually sure why this doesn't work in CI though. Possibly the test itself is picking up the wrong copy of
typing_extensions
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure how the pre-existing tests currently pass without this? I think it's correct? Otherwise we unpack the version of
typing_extensions
we want into ansrc/
directory, but nevercd
into thatsrc
directory, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what it looks like.