Skip to content

Commit

Permalink
Flip --incompatible_restrict_named_params to true.
Browse files Browse the repository at this point in the history
RELNOTES: Make a number of parameters of Starlark builtin functions positional-only (as opposed to specifiable by keyword). See #8147 for details.
PiperOrigin-RevId: 265995993
  • Loading branch information
c-parsons authored and copybara-github committed Aug 28, 2019
1 parent c91fa30 commit 65ecfea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_restrict_named_params",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public static Builder builderWithDefaults() {
.incompatibleRemapMainRepo(false)
.incompatibleRemoveNativeMavenJar(false)
.incompatibleRunShellCommandString(false)
.incompatibleRestrictNamedParams(false)
.incompatibleRestrictNamedParams(true)
.incompatibleStringJoinRequiresStrings(true)
.internalSkylarkFlagTestCanary(false)
.incompatibleDoNotSplitLinkingCmdline(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1216,16 +1216,9 @@ public void testGetattrNoAttr() throws Exception {

@Test
public void testGetattr() throws Exception {
eval(
"s = struct(a='val')",
"x = getattr(s, 'a')",
"y = getattr(s, 'b', 'def')",
"z = getattr(s, 'b', default = 'def')",
"w = getattr(s, 'a', default='ignored')");
eval("s = struct(a='val')", "x = getattr(s, 'a')", "y = getattr(s, 'b', 'def')");
assertThat(lookup("x")).isEqualTo("val");
assertThat(lookup("y")).isEqualTo("def");
assertThat(lookup("z")).isEqualTo("def");
assertThat(lookup("w")).isEqualTo("val");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ public void testDictKeysDuplicateKeyArgs() throws Exception {
public void testArgBothPosKey() throws Exception {
newTest()
.testIfErrorContains(
"got multiple values for keyword argument 'old', for call to method "
+ "replace(old, new, maxsplit = None) of 'string'",
"'banana'.replace('a', 'o', 3, old='a')");
"got multiple values for keyword argument 'base', "
+ "for call to function int(x, base = unbound)",
"int('2', 3, base=3)");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public void testTupleCoercion() throws Exception {
// keyword, or may be None, even in places where it does not quite make sense.
@Test
public void testLegacyNamed() throws Exception {
new SkylarkTest()
new SkylarkTest("--incompatible_restrict_named_params=false")
// Parameters which may be specified by keyword but are not explicitly 'named'.
.testStatement("all(elements=[True, True])", Boolean.TRUE)
.testStatement("any(elements=[True, False])", Boolean.TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,31 +1103,27 @@ public void testProxyMethodsObject() throws Exception {

@Test
public void testLegacyNamed() throws Exception {
new SkylarkTest()
new SkylarkTest("--incompatible_restrict_named_params=false")
.update("mock", new Mock())
.setUp(
"b = mock.legacy_method(True, legacyNamed=True, named=True)")
.setUp("b = mock.legacy_method(True, legacyNamed=True, named=True)")
.testLookup("b", "legacy_method(true, true, true)");

new SkylarkTest()
new SkylarkTest("--incompatible_restrict_named_params=false")
.update("mock", new Mock())
.setUp(
"b = mock.legacy_method(True, True, named=True)")
.setUp("b = mock.legacy_method(True, True, named=True)")
.testLookup("b", "legacy_method(true, true, true)");

// Verify legacyNamed also works with proxy method objects.
new SkylarkTest()
new SkylarkTest("--incompatible_restrict_named_params=false")
.update("mock", new Mock())
.setUp(
"m = mock.proxy_methods_object()",
"b = m.legacy_method(True, legacyNamed=True, named=True)")
.testLookup("b", "legacy_method(true, true, true)");

new SkylarkTest()
new SkylarkTest("--incompatible_restrict_named_params=false")
.update("mock", new Mock())
.setUp(
"m = mock.proxy_methods_object()",
"b = m.legacy_method(True, True, named=True)")
.setUp("m = mock.proxy_methods_object()", "b = m.legacy_method(True, True, named=True)")
.testLookup("b", "legacy_method(true, true, true)");
}

Expand Down

0 comments on commit 65ecfea

Please sign in to comment.