From 2a74694f04f8f1909c0cf81df205e582d56e70fa Mon Sep 17 00:00:00 2001 From: Chiang Fong Lee Date: Wed, 18 Oct 2017 00:54:19 +0800 Subject: [PATCH 1/3] Bulk fix of ant checkstyle in Bytes/ByteArray --- python/common/org/python/types/ByteArray.java | 6 +++--- python/common/org/python/types/Bytes.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python/common/org/python/types/ByteArray.java b/python/common/org/python/types/ByteArray.java index d18f1be38e..4cb0292817 100644 --- a/python/common/org/python/types/ByteArray.java +++ b/python/common/org/python/types/ByteArray.java @@ -725,9 +725,9 @@ public org.python.Object expandtabs(java.util.List args, java } @org.python.Method( - __doc__ = "B.find(sub[, start[, end]]) -> int"+ - "\n\nReturn the lowest index in B where subsection sub is found,"+ - "\nsuch that sub is contained within B[start,end]. Optional"+ + __doc__ = "B.find(sub[, start[, end]]) -> int" + + "\n\nReturn the lowest index in B where subsection sub is found," + + "\nsuch that sub is contained within B[start,end]. Optional" + "\narguments start and end are interpreted as in slice notation.\n\nReturn -1 on failure.", args = {"sub"}, default_args = {"start", "end"} diff --git a/python/common/org/python/types/Bytes.java b/python/common/org/python/types/Bytes.java index ad86e79fdd..d82d76f3a4 100644 --- a/python/common/org/python/types/Bytes.java +++ b/python/common/org/python/types/Bytes.java @@ -686,7 +686,7 @@ public org.python.Object center(org.python.Object width, org.python.Object byteT public static byte[] _center(byte[] input, org.python.Object width, org.python.Object byteToFill) { byte[] fillByte; if (byteToFill instanceof org.python.types.Bytes || byteToFill instanceof org.python.types.ByteArray) { - if(byteToFill instanceof org.python.types.ByteArray){ + if (byteToFill instanceof org.python.types.ByteArray) { fillByte = ((org.python.types.ByteArray) byteToFill).value; } else { fillByte = ((org.python.types.Bytes) byteToFill).value; @@ -910,8 +910,8 @@ public org.python.Object expandtabs(java.util.List args, java } @org.python.Method( - __doc__ = "B.find(sub[, start[, end]]) -> int"+ - "\n\nReturn the lowest index in B where substring sub is found,\nsuch that sub is contained within B[start:end]. Optional"+ + __doc__ = "B.find(sub[, start[, end]]) -> int" + + "\n\nReturn the lowest index in B where substring sub is found,\nsuch that sub is contained within B[start:end]. Optional" + "\narguments start and end are interpreted as in slice notation.\n\nReturn -1 on failure.", args = {"sub"}, default_args = {"start", "end"} @@ -926,7 +926,7 @@ public org.python.types.Int find(org.python.Object sub, org.python.Object start, _end = this.value.length; } byte[] _sub; - if(sub instanceof org.python.types.ByteArray){ + if (sub instanceof org.python.types.ByteArray) { _sub = ((org.python.types.ByteArray) sub).value; } else { _sub = ((org.python.types.Bytes) sub).value; @@ -1232,9 +1232,9 @@ public static byte[] _swapcase(byte[] input) { byte[] result = new byte[input.length]; for (int idx = 0; idx < input.length; ++idx) { char lc = (char) input[idx]; - if(Character.isUpperCase(lc)){ + if (Character.isUpperCase(lc)) { result[idx] = (byte) Character.toLowerCase(lc); - }else{ + } else { result[idx] = (byte) Character.toUpperCase(lc); } } From e51b7845d1374c55e175892cc0027176cfaa5b76 Mon Sep 17 00:00:00 2001 From: Chiang Fong Lee Date: Wed, 18 Oct 2017 00:55:33 +0800 Subject: [PATCH 2/3] Disable FileLength check in ant checkstyle config - It was erroring on Str.java because it was 2,374 lines, compared to the default max allowed of 2,000 lines. It doesn't seem productive to try and limit our not-organised-in-a-Java-way code that way. --- checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle.xml b/checkstyle.xml index 2be470696f..762a0bcaf3 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -55,7 +55,7 @@ - + From ee5036a86ee3208443a9d3118a45453b1af36d20 Mon Sep 17 00:00:00 2001 From: Chiang Fong Lee Date: Wed, 18 Oct 2017 00:56:17 +0800 Subject: [PATCH 3/3] Fix one missing line in ByteArray that causes a flake8 error --- tests/datatypes/test_bytearray.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/datatypes/test_bytearray.py b/tests/datatypes/test_bytearray.py index f49ff93913..7d935969f2 100644 --- a/tests/datatypes/test_bytearray.py +++ b/tests/datatypes/test_bytearray.py @@ -127,6 +127,7 @@ def test_lower(self): print(bytearray(b"hElLO wOrLd").lower()) print(bytearray(b"[Hello] World").lower()) """) + def test_count(self): self.assertCodeExecution(""" print(bytearray(b'abcabca').count(97))