diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 25d832f..e23e054 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -50,6 +50,6 @@ jobs: - name: Lint Python code run: | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - ruff check + ruff check --extend-select=C4,C90,PERF,RET,SIM,W # TODO(eustas): run buildifier diff --git a/scripts/dictionary/step-02-rfc-to-bin.py b/scripts/dictionary/step-02-rfc-to-bin.py index ddf255a..3039e27 100644 --- a/scripts/dictionary/step-02-rfc-to-bin.py +++ b/scripts/dictionary/step-02-rfc-to-bin.py @@ -18,13 +18,11 @@ for line in lines: if appendix_a_found: if re_data_line.match(line) is not None: data = line.strip() - for i in range(32): - dictionary.append(int(data[2 * i:2 * i + 2], 16)) + dictionary.extend(int(data[2 * i:2 * i + 2], 16) for i in range(32)) if len(dictionary) == 122784: break - else: - if line.startswith("Appendix A."): - appendix_a_found = True + elif line.startswith("Appendix A."): + appendix_a_found = True bin_path = "dictionary.bin" diff --git a/scripts/dictionary/step-04-generate-java-literals.py b/scripts/dictionary/step-04-generate-java-literals.py index d864542..c0926ab 100644 --- a/scripts/dictionary/step-04-generate-java-literals.py +++ b/scripts/dictionary/step-04-generate-java-literals.py @@ -40,13 +40,12 @@ for b in data: is_skip = False hi.append(unichr(cntr)) cntr = skip_flip_offset + 1 + elif value >= 0x80: + cntr += 1 else: - if value >= 0x80: - cntr += 1 - else: - is_skip = True - hi.append(unichr(cntr)) - cntr = skip_flip_offset + 1 + is_skip = True + hi.append(unichr(cntr)) + cntr = skip_flip_offset + 1 hi.append(unichr(cntr)) low0 = low[0:len(low) // 2] @@ -56,15 +55,15 @@ low1 = low[len(low) // 2:len(low)] def escape(chars): result = [] for c in chars: - if "\r" == c: + if c == "\r": result.append("\\r") - elif "\n" == c: + elif c == "\n": result.append("\\n") - elif "\t" == c: + elif c == "\t": result.append("\\t") - elif "\"" == c: + elif c == "\"": result.append("\\\"") - elif "\\" == c: + elif c == "\\": result.append("\\\\") elif ord(c) < 32 or ord(c) >= 127: result.append("\\u%04X" % ord(c)) diff --git a/setup.py b/setup.py index 60cee8a..34017cf 100644 --- a/setup.py +++ b/setup.py @@ -53,8 +53,7 @@ def get_version(): def get_test_suite(): test_loader = unittest.TestLoader() - test_suite = test_loader.discover("python", pattern="*_test.py") - return test_suite + return test_loader.discover("python", pattern="*_test.py") class BuildExt(build_ext): @@ -77,13 +76,9 @@ class BuildExt(build_ext): if not (self.force or dep_util.newer_group(depends, ext_path, "newer")): log.debug("skipping '%s' extension (up-to-date)", ext.name) return - else: - log.info("building '%s' extension", ext.name) + log.info("building '%s' extension", ext.name) - c_sources = [] - for source in ext.sources: - if source.endswith(".c"): - c_sources.append(source) + c_sources = [source for source in ext.sources if source.endswith(".c")] extra_args = ext.extra_compile_args or [] objects = [] @@ -184,7 +179,7 @@ USE_SYSTEM_BROTLI = bool_from_environ("USE_SYSTEM_BROTLI") if USE_SYSTEM_BROTLI: import pkgconfig - + REQUIRED_BROTLI_SYSTEM_LIBRARIES = ["libbrotlicommon", "libbrotlienc", "libbrotlidec"] define_macros = []