Skip to content

Commit e9be4c4

Browse files
authored
Remove 'darker' dependency (#8248)
Previously, the github action to check formatting checked python formatting using `darker`. `darker` has some issues, and since this project doesn't involve much python code it is easier to fix them by not using it. This change removes `darker` from the code formatting check pipelines entirely.
1 parent 8620c86 commit e9be4c4

3 files changed

Lines changed: 5 additions & 64 deletions

File tree

utils/git/code-format-helper.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -153,46 +153,7 @@ def format_run(self, changed_files: [str], args: argparse.Namespace) -> str | No
153153
return None
154154

155155

156-
class DarkerFormatHelper(FormatHelper):
157-
name = "darker"
158-
friendly_name = "Python code formatter"
159-
160-
@property
161-
def instructions(self):
162-
return " ".join(self.darker_cmd)
163-
164-
def filter_changed_files(self, changed_files: [str]) -> [str]:
165-
filtered_files = []
166-
for path in changed_files:
167-
name, ext = os.path.splitext(path)
168-
if ext == ".py":
169-
filtered_files.append(path)
170-
171-
return filtered_files
172-
173-
def format_run(self, changed_files: [str], args: argparse.Namespace) -> str | None:
174-
py_files = self.filter_changed_files(changed_files)
175-
if not py_files:
176-
return
177-
darker_cmd = [
178-
"darker",
179-
"--check",
180-
"--diff",
181-
"-r",
182-
f"{args.start_rev}..{args.end_rev}",
183-
] + py_files
184-
print(f"Running: {' '.join(darker_cmd)}")
185-
self.darker_cmd = darker_cmd
186-
proc = subprocess.run(darker_cmd, capture_output=True)
187-
188-
# formatting needed
189-
if proc.returncode == 1:
190-
return proc.stdout.decode("utf-8")
191-
192-
return None
193-
194-
195-
ALL_FORMATTERS = (DarkerFormatHelper(), ClangFormatHelper())
156+
ALL_FORMATTERS = (ClangFormatHelper(),)
196157

197158
if __name__ == "__main__":
198159
parser = argparse.ArgumentParser()

utils/git/requirements_formatting.txt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,33 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
5-
# pip-compile --output-file=llvm/utils/git/requirements_formatting.txt llvm/utils/git/requirements_formatting.txt.in
5+
# pip-compile --output-file=utils/git/requirements_formatting.txt utils/git/requirements_formatting.txt.in
66
#
7-
black==24.3.0
8-
# via
9-
# -r llvm/utils/git/requirements_formatting.txt.in
10-
# darker
117
certifi==2024.7.4
128
# via requests
13-
cffi==1.15.1
9+
cffi==2.0.0
1410
# via
1511
# cryptography
1612
# pynacl
1713
charset-normalizer==3.2.0
1814
# via requests
19-
click==8.1.7
20-
# via black
2115
cryptography==46.0.5
2216
# via pyjwt
23-
darker==1.7.2
24-
# via -r llvm/utils/git/requirements_formatting.txt.in
2517
deprecated==1.2.14
2618
# via pygithub
2719
idna==3.7
2820
# via requests
29-
mypy-extensions==1.0.0
30-
# via black
31-
packaging==23.1
32-
# via black
33-
pathspec==0.11.2
34-
# via black
35-
platformdirs==3.10.0
36-
# via black
3721
pycparser==2.21
3822
# via cffi
3923
pygithub==1.59.1
40-
# via -r llvm/utils/git/requirements_formatting.txt.in
24+
# via -r utils/git/requirements_formatting.txt.in
4125
pyjwt[crypto]==2.8.0
4226
# via pygithub
4327
pynacl==1.5.0
4428
# via pygithub
4529
requests==2.32.4
4630
# via pygithub
47-
toml==0.10.2
48-
# via darker
4931
urllib3==2.6.0
5032
# via requests
5133
wrapt==1.15.0
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
black~=24.3
2-
darker==1.7.2
31
PyGithub==1.59.1

0 commit comments

Comments
 (0)