Skip to content
Draft
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
41 changes: 1 addition & 40 deletions utils/git/code-format-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,46 +153,7 @@ def format_run(self, changed_files: [str], args: argparse.Namespace) -> str | No
return None


class DarkerFormatHelper(FormatHelper):
name = "darker"
friendly_name = "Python code formatter"

@property
def instructions(self):
return " ".join(self.darker_cmd)

def filter_changed_files(self, changed_files: [str]) -> [str]:
filtered_files = []
for path in changed_files:
name, ext = os.path.splitext(path)
if ext == ".py":
filtered_files.append(path)

return filtered_files

def format_run(self, changed_files: [str], args: argparse.Namespace) -> str | None:
py_files = self.filter_changed_files(changed_files)
if not py_files:
return
darker_cmd = [
"darker",
"--check",
"--diff",
"-r",
f"{args.start_rev}..{args.end_rev}",
] + py_files
print(f"Running: {' '.join(darker_cmd)}")
self.darker_cmd = darker_cmd
proc = subprocess.run(darker_cmd, capture_output=True)

# formatting needed
if proc.returncode == 1:
return proc.stdout.decode("utf-8")

return None


ALL_FORMATTERS = (DarkerFormatHelper(), ClangFormatHelper())
ALL_FORMATTERS = (ClangFormatHelper(),)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down
30 changes: 6 additions & 24 deletions utils/git/requirements_formatting.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,33 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --output-file=llvm/utils/git/requirements_formatting.txt llvm/utils/git/requirements_formatting.txt.in
# pip-compile --output-file=utils/git/requirements_formatting.txt utils/git/requirements_formatting.txt.in
#
black==24.3.0
# via
# -r llvm/utils/git/requirements_formatting.txt.in
# darker
certifi==2024.7.4
# via requests
cffi==1.15.1
cffi==2.0.0
# via
# cryptography
# pynacl
charset-normalizer==3.2.0
# via requests
click==8.1.7
# via black
cryptography==44.0.1
cryptography==46.0.5
# via pyjwt
darker==1.7.2
# via -r llvm/utils/git/requirements_formatting.txt.in
deprecated==1.2.14
# via pygithub
idna==3.7
# via requests
mypy-extensions==1.0.0
# via black
packaging==23.1
# via black
pathspec==0.11.2
# via black
platformdirs==3.10.0
# via black
pycparser==2.21
# via cffi
pygithub==1.59.1
# via -r llvm/utils/git/requirements_formatting.txt.in
# via -r utils/git/requirements_formatting.txt.in
pyjwt[crypto]==2.8.0
# via pygithub
pynacl==1.6.2
pynacl==1.5.0
# via pygithub
requests==2.32.4
# via pygithub
toml==0.10.2
# via darker
urllib3==2.6.3
# via requests
wrapt==1.15.0
Expand Down
2 changes: 0 additions & 2 deletions utils/git/requirements_formatting.txt.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
black~=24.3
darker==1.7.2
PyGithub==1.59.1