Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | 7928 |
Merged at revision: | 7927 |
Proposed branch: | lp:~jelmer/brz/fix-ruff |
Merge into: | lp:brz |
Diff against target: |
412 lines (+46/-70) 17 files modified
Makefile (+2/-0) breezy/bzr/inventory.py (+1/-1) breezy/bzr/remote.py (+4/-1) breezy/bzr/tests/test_knit.py (+1/-3) breezy/bzr/tests/test_weave.py (+1/-3) breezy/bzr/vf_repository.py (+2/-3) breezy/bzr/weave.py (+2/-8) breezy/plugins/stats/cmds.py (+4/-6) breezy/plugins/weave_fmt/bzrdir.py (+1/-3) breezy/tests/test_http.py (+2/-6) breezy/transport/__init__.py (+1/-3) breezy/ui/text.py (+1/-3) crates/bazaar-py/src/inventory.rs (+14/-16) crates/graph-py/src/lib.rs (+3/-6) crates/transport-py/src/lib.rs (+1/-1) crates/transport-py/src/sftp.rs (+0/-1) pyproject.toml (+6/-6) |
To merge this branch: | bzr merge lp:~jelmer/brz/fix-ruff |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij | Approve | ||
Review via email: mp+460726@code.launchpad.net |
Commit message
Update to new ruff
Description of the change
Update to new ruff
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) : | # |
review:
Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
lp:~jelmer/brz/fix-ruff
updated
- 7928. By Jelmer Vernooij
-
Fix test
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' |
2 | --- Makefile 2024-01-24 22:02:59 +0000 |
3 | +++ Makefile 2024-02-18 14:24:34 +0000 |
4 | @@ -39,6 +39,7 @@ |
5 | extensions: |
6 | @echo "building extension modules." |
7 | $(PYTHON) setup.py build_ext -i $(PYTHON_BUILDFLAGS) |
8 | + $(PYTHON) setup.py build_rust -i $(PYTHON_BUILDFLAGS) |
9 | |
10 | check:: docs check-nodocs |
11 | |
12 | @@ -238,6 +239,7 @@ |
13 | @echo *** Make brz.exe |
14 | $(PYTHON) tools/win32/ostools.py remove breezy/*.pyd |
15 | $(PYTHON) setup.py build_ext -i -f $(PYTHON_BUILDFLAGS) |
16 | + $(PYTHON) setup.py build_rust -i -f $(PYTHON_BUILDFLAGS) |
17 | $(PYTHON) setup.py py2exe > py2exe.log |
18 | $(PYTHON) tools/win32/ostools.py copytodir tools/win32/start_brz.bat win32_brz.exe |
19 | $(PYTHON) tools/win32/ostools.py copytodir tools/win32/breezy.url win32_brz.exe |
20 | |
21 | === modified file 'breezy/bzr/inventory.py' |
22 | --- breezy/bzr/inventory.py 2023-11-16 15:15:02 +0000 |
23 | +++ breezy/bzr/inventory.py 2024-02-18 14:24:34 +0000 |
24 | @@ -765,7 +765,7 @@ |
25 | revision_id = info[b"revision_id"] |
26 | root_id = info[b"root_id"] |
27 | search_key_name = info.get(b"search_key_name", b"plain") |
28 | - parent_id_basename_to_file_id = info.get(b"parent_id_basename_to_file_id", None) |
29 | + parent_id_basename_to_file_id = info.get(b"parent_id_basename_to_file_id") |
30 | if not parent_id_basename_to_file_id.startswith(b"sha1:"): |
31 | raise ValueError( |
32 | "parent_id_basename_to_file_id should be a sha1" |
33 | |
34 | === modified file 'breezy/bzr/remote.py' |
35 | --- breezy/bzr/remote.py 2023-11-16 15:15:02 +0000 |
36 | +++ breezy/bzr/remote.py 2024-02-18 14:24:34 +0000 |
37 | @@ -2823,7 +2823,10 @@ |
38 | with tarfile.open( |
39 | "repository", fileobj=tar_file, mode="r|bz2" |
40 | ) as tar, osutils.TemporaryDirectory() as tmpdir: |
41 | - tar.extractall(tmpdir) |
42 | + members = tar.getmembers() |
43 | + if any(m.name.startswith("/") or ".." in m.name for m in members): |
44 | + raise AssertionError("Tarball contains absolute paths") |
45 | + tar.extractall(tmpdir, members=members) # noqa: S202 |
46 | tmp_bzrdir = _mod_bzrdir.BzrDir.open(tmpdir) |
47 | tmp_repo = tmp_bzrdir.open_repository() |
48 | tmp_repo.copy_content_into(destination, revision_id) |
49 | |
50 | === modified file 'breezy/bzr/tests/test_knit.py' |
51 | --- breezy/bzr/tests/test_knit.py 2023-11-16 15:15:02 +0000 |
52 | +++ breezy/bzr/tests/test_knit.py 2024-02-18 14:24:34 +0000 |
53 | @@ -290,9 +290,7 @@ |
54 | """ |
55 | |
56 | def readv(self, relpath, offsets): |
57 | - count = 0 |
58 | - for result in MockTransport.readv(self, relpath, offsets): |
59 | - count += 1 |
60 | + for count, result in enumerate(MockTransport.readv(self, relpath, offsets), 1): |
61 | # we use 2 because the first offset is the pack header, the second |
62 | # is the first actual content requset |
63 | if count > 2: |
64 | |
65 | === modified file 'breezy/bzr/tests/test_weave.py' |
66 | --- breezy/bzr/tests/test_weave.py 2023-11-07 10:54:10 +0000 |
67 | +++ breezy/bzr/tests/test_weave.py 2024-02-18 14:24:34 +0000 |
68 | @@ -660,11 +660,9 @@ |
69 | |
70 | k = Weave() |
71 | parents = set() |
72 | - i = 0 |
73 | - for t in texts: |
74 | + for i, t in enumerate(texts): |
75 | k.add_lines(b"text%d" % i, list(parents), t) |
76 | parents.add(b"text%d" % i) |
77 | - i += 1 |
78 | |
79 | self.log("k._weave=" + pformat(k._weave)) |
80 | |
81 | |
82 | === modified file 'breezy/bzr/vf_repository.py' |
83 | --- breezy/bzr/vf_repository.py 2023-11-16 21:12:11 +0000 |
84 | +++ breezy/bzr/vf_repository.py 2024-02-18 14:24:34 +0000 |
85 | @@ -465,7 +465,7 @@ |
86 | carried_over = False |
87 | if len(heads) == 1: |
88 | # Could be a carry-over situation: |
89 | - parent_entry_revs = parent_entries.get(file_id, None) |
90 | + parent_entry_revs = parent_entries.get(file_id) |
91 | if parent_entry_revs: |
92 | parent_entry = parent_entry_revs.get(heads[0], None) |
93 | else: |
94 | @@ -1508,10 +1508,9 @@ |
95 | file_ids = self.fileids_altered_by_revision_ids(revision_ids, inv_w) |
96 | count = 0 |
97 | num_file_ids = len(file_ids) |
98 | - for file_id, altered_versions in file_ids.items(): |
99 | + for count, (file_id, altered_versions) in enumerate(file_ids.items()): |
100 | if pb is not None: |
101 | pb.update(gettext("Fetch texts"), count, num_file_ids) |
102 | - count += 1 |
103 | yield ("file", file_id, altered_versions) |
104 | |
105 | def _find_non_file_keys_to_fetch(self, revision_ids): |
106 | |
107 | === modified file 'breezy/bzr/weave.py' |
108 | --- breezy/bzr/weave.py 2023-11-16 15:15:02 +0000 |
109 | +++ breezy/bzr/weave.py 2024-02-18 14:24:34 +0000 |
110 | @@ -651,9 +651,7 @@ |
111 | istack = [] |
112 | dset = set() |
113 | |
114 | - lineno = 0 # line of weave, 0-based |
115 | - |
116 | - for l in self._weave: |
117 | + for lineno, l in enumerate(self._weave): |
118 | if l.__class__ == tuple: |
119 | c, v = l |
120 | if c == b"{": |
121 | @@ -668,7 +666,6 @@ |
122 | raise WeaveFormatError(f"unexpected instruction {v!r}") |
123 | else: |
124 | yield lineno, istack[-1], frozenset(dset), l |
125 | - lineno += 1 |
126 | |
127 | if istack: |
128 | raise WeaveFormatError( |
129 | @@ -740,8 +737,6 @@ |
130 | iset = set() |
131 | dset = set() |
132 | |
133 | - lineno = 0 # line of weave, 0-based |
134 | - |
135 | isactive = None |
136 | |
137 | result = [] |
138 | @@ -770,7 +765,7 @@ |
139 | # 'in' test could dominate, so I'm leaving this change in place - when |
140 | # its fast enough to consider profiling big datasets we can review. |
141 | |
142 | - for l in self._weave: |
143 | + for lineno, l in enumerate(self._weave): |
144 | if l.__class__ == tuple: |
145 | c, v = l |
146 | isactive = None |
147 | @@ -792,7 +787,6 @@ |
148 | isactive = (not dset) and istack and (istack[-1] in included) |
149 | if isactive: |
150 | result.append((istack[-1], lineno, l)) |
151 | - lineno += 1 |
152 | if istack: |
153 | raise WeaveFormatError( |
154 | "unclosed insertion blocks " "at end of weave: %s" % istack |
155 | |
156 | === modified file 'breezy/plugins/stats/cmds.py' |
157 | --- breezy/plugins/stats/cmds.py 2023-11-16 15:15:02 +0000 |
158 | +++ breezy/plugins/stats/cmds.py 2024-02-18 14:24:34 +0000 |
159 | @@ -291,10 +291,10 @@ |
160 | with a_branch.lock_read(): |
161 | graph = a_branch.repository.get_graph() |
162 | revno = 0 |
163 | - cur_parents = 0 |
164 | sorted_graph = tsort.merge_sort(graph.iter_ancestry([last_rev]), last_rev) |
165 | - for _num, _node_name, depth, _isend in reversed(sorted_graph): |
166 | - cur_parents += 1 |
167 | + for cur_parents, (_num, _node_name, depth, _isend) in enumerate( |
168 | + reversed(sorted_graph), 1 |
169 | + ): |
170 | if depth == 0: |
171 | revno += 1 |
172 | self.outf.write("%4d, %4d\n" % (revno, cur_parents)) |
173 | @@ -304,15 +304,13 @@ |
174 | ret = {} |
175 | total = 0 |
176 | with ui.ui_factory.nested_progress_bar() as pb, repository.lock_read(): |
177 | - i = 0 |
178 | - for delta in repository.get_revision_deltas(revs): |
179 | + for i, delta in enumerate(repository.get_revision_deltas(revs)): |
180 | pb.update("classifying commits", i, len(revs)) |
181 | for c in classify_delta(delta): |
182 | if c not in ret: |
183 | ret[c] = 0 |
184 | ret[c] += 1 |
185 | total += 1 |
186 | - i += 1 |
187 | return ret, total |
188 | |
189 | |
190 | |
191 | === modified file 'breezy/plugins/weave_fmt/bzrdir.py' |
192 | --- breezy/plugins/weave_fmt/bzrdir.py 2023-11-16 15:15:02 +0000 |
193 | +++ breezy/plugins/weave_fmt/bzrdir.py 2024-02-18 14:24:34 +0000 |
194 | @@ -357,11 +357,9 @@ |
195 | transaction = WriteTransaction() |
196 | |
197 | try: |
198 | - i = 0 |
199 | - for file_id, file_weave in self.text_weaves.items(): |
200 | + for i, (file_id, file_weave) in enumerate(self.text_weaves.items()): |
201 | self.pb.update(gettext("writing weave"), i, len(self.text_weaves)) |
202 | weaves._put_weave(file_id, file_weave, transaction) |
203 | - i += 1 |
204 | self.pb.update(gettext("inventory"), 0, 1) |
205 | controlweaves._put_weave(b"inventory", self.inv_weave, transaction) |
206 | self.pb.update(gettext("inventory"), 1, 1) |
207 | |
208 | === modified file 'breezy/tests/test_http.py' |
209 | --- breezy/tests/test_http.py 2023-11-07 16:08:34 +0000 |
210 | +++ breezy/tests/test_http.py 2024-02-18 14:24:34 +0000 |
211 | @@ -963,8 +963,7 @@ |
212 | self.end_headers() |
213 | |
214 | # Send the multipart body |
215 | - cur = 0 |
216 | - for start, end in ranges: |
217 | + for cur, (start, end) in enumerate(ranges): |
218 | self.wfile.write(boundary_line) |
219 | self.send_header("Content-type", "application/octet-stream") |
220 | self.send_header( |
221 | @@ -976,7 +975,6 @@ |
222 | self.close_connection = 1 |
223 | return |
224 | self.send_range_content(file, start, end - start + 1) |
225 | - cur += 1 |
226 | # Final boundary |
227 | self.wfile.write(boundary_line) |
228 | |
229 | @@ -1038,8 +1036,7 @@ |
230 | self.end_headers() |
231 | |
232 | # Send the multipart body |
233 | - cur = 0 |
234 | - for start, end in ranges: |
235 | + for cur, (start, end) in enumerate(ranges): |
236 | if cur + self._truncated_ranges >= len(ranges): |
237 | # Abruptly ends the response and close the connection |
238 | self.close_connection = 1 |
239 | @@ -1051,7 +1048,6 @@ |
240 | ) |
241 | self.end_headers() |
242 | self.send_range_content(file, start, end - start + 1) |
243 | - cur += 1 |
244 | # Final boundary |
245 | self.wfile.write(boundary_line) |
246 | |
247 | |
248 | === modified file 'breezy/transport/__init__.py' |
249 | --- breezy/transport/__init__.py 2023-11-16 15:15:02 +0000 |
250 | +++ breezy/transport/__init__.py 2024-02-18 14:24:34 +0000 |
251 | @@ -552,14 +552,12 @@ |
252 | """ |
253 | total = self._get_total(multi) |
254 | result = [] |
255 | - count = 0 |
256 | - for entry in multi: |
257 | + for count, entry in enumerate(multi): |
258 | self._update_pb(pb, msg, count, total) |
259 | if expand: |
260 | result.append(func(*entry)) |
261 | else: |
262 | result.append(func(entry)) |
263 | - count += 1 |
264 | return tuple(result) |
265 | |
266 | def abspath(self, relpath): |
267 | |
268 | === modified file 'breezy/ui/text.py' |
269 | --- breezy/ui/text.py 2023-11-16 15:15:02 +0000 |
270 | +++ breezy/ui/text.py 2024-02-18 14:24:34 +0000 |
271 | @@ -72,13 +72,12 @@ |
272 | Setup final prompt and the lists of choices and associated |
273 | shortcuts. |
274 | """ |
275 | - index = 0 |
276 | help_list = [] |
277 | self.alternatives = {} |
278 | choices = choices.split("\n") |
279 | if default is not None and default not in range(0, len(choices)): |
280 | raise ValueError("invalid default index") |
281 | - for c in choices: |
282 | + for index, c in enumerate(choices): |
283 | name = c.replace("&", "").lower() |
284 | choice = (name, index) |
285 | if name in self.alternatives: |
286 | @@ -103,7 +102,6 @@ |
287 | self.alternatives[""] = choice |
288 | self.alternatives["\r"] = choice |
289 | help_list.append(help) |
290 | - index += 1 |
291 | |
292 | self.prompt = f"{msg} ({', '.join(help_list)}): " |
293 | |
294 | |
295 | === modified file 'crates/bazaar-py/src/inventory.rs' |
296 | --- crates/bazaar-py/src/inventory.rs 2024-01-27 13:51:13 +0000 |
297 | +++ crates/bazaar-py/src/inventory.rs 2024-02-18 14:24:34 +0000 |
298 | @@ -252,23 +252,21 @@ |
299 | // * there was a bug in revision updates with executable bit support |
300 | let mut candidate = |
301 | candidate.extract::<PyRefMut<InventoryEntry>>(py)?; |
302 | - match (&mut candidate.0, &mut entry.0) { |
303 | - ( |
304 | - Entry::File { |
305 | - executable: candidate_executable, |
306 | - .. |
307 | - }, |
308 | - Entry::File { |
309 | - executable: entry_executable, |
310 | - .. |
311 | - }, |
312 | - ) => { |
313 | - if candidate_executable != entry_executable { |
314 | - *entry_executable = false; |
315 | - *candidate_executable = false; |
316 | - } |
317 | + if let ( |
318 | + Entry::File { |
319 | + executable: candidate_executable, |
320 | + .. |
321 | + }, |
322 | + Entry::File { |
323 | + executable: entry_executable, |
324 | + .. |
325 | + }, |
326 | + ) = (&mut candidate.0, &mut entry.0) |
327 | + { |
328 | + if candidate_executable != entry_executable { |
329 | + *entry_executable = false; |
330 | + *candidate_executable = false; |
331 | } |
332 | - _ => {} |
333 | } |
334 | } else { |
335 | // add this revision as a candidate. |
336 | |
337 | === modified file 'crates/graph-py/src/lib.rs' |
338 | --- crates/graph-py/src/lib.rs 2024-01-27 14:21:25 +0000 |
339 | +++ crates/graph-py/src/lib.rs 2024-02-18 14:24:34 +0000 |
340 | @@ -301,13 +301,10 @@ |
341 | }; |
342 | |
343 | // The null: revision doesn't exist in the graph, so don't attempt to remove it |
344 | - match branch_tip { |
345 | - Some(ref mut tip_obj) => { |
346 | - if branch_tip_is_null(py, tip_obj.clone_ref(py)) { |
347 | - branch_tip = None; |
348 | - } |
349 | + if let Some(ref mut tip_obj) = branch_tip { |
350 | + if branch_tip_is_null(py, tip_obj.clone_ref(py)) { |
351 | + branch_tip = None; |
352 | } |
353 | - None => (), |
354 | } |
355 | |
356 | let sorter = breezy_graph::tsort::MergeSorter::<PyNode>::new( |
357 | |
358 | === modified file 'crates/transport-py/src/lib.rs' |
359 | --- crates/transport-py/src/lib.rs 2024-01-27 13:51:13 +0000 |
360 | +++ crates/transport-py/src/lib.rs 2024-02-18 14:24:34 +0000 |
361 | @@ -1,5 +1,5 @@ |
362 | use breezy_transport::lock::{FileLock, Lock as LockTrait, LockError}; |
363 | -use breezy_transport::{Error, ReadStream, Transport as TransportTrait, UrlFragment, WriteStream}; |
364 | +use breezy_transport::{Error, ReadStream, Transport as _, UrlFragment, WriteStream}; |
365 | use log::debug; |
366 | use pyo3::exceptions::{PyRuntimeError, PyValueError}; |
367 | use pyo3::import_exception; |
368 | |
369 | === modified file 'crates/transport-py/src/sftp.rs' |
370 | --- crates/transport-py/src/sftp.rs 2023-11-14 20:56:14 +0000 |
371 | +++ crates/transport-py/src/sftp.rs 2024-02-18 14:24:34 +0000 |
372 | @@ -5,7 +5,6 @@ |
373 | use pyo3::types::{PyBytes, PyType}; |
374 | |
375 | use std::collections::VecDeque; |
376 | -use std::io::{Read, Seek}; |
377 | use std::sync::Arc; |
378 | |
379 | create_exception!(breezy._transport_rs, SFTPError, PyException); |
380 | |
381 | === modified file 'pyproject.toml' |
382 | --- pyproject.toml 2023-11-16 21:12:11 +0000 |
383 | +++ pyproject.toml 2024-02-18 14:24:34 +0000 |
384 | @@ -97,6 +97,9 @@ |
385 | ignore_missing_imports = true |
386 | |
387 | [tool.ruff] |
388 | +extend-exclude = ["lib", "bin"] |
389 | + |
390 | +[tool.ruff.lint] |
391 | select = [ |
392 | "ANN", # annotations |
393 | "D", # pydocstyle |
394 | @@ -173,15 +176,12 @@ |
395 | ] |
396 | # These are actually fine, but they make mypy more strict and then it fails. |
397 | unfixable = ["ANN204"] |
398 | -extend-exclude = ["lib", "bin"] |
399 | - |
400 | -[tool.ruff.isort] |
401 | - |
402 | -[tool.ruff.extend-per-file-ignores] |
403 | + |
404 | +[tool.ruff.lint.extend-per-file-ignores] |
405 | "breezy/plugins/po_merge/tests/test_po_merge.py" = ["RUF001"] |
406 | |
407 | |
408 | -[tool.ruff.pydocstyle] |
409 | +[tool.ruff.lint.pydocstyle] |
410 | convention = "google" |
411 | |
412 | [tool.setuptools-gettext] |
The attempt to merge lp:~jelmer/brz/fix-ruff into lp:brz failed. Command exited with 1.
Below is the output from the failed tests.
Collecting setuptools-gettext gettext- 0.1.11- py3-none- any.whl. metadata (1.9 kB) 11/site- packages (from setuptools-gettext) (68.1.2) gettext- 0.1.11- py3-none- any.whl (13 kB) gettext- 0.1.11 /tmp/tarmac/ branch. yetqwku0 python3/ dist-packages (from breezy==3.4.0.dev0) (5.0.8) python3/ dist-packages (from breezy==3.4.0.dev0) (0.2) python3/ dist-packages (from breezy==3.4.0.dev0) (0.2.13) python3/ dist-packages (from breezy==3.4.0.dev0) (0.0.8) python3/ dist-packages (from breezy==3.4.0.dev0) (0.21.6) python3/ dist-packages (from breezy==3.4.0.dev0) (1.26.18) python3/ dist-packages (from breezy==3.4.0.dev0) (6.0.1) 2.7.1-py3- none-any. whl.metadata (5.3 kB) 0.5.0-py2. py3-none- any.whl (21 kB) subunit- 1.4.4-py3- none-any. whl.metadata (22 kB) 3.0.8-cp311- cp311-manylinux _2_17_x86_ 64.manylinux201 4_x86_64. whl.metadata (3.2 kB) lib/python3. 11/dist- packages (from breezy==3.4.0.dev0) (0.2.2) 0.20.1- py3-none- any.whl. metadata (2.8 kB) 11/site- packages (from breezy==3.4.0.dev0) (68.1.2) 7.2.6-py3- none-any. whl.metadata (5.9 kB) epytext- 0.0.4.tar. gz (3.6 kB) 0.9.14. tar.gz (41 kB)
Downloading setuptools_
Requirement already satisfied: setuptools>=60.8 in ./lib/python3.
Downloading setuptools_
Installing collected packages: setuptools-gettext
Successfully installed setuptools-
Obtaining file://
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Checking if build backend supports build_editable: started
Checking if build backend supports build_editable: finished with status 'done'
Getting requirements to build editable: started
Getting requirements to build editable: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing editable metadata (pyproject.toml): started
Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: configobj in /usr/lib/
Requirement already satisfied: fastbencode in /usr/lib/
Requirement already satisfied: patiencediff in /usr/lib/
Requirement already satisfied: merge3 in /usr/lib/
Requirement already satisfied: dulwich>=0.21.6 in /usr/lib/
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/
Requirement already satisfied: pyyaml in /usr/lib/
Collecting testtools>=0.9.5 (from breezy==3.4.0.dev0)
Downloading testtools-
Collecting testscenarios (from breezy==3.4.0.dev0)
Downloading testscenarios-
Collecting python-subunit (from breezy==3.4.0.dev0)
Downloading python_
Collecting cython>=0.29 (from breezy==3.4.0.dev0)
Using cached Cython-
Requirement already satisfied: ruff in /usr/local/
Collecting docutils (from breezy==3.4.0.dev0)
Downloading docutils-
Requirement already satisfied: setuptools in ./lib/python3.
Collecting sphinx (from breezy==3.4.0.dev0)
Downloading sphinx-
Collecting sphinx-epytext (from breezy==3.4.0.dev0)
Downloading sphinx-
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting fastimport (from breezy==3.4.0.dev0)
Downloading fastimport-
━━━━━━...