Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-125028: Prohibit placeholders in partial keywords#126062
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from13 commits
8b08ed5
bea722a
f346390
c7ee84b
e741a5c
71e65c3
294f189
5abc61e
656361b
da4214a
26dded8
e8d7521
106e6bc
5e151aa
38ff471
85955d6
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -233,6 +233,12 @@ def test_placeholders(self): | ||
actual_args, actual_kwds = p('x', 'y') | ||
self.assertEqual(actual_args, ('x', 0, 'y', 1)) | ||
self.assertEqual(actual_kwds, {}) | ||
# Checks via `is` and not `eq` | ||
# thus unittest.mock.ANY isn't treated as Placeholder | ||
dg-pb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
p = self.partial(capture, unittest.mock.ANY) | ||
actual_args, actual_kwds = p() | ||
self.assertEqual(actual_args, (unittest.mock.ANY,)) | ||
dg-pb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
self.assertEqual(actual_kwds, {}) | ||
def test_placeholders_optimization(self): | ||
PH = self.module.Placeholder | ||
@@ -249,6 +255,16 @@ def test_placeholders_optimization(self): | ||
self.assertEqual(p2.args, (PH, 0)) | ||
self.assertEqual(p2(1), ((1, 0), {})) | ||
def test_placeholders_kw_restriction(self): | ||
PH = self.module.Placeholder | ||
with self.assertRaisesRegex(TypeError, "Placeholder"): | ||
self.partial(capture, a=PH) | ||
dg-pb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# Passes, as checks via `is` and not `eq` | ||
p = self.partial(capture, a=unittest.mock.ANY) | ||
actual_args, actual_kwds = p() | ||
self.assertEqual(actual_args, ()) | ||
self.assertEqual(actual_kwds, {'a': unittest.mock.ANY}) | ||
dg-pb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
def test_construct_placeholder_singleton(self): | ||
PH = self.module.Placeholder | ||
tp = type(PH) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:data:`functools.Placeholder` cannot be passed to :func:`functools.partial` as a keyword argument. |
Uh oh!
There was an error while loading.Please reload this page.