Bug 222329

Summary: [check-webkit-style] Fix Contributor sorting in Python 3
Product: WebKit Reporter: Jonathan Bedard <jbedard>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, cgambrell, darin, dewei_zhu, ews-watchlist, glenn, gsnedders, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch dewei_zhu: review+

Jonathan Bedard
Reported 2021-02-23 12:52:24 PST
Sorting of contributors is broken in Python 3, making it difficult for new contributors to add themselves to contributors.json.
Attachments
Patch (4.36 KB, patch)
2021-02-23 12:56 PST, Jonathan Bedard
no flags
Patch (3.82 KB, patch)
2021-02-23 12:58 PST, Jonathan Bedard
no flags
Patch (4.19 KB, patch)
2021-02-23 13:25 PST, Jonathan Bedard
dewei_zhu: review+
Radar WebKit Bug Importer
Comment 1 2021-02-23 12:52:38 PST
Jonathan Bedard
Comment 2 2021-02-23 12:56:17 PST
Jonathan Bedard
Comment 3 2021-02-23 12:58:15 PST
Darin Adler
Comment 4 2021-02-23 13:04:29 PST
Comment on attachment 421345 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=421345&action=review > Tools/Scripts/webkitpy/common/config/committers.py:99 > + cmp = hash(getattr(self, member)) - hash(getattr(other, member)) Sorting by hashes doesn’t seem like a good idea if we want the sorting to stay stable in the future.
Jonathan Bedard
Comment 5 2021-02-23 13:11:05 PST
(In reply to Darin Adler from comment #4) > Comment on attachment 421345 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=421345&action=review > > > Tools/Scripts/webkitpy/common/config/committers.py:99 > > + cmp = hash(getattr(self, member)) - hash(getattr(other, member)) > > Sorting by hashes doesn’t seem like a good idea if we want the sorting to > stay stable in the future. Was trying to avoid iterating through the lists, but I guess we probably should.
Jonathan Bedard
Comment 6 2021-02-23 13:25:11 PST
Jonathan Bedard
Comment 7 2021-02-23 13:41:08 PST
This is the stack trace we get if you modify contributors.json then call check-webkit-style: File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/check-webkit-style", line 46, in <module> sys.exit(CheckWebKitStyle().main()) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/style/main.py", line 159, in main patch_checker.check(patch) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/style/patchreader.py", line 86, in check self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/style/filereader.py", line 137, in process_file self._processor.process(lines, file_path, **kwargs) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/style/checker.py", line 1027, in process checker.check(lines) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/style/checkers/contributors.py", line 42, in check canonicalized = CommitterList().as_json() File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/common/config/committers.py", line 244, in as_json result = CommitterList._contributor_list_to_dict(self._contributors) File "/Volumes/Shared/CheckoutBeta/OpenSource/Tools/Scripts/webkitpy/common/config/committers.py", line 239, in _contributor_list_to_dict for contributor in sorted(list): TypeError: '<' not supported between instances of 'Contributor' and 'Reviewer'
Jonathan Bedard
Comment 8 2021-02-23 16:26:42 PST
Sam Sneddon [:gsnedders]
Comment 9 2021-02-24 10:36:32 PST
FWIW, in general I'd suggest using functools.total_ordering() rather than manually defining all the comparison operations.
Note You need to log in before you can comment on or make changes to this bug.