Skip to content

Fix tests on 3.15#760

Merged
AlexWaygood merged 3 commits into
mainfrom
fix-issue-759
May 29, 2026
Merged

Fix tests on 3.15#760
AlexWaygood merged 3 commits into
mainfrom
fix-issue-759

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

Fixes #759

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 59.45946% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.21%. Comparing base (7ce55df) to head (d6217eb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/test_typing_extensions.py 59.45% 15 Missing ⚠️
@@            Coverage Diff             @@
##             main     #760      +/-   ##
==========================================
- Coverage   97.38%   97.21%   -0.18%     
==========================================
  Files           3        3              
  Lines        7773     7797      +24     
==========================================
+ Hits         7570     7580      +10     
- Misses        203      217      +14     
Flag Coverage Δ
3.10 88.94% <59.45%> (-0.15%) ⬇️
3.10.4 88.94% <59.45%> (-0.15%) ⬇️
3.11 88.18% <59.45%> (-0.15%) ⬇️
3.11.0 87.43% <59.45%> (-0.15%) ⬇️
3.12 88.13% <59.45%> (-0.15%) ⬇️
3.12.0 88.12% <59.45%> (-0.15%) ⬇️
3.13 82.92% <59.45%> (-0.13%) ⬇️
3.13.0 83.64% <59.45%> (-0.13%) ⬇️
3.14 79.02% <59.45%> (-0.12%) ⬇️
3.9 89.64% <59.45%> (-0.15%) ⬇️
3.9.12 89.64% <59.45%> (-0.15%) ⬇️
pypy3.10 88.77% <59.45%> (-0.15%) ⬇️
pypy3.11 88.04% <59.45%> (-0.15%) ⬇️
pypy3.9 89.48% <59.45%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/typing_extensions.py 93.92% <ø> (-0.01%) ⬇️
src/test_typing_extensions.py 98.18% <59.45%> (-0.23%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

self.assertIsInstance(self.sentinel_type.__doc__, str)

def test_constructor(self):
self.assertIs(self.sentinel_type, type(self.sentinel_type)())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

doesn't hold true on Python 3.15, and doesn't seem worth having a conditional test for

Comment on lines -9542 to -9544
from test import support
with support.swap_attr(builtins, "int", dict):
self.assertIs(evaluate_forward_ref(typing.ForwardRef("int")), dict)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

uv builds of Python don't have the test module available so this test failed for me locally

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just put Codex on fixing the same issue and it decided to do this instead:

@@ -9530,9 +9555,7 @@ class EvaluateForwardRefTests(BaseTestCase):
         )
         self.assertIs(evaluate_forward_ref(typing.ForwardRef("int"), globals={"int": str}), str)
         import builtins
-
-        from test import support
-        with support.swap_attr(builtins, "int", dict):
+        with patch.object(builtins, "int", dict):
             self.assertIs(evaluate_forward_ref(typing.ForwardRef("int")), dict)
 
     def test_nested_strings(self):

Seems simpler?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh that's nice, i forgot about patch.object

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made that change. I wonder what benefit there is to test.support.swap_attr in the CPython test suite over just using mock.patch.object...

Comment thread src/typing_extensions.py
Comment on lines -207 to -213
if repr is not None:
warnings.warn(
"The 'repr' parameter is deprecated "
"and will be removed in Python 3.15.",
DeprecationWarning,
stacklevel=2,
)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we added the repr back upstream so I removed the deprecation (python/cpython#149654). The deprecation only exists on main, not on the latest release of typing_extensions, so this doesn't warrant a changelog entry

Comment on lines +9685 to +9695
@skipUnless(TYPING_3_15_0, reason='Deprecated sentinel APIs are available before 3.15')
def test_sentinel_removed_deprecated_apis(self):
with self.assertRaises(TypeError):
class SentinelSubclass(Sentinel):
pass
with self.assertRaises(TypeError):
sentinel()
with self.assertRaises(TypeError):
Sentinel(name="my_sentinel")
with self.assertRaises(AttributeError):
sentinel('my_sentinel').foo = "bar"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

these all cause DeprecationWarnings in the typing_extensions backports but raise exceptions upstream on CPython. The deprecation warnings on Python <=3.14 are tested in the previous test immediately above this

@AlexWaygood AlexWaygood marked this pull request as ready for review May 29, 2026 13:42
Comment thread src/test_typing_extensions.py Outdated
@AlexWaygood AlexWaygood merged commit 404b33b into main May 29, 2026
22 checks passed
@AlexWaygood AlexWaygood deleted the fix-issue-759 branch May 29, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests fails on Python 3.15.0b1

2 participants