Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update ruff and add lint-py-fix #54410

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1536,17 +1536,22 @@ cpplint: lint-cpp
# Try with '--system' if it fails without; the system may have set '--user'
lint-py-build:
$(info Pip installing ruff on $(shell $(PYTHON) --version)...)
$(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff==0.5.2 || \
$(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff==0.5.2
$(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff==0.6.5 || \
$(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff==0.6.5

.PHONY: lint-py
.PHONY: lint-py lint-py-fix lint-py-fix-unsafe
ifneq ("","$(wildcard tools/pip/site-packages/ruff)")
# Lint the Python code with ruff.
lint-py:
tools/pip/site-packages/bin/ruff --version
tools/pip/site-packages/bin/ruff check .
lint-py-fix:
tools/pip/site-packages/bin/ruff check . --fix

lint-py-fix-unsafe:
tools/pip/site-packages/bin/ruff check . --fix --unsafe-fixes
else
lint-py:
lint-py lint-py-fix lint-py-fix-unsafe:
$(warning Python linting with ruff is not available)
$(warning Run 'make lint-py-build')
endif
Expand Down Expand Up @@ -1603,6 +1608,7 @@ lint-clean:
$(RM) tools/.*lintstamp
$(RM) .eslintcache
$(RM) -r tools/eslint/node_modules
$(RM) tools/pip/site_packages

HAS_DOCKER ?= $(shell command -v docker > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)

Expand Down
10 changes: 5 additions & 5 deletions tools/v8-json-to-junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import utils
import signal
import sys
import xml.etree.ElementTree as xml
import xml.etree.ElementTree as ET

def IsExitCodeCrashing(exit_code):
if utils.IsWindows():
Expand All @@ -44,22 +44,22 @@ def IsExitCodeCrashing(exit_code):

class JUnitTestOutput:
def __init__(self, test_suite_name):
self.root = xml.Element("testsuite")
self.root = ET.Element("testsuite")
self.root.attrib["name"] = test_suite_name

def HasRunTest(self, test_name, test_cmd, test_duration, test_failure):
test_case_element = xml.Element("testcase")
test_case_element = ET.Element("testcase")
test_case_element.attrib["name"] = test_name
test_case_element.attrib["cmd"] = test_cmd
test_case_element.attrib["time"] = str(round(test_duration, 3))
if test_failure is not None:
failure_element = xml.Element("failure")
failure_element = ET.Element("failure")
failure_element.text = test_failure
test_case_element.append(failure_element)
self.root.append(test_case_element)

def FinishAndWrite(self, f):
xml.ElementTree(self.root).write(f, "UTF-8")
ET.ElementTree(self.root).write(f, "UTF-8")


def Main():
Expand Down
Loading