Skip to content

Commit 5fa73e2

Browse files
Merge pull request #1392 from cclauss:comprehensions
PiperOrigin-RevId: 836153778
2 parents 486ed5b + 5db7aca commit 5fa73e2

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ jobs:
5050
- name: Lint Python code
5151
run: |
5252
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
53-
ruff check
53+
ruff check --extend-select=C4,C90,PERF,RET,SIM,W
5454
5555
# TODO(eustas): run buildifier

scripts/dictionary/step-02-rfc-to-bin.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
if appendix_a_found:
1919
if re_data_line.match(line) is not None:
2020
data = line.strip()
21-
for i in range(32):
22-
dictionary.append(int(data[2 * i:2 * i + 2], 16))
21+
dictionary.extend(int(data[2 * i:2 * i + 2], 16) for i in range(32))
2322
if len(dictionary) == 122784:
2423
break
25-
else:
26-
if line.startswith("Appendix A."):
27-
appendix_a_found = True
24+
elif line.startswith("Appendix A."):
25+
appendix_a_found = True
2826

2927
bin_path = "dictionary.bin"
3028

scripts/dictionary/step-04-generate-java-literals.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
is_skip = False
4141
hi.append(unichr(cntr))
4242
cntr = skip_flip_offset + 1
43+
elif value >= 0x80:
44+
cntr += 1
4345
else:
44-
if value >= 0x80:
45-
cntr += 1
46-
else:
47-
is_skip = True
48-
hi.append(unichr(cntr))
49-
cntr = skip_flip_offset + 1
46+
is_skip = True
47+
hi.append(unichr(cntr))
48+
cntr = skip_flip_offset + 1
5049
hi.append(unichr(cntr))
5150

5251
low0 = low[0:len(low) // 2]
@@ -56,15 +55,15 @@
5655
def escape(chars):
5756
result = []
5857
for c in chars:
59-
if "\r" == c:
58+
if c == "\r":
6059
result.append("\\r")
61-
elif "\n" == c:
60+
elif c == "\n":
6261
result.append("\\n")
63-
elif "\t" == c:
62+
elif c == "\t":
6463
result.append("\\t")
65-
elif "\"" == c:
64+
elif c == "\"":
6665
result.append("\\\"")
67-
elif "\\" == c:
66+
elif c == "\\":
6867
result.append("\\\\")
6968
elif ord(c) < 32 or ord(c) >= 127:
7069
result.append("\\u%04X" % ord(c))

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def get_version():
5353

5454
def get_test_suite():
5555
test_loader = unittest.TestLoader()
56-
test_suite = test_loader.discover("python", pattern="*_test.py")
57-
return test_suite
56+
return test_loader.discover("python", pattern="*_test.py")
5857

5958

6059
class BuildExt(build_ext):
@@ -77,13 +76,9 @@ def build_extension(self, ext):
7776
if not (self.force or dep_util.newer_group(depends, ext_path, "newer")):
7877
log.debug("skipping '%s' extension (up-to-date)", ext.name)
7978
return
80-
else:
81-
log.info("building '%s' extension", ext.name)
79+
log.info("building '%s' extension", ext.name)
8280

83-
c_sources = []
84-
for source in ext.sources:
85-
if source.endswith(".c"):
86-
c_sources.append(source)
81+
c_sources = [source for source in ext.sources if source.endswith(".c")]
8782
extra_args = ext.extra_compile_args or []
8883

8984
objects = []
@@ -184,7 +179,7 @@ def build_extension(self, ext):
184179

185180
if USE_SYSTEM_BROTLI:
186181
import pkgconfig
187-
182+
188183
REQUIRED_BROTLI_SYSTEM_LIBRARIES = ["libbrotlicommon", "libbrotlienc", "libbrotlidec"]
189184

190185
define_macros = []

0 commit comments

Comments
 (0)