Merge lp:~rbalint/update-manager/pep8-again into lp:update-manager
- pep8-again
- Merge into main
Proposed by
Balint Reczey
Status: | Merged |
---|---|
Merged at revision: | 2842 |
Proposed branch: | lp:~rbalint/update-manager/pep8-again |
Merge into: | lp:update-manager |
Diff against target: |
424 lines (+56/-55) 18 files modified
UpdateManager/ChangelogViewer.py (+1/-1) UpdateManager/Core/MetaRelease.py (+2/-2) UpdateManager/Core/MyCache.py (+6/-6) UpdateManager/Core/UpdateList.py (+8/-8) UpdateManager/Dialogs.py (+1/-1) UpdateManager/UpdateManager.py (+2/-2) UpdateManager/UpdatesAvailable.py (+6/-6) UpdateManager/backend/__init__.py (+4/-4) debian/changelog (+5/-4) debian/source_update-manager.py (+2/-2) janitor/plugincore/manager.py (+4/-4) janitor/plugincore/plugins/kdelibs4to5_plugin.py (+1/-1) janitor/plugincore/plugins/langpack_manual_plugin.py (+3/-3) janitor/plugincore/tests/test_documentation.py (+3/-3) tests/test_hwe_support_status.py (+3/-3) tests/test_pep8.py (+1/-1) tests/test_update_origin.py (+3/-3) tests/test_utils.py (+1/-1) |
To merge this branch: | bzr merge lp:~rbalint/update-manager/pep8-again |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Iain Lane | Approve | ||
Brian Murray | Approve | ||
Review via email: mp+355934@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'UpdateManager/ChangelogViewer.py' |
2 | --- UpdateManager/ChangelogViewer.py 2018-09-27 14:15:39 +0000 |
3 | +++ UpdateManager/ChangelogViewer.py 2018-10-01 16:16:20 +0000 |
4 | @@ -162,7 +162,7 @@ |
5 | # search for the next match in the buffer |
6 | for (start_str, end_list, url_prefix) in search_items: |
7 | # init |
8 | - iter = buffer.get_iter_at_offset(iter_end.get_offset() \ |
9 | + iter = buffer.get_iter_at_offset(iter_end.get_offset() |
10 | - len(content)) |
11 | while True: |
12 | ret = iter.forward_search(start_str, |
13 | |
14 | === modified file 'UpdateManager/Core/MetaRelease.py' |
15 | --- UpdateManager/Core/MetaRelease.py 2018-09-27 14:15:39 +0000 |
16 | +++ UpdateManager/Core/MetaRelease.py 2018-10-01 16:16:20 +0000 |
17 | @@ -344,7 +344,7 @@ |
18 | # sometime there is a root owned meta-relase file |
19 | # there, try to remove it so that we get it |
20 | # with proper permissions |
21 | - if (os.path.exists(self.METARELEASE_FILE) \ |
22 | + if (os.path.exists(self.METARELEASE_FILE) |
23 | and not os.access(self.METARELEASE_FILE, os.W_OK)): |
24 | try: |
25 | os.unlink(self.METARELEASE_FILE) |
26 | @@ -381,7 +381,7 @@ |
27 | try: |
28 | self.parse() |
29 | except Exception as e: |
30 | - logging.exception("parse failed for '%s'" \ |
31 | + logging.exception("parse failed for '%s'" |
32 | % self.METARELEASE_FILE) |
33 | # no use keeping a broken file around |
34 | os.remove(self.METARELEASE_FILE) |
35 | |
36 | === modified file 'UpdateManager/Core/MyCache.py' |
37 | --- UpdateManager/Core/MyCache.py 2018-09-27 14:15:39 +0000 |
38 | +++ UpdateManager/Core/MyCache.py 2018-10-01 16:16:20 +0000 |
39 | @@ -84,7 +84,7 @@ |
40 | # on broken packages, try to fix via saveDistUpgrade() |
41 | if self._depcache.broken_count > 0: |
42 | self.saveDistUpgrade() |
43 | - assert (self._depcache.broken_count == 0 \ |
44 | + assert (self._depcache.broken_count == 0 |
45 | and self._depcache.del_count == 0) |
46 | self.launchpad = None |
47 | # generate versioned_kernel_pkgs_regexp for later use |
48 | @@ -154,7 +154,7 @@ |
49 | continue |
50 | match = True |
51 | for base_dep in dep_or: |
52 | - if (base_dep.name != target.package.shortname \ |
53 | + if (base_dep.name != target.package.shortname |
54 | or not apt_pkg.check_dep( |
55 | target.version, base_dep.relation, base_dep.version)): |
56 | match = False |
57 | @@ -170,7 +170,7 @@ |
58 | candidate = cpkg.candidate |
59 | if candidate is not None: |
60 | if (self._check_dependencies( |
61 | - target, candidate.get_dependencies("Conflicts")) \ |
62 | + target, candidate.get_dependencies("Conflicts")) |
63 | and self._check_dependencies( |
64 | target, candidate.get_dependencies("Replaces"))): |
65 | logging.info( |
66 | @@ -192,7 +192,7 @@ |
67 | wouldDelete -= 1 |
68 | if wouldDelete > 0: |
69 | self.clear() |
70 | - assert (self._depcache.broken_count == 0 \ |
71 | + assert (self._depcache.broken_count == 0 |
72 | and self._depcache.del_count == 0) |
73 | else: |
74 | assert self._depcache.broken_count == 0 |
75 | @@ -283,12 +283,12 @@ |
76 | # |
77 | # for NEWS.Debian we do require the changelogver > installed |
78 | if strict_versioning: |
79 | - if (installed \ |
80 | + if (installed |
81 | and apt_pkg.version_compare(changelogver, |
82 | installed) < 0): |
83 | break |
84 | else: |
85 | - if (installed \ |
86 | + if (installed |
87 | and apt_pkg.version_compare(changelogver, |
88 | installed) == 0): |
89 | break |
90 | |
91 | === modified file 'UpdateManager/Core/UpdateList.py' |
92 | --- UpdateManager/Core/UpdateList.py 2018-09-27 14:15:39 +0000 |
93 | +++ UpdateManager/Core/UpdateList.py 2018-10-01 16:16:20 +0000 |
94 | @@ -102,8 +102,8 @@ |
95 | # This shouldn't really happen. If we land here often, it's a sign |
96 | # that something has gone wrong. Unless all pkgs are None it's not |
97 | # a critical issue - a hit to the performance at most. |
98 | - reason = ((not pkg or not pkg.candidate) \ |
99 | - and "Package was None or didn't have a candidate." \ |
100 | + reason = ((not pkg or not pkg.candidate) |
101 | + and "Package was None or didn't have a candidate." |
102 | or "%s already in _deps." % pkg.name) |
103 | logging.debug("Useless call to _add_deps. %s" % reason) |
104 | return |
105 | @@ -140,7 +140,7 @@ |
106 | |
107 | def selection_is_inconsistent(self): |
108 | pkgs_installing = [item for item in self.items if item.is_selected()] |
109 | - return (len(pkgs_installing) > 0 \ |
110 | + return (len(pkgs_installing) > 0 |
111 | and len(pkgs_installing) < len(self.items)) |
112 | |
113 | def get_total_size(self): |
114 | @@ -338,7 +338,7 @@ |
115 | inst_ver = pkg._pkg.current_ver |
116 | for ver in pkg._pkg.version_list: |
117 | # discard is < than installed ver |
118 | - if (inst_ver \ |
119 | + if (inst_ver |
120 | and apt.apt_pkg.version_compare(ver.ver_str, |
121 | inst_ver.ver_str) <= 0): |
122 | continue |
123 | @@ -507,13 +507,13 @@ |
124 | upgrade_pkgs.append(pkg) |
125 | self.num_updates = self.num_updates + 1 |
126 | |
127 | - if pkg.is_upgradable and not (pkg.marked_upgrade \ |
128 | + if pkg.is_upgradable and not (pkg.marked_upgrade |
129 | or pkg.marked_install): |
130 | self.held_back.append(pkg.name) |
131 | continue |
132 | - if (pkg.is_auto_removable \ |
133 | - and (cache.versioned_kernel_pkgs_regexp \ |
134 | - and cache.versioned_kernel_pkgs_regexp.match(pkg.name) \ |
135 | + if (pkg.is_auto_removable |
136 | + and (cache.versioned_kernel_pkgs_regexp |
137 | + and cache.versioned_kernel_pkgs_regexp.match(pkg.name) |
138 | and not cache.running_kernel_pkgs_regexp.match( |
139 | pkg.name))): |
140 | kernel_autoremove_pkgs.append(pkg) |
141 | |
142 | === modified file 'UpdateManager/Dialogs.py' |
143 | --- UpdateManager/Dialogs.py 2018-09-27 14:15:39 +0000 |
144 | +++ UpdateManager/Dialogs.py 2018-10-01 16:16:20 +0000 |
145 | @@ -368,7 +368,7 @@ |
146 | Dialog.start(self) |
147 | # Turn off close button |
148 | self.window_main.realize() |
149 | - self.window_main.get_window().set_functions(Gdk.WMFunction.MOVE \ |
150 | + self.window_main.get_window().set_functions(Gdk.WMFunction.MOVE |
151 | | Gdk.WMFunction.MINIMIZE) |
152 | |
153 | def restart(self, *args, **kwargs): |
154 | |
155 | === modified file 'UpdateManager/UpdateManager.py' |
156 | --- UpdateManager/UpdateManager.py 2018-09-27 14:15:39 +0000 |
157 | +++ UpdateManager/UpdateManager.py 2018-10-01 16:16:20 +0000 |
158 | @@ -305,8 +305,8 @@ |
159 | |
160 | # Check for new fresh release |
161 | settings = Gio.Settings.new("com.ubuntu.update-manager") |
162 | - if (self.meta_release.new_dist \ |
163 | - and (self.options.check_dist_upgrades \ |
164 | + if (self.meta_release.new_dist |
165 | + and (self.options.check_dist_upgrades |
166 | or settings.get_boolean("check-dist-upgrades"))): |
167 | return DistUpgradeDialog(self, self.meta_release) |
168 | |
169 | |
170 | === modified file 'UpdateManager/UpdatesAvailable.py' |
171 | --- UpdateManager/UpdatesAvailable.py 2018-09-27 14:15:39 +0000 |
172 | +++ UpdateManager/UpdatesAvailable.py 2018-10-01 16:16:20 +0000 |
173 | @@ -531,11 +531,11 @@ |
174 | # set descr |
175 | data = model.get_value(iter, LIST_UPDATE_DATA) |
176 | item = data.item |
177 | - if (item is None and data.group is not None \ |
178 | + if (item is None and data.group is not None |
179 | and data.group.core_item is not None): |
180 | item = data.group.core_item |
181 | - if (item is None or item.pkg is None \ |
182 | - or item.pkg.candidate is None \ |
183 | + if (item is None or item.pkg is None |
184 | + or item.pkg.candidate is None |
185 | or item.pkg.candidate.description is None): |
186 | changes_buffer = self.textview_changes.get_buffer() |
187 | changes_buffer.set_text("") |
188 | @@ -724,7 +724,7 @@ |
189 | self.hbox_restart.set_visible(requires_restart) |
190 | |
191 | def _refresh_updates_count(self): |
192 | - self.button_install.set_sensitive(self.cache.install_count \ |
193 | + self.button_install.set_sensitive(self.cache.install_count |
194 | + self.cache.del_count) |
195 | try: |
196 | inst_count = self.cache.install_count + self.cache.del_count |
197 | @@ -889,7 +889,7 @@ |
198 | self.vbox_alerts.show() |
199 | self.connected = False |
200 | # in doubt (STATE_UNKNOWN), assume connected |
201 | - elif (state in NetworkManagerHelper.NM_STATE_CONNECTED_LIST \ |
202 | + elif (state in NetworkManagerHelper.NM_STATE_CONNECTED_LIST |
203 | or state == NetworkManagerHelper.NM_STATE_UNKNOWN): |
204 | self.updates_changed() |
205 | self.hbox_offline.hide() |
206 | @@ -1067,7 +1067,7 @@ |
207 | |
208 | self.treeview_update.set_model(self.store) |
209 | self.pkg_cell_area.indent_toplevel = ( |
210 | - bool(self.list.security_groups) \ |
211 | + bool(self.list.security_groups) |
212 | or bool(self.list.kernel_autoremove_groups)) |
213 | self.update_close_button() |
214 | self.update_count() |
215 | |
216 | === modified file 'UpdateManager/backend/__init__.py' |
217 | --- UpdateManager/backend/__init__.py 2018-09-27 14:15:39 +0000 |
218 | +++ UpdateManager/backend/__init__.py 2018-10-01 16:16:20 +0000 |
219 | @@ -46,10 +46,10 @@ |
220 | if pkg.is_auto_installed: |
221 | pkgname += "#auto" |
222 | pkgs_install.append(pkgname) |
223 | - elif (pkg.marked_upgrade \ |
224 | + elif (pkg.marked_upgrade |
225 | and fresh_cache[pkg.name].is_upgradable): |
226 | pkgs_upgrade.append(pkg.name) |
227 | - elif (pkg.marked_delete \ |
228 | + elif (pkg.marked_delete |
229 | and fresh_cache[pkg.name].is_installed): |
230 | pkgs_remove.append(pkg.name) |
231 | except KeyError: |
232 | @@ -98,7 +98,7 @@ |
233 | def get_backend(*args, **kwargs): |
234 | """Select and return a package manager backend.""" |
235 | # try aptdaemon |
236 | - if (os.path.exists("/usr/sbin/aptd") \ |
237 | + if (os.path.exists("/usr/sbin/aptd") |
238 | and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ): |
239 | # check if the gtkwidgets are installed as well |
240 | try: |
241 | @@ -108,7 +108,7 @@ |
242 | import logging |
243 | logging.exception("importing aptdaemon") |
244 | # try synaptic |
245 | - if (os.path.exists("/usr/sbin/synaptic") \ |
246 | + if (os.path.exists("/usr/sbin/synaptic") |
247 | and "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ): |
248 | from .InstallBackendSynaptic import InstallBackendSynaptic |
249 | return InstallBackendSynaptic(*args, **kwargs) |
250 | |
251 | === modified file 'debian/changelog' |
252 | --- debian/changelog 2018-09-27 14:16:35 +0000 |
253 | +++ debian/changelog 2018-10-01 16:16:20 +0000 |
254 | @@ -2,14 +2,15 @@ |
255 | |
256 | * Allow unselecting updates and performing only removals (LP: #1792320) |
257 | * Stop trying apt_pkg.pkgsystem_(un)lock(), as a normal user it always fails |
258 | + (LP: #1795387) |
259 | * Keep or delete packages after looping over all of them. |
260 | This prevents the resolver from changing the packages in the loop resulting |
261 | in not keeping some phased packages back from being upgraded. (LP: #1072136) |
262 | - * Fix PEP 8 warnings |
263 | - Also ignore "E502 the backslash is redundant between brackets" because the |
264 | - additional brackets help readability. |
265 | + * Fix PEP 8 warnings (LP: #1795384) |
266 | + Also ignore "W503 line break before binary operator" because it will |
267 | + become the best practice |
268 | |
269 | - -- Balint Reczey <rbalint@ubuntu.com> Thu, 27 Sep 2018 15:19:02 +0200 |
270 | + -- Balint Reczey <rbalint@ubuntu.com> Mon, 01 Oct 2018 18:00:40 +0200 |
271 | |
272 | update-manager (1:18.10.8) cosmic; urgency=medium |
273 | |
274 | |
275 | === modified file 'debian/source_update-manager.py' |
276 | --- debian/source_update-manager.py 2018-09-27 14:15:39 +0000 |
277 | +++ debian/source_update-manager.py 2018-10-01 16:16:20 +0000 |
278 | @@ -27,8 +27,8 @@ |
279 | elif sp.returncode == 10: |
280 | res = out.strip() |
281 | else: |
282 | - res = (b'Error: command ' + str(command).encode() \ |
283 | - + b' failed with exit code ' \ |
284 | + res = (b'Error: command ' + str(command).encode() |
285 | + + b' failed with exit code ' |
286 | + str(sp.returncode).encode() + b': ' + out) |
287 | return res |
288 | |
289 | |
290 | === modified file 'janitor/plugincore/manager.py' |
291 | --- janitor/plugincore/manager.py 2018-09-27 14:15:39 +0000 |
292 | +++ janitor/plugincore/manager.py 2018-10-01 16:16:20 +0000 |
293 | @@ -81,8 +81,8 @@ |
294 | """Find and instantiate all plugins in a module.""" |
295 | def is_plugin(target): |
296 | # Don't return the base class itself. |
297 | - return (inspect.isclass(target) \ |
298 | - and issubclass(target, Plugin) \ |
299 | + return (inspect.isclass(target) |
300 | + and issubclass(target, Plugin) |
301 | and target is not Plugin) |
302 | plugin_classes = [ |
303 | member |
304 | @@ -177,8 +177,8 @@ |
305 | # condition. |
306 | plugins = [ |
307 | plugin for plugin in self._plugins |
308 | - if (plugin.condition == condition \ |
309 | - or condition in plugin.condition \ |
310 | + if (plugin.condition == condition |
311 | + or condition in plugin.condition |
312 | or condition == '*') |
313 | ] |
314 | logging.debug("plugins for condition '{}' are '{}'".format( |
315 | |
316 | === modified file 'janitor/plugincore/plugins/kdelibs4to5_plugin.py' |
317 | --- janitor/plugincore/plugins/kdelibs4to5_plugin.py 2018-09-27 14:15:39 +0000 |
318 | +++ janitor/plugincore/plugins/kdelibs4to5_plugin.py 2018-10-01 16:16:20 +0000 |
319 | @@ -43,7 +43,7 @@ |
320 | fromp = 'kdelibs4-dev' |
321 | top = 'kdelibs5-dev' |
322 | cache = self.app.apt_cache |
323 | - if (fromp in cache and cache[fromp].is_installed \ |
324 | + if (fromp in cache and cache[fromp].is_installed |
325 | and top in cache and not cache[top].is_installed): |
326 | yield MissingPackageCruft( |
327 | cache[top], |
328 | |
329 | === modified file 'janitor/plugincore/plugins/langpack_manual_plugin.py' |
330 | --- janitor/plugincore/plugins/langpack_manual_plugin.py 2018-09-27 14:15:39 +0000 |
331 | +++ janitor/plugincore/plugins/langpack_manual_plugin.py 2018-10-01 16:16:20 +0000 |
332 | @@ -68,9 +68,9 @@ |
333 | # language-support-* - we fix this here |
334 | cache = self.app.apt_cache |
335 | for pkg in cache: |
336 | - if (pkg.name.startswith('language-pack-') \ |
337 | - and not pkg.name.endswith('-base') \ |
338 | - and cache._depcache.IsAutoInstalled(pkg._pkg) \ |
339 | + if (pkg.name.startswith('language-pack-') |
340 | + and not pkg.name.endswith('-base') |
341 | + and cache._depcache.IsAutoInstalled(pkg._pkg) |
342 | and pkg.is_installed): |
343 | # Then... |
344 | logging.debug("setting '%s' to manual installed" % pkg.name) |
345 | |
346 | === modified file 'janitor/plugincore/tests/test_documentation.py' |
347 | --- janitor/plugincore/tests/test_documentation.py 2018-09-27 14:15:39 +0000 |
348 | +++ janitor/plugincore/tests/test_documentation.py 2018-10-01 16:16:20 +0000 |
349 | @@ -34,9 +34,9 @@ |
350 | COMMASPACE = ', ' |
351 | DOT = '.' |
352 | DOCTEST_FLAGS = ( |
353 | - doctest.ELLIPSIS \ |
354 | - | doctest.NORMALIZE_WHITESPACE \ |
355 | - | doctest.REPORT_NDIFF \ |
356 | + doctest.ELLIPSIS |
357 | + | doctest.NORMALIZE_WHITESPACE |
358 | + | doctest.REPORT_NDIFF |
359 | | doctest.IGNORE_EXCEPTION_DETAIL) |
360 | |
361 | |
362 | |
363 | === modified file 'tests/test_hwe_support_status.py' |
364 | --- tests/test_hwe_support_status.py 2018-09-27 14:15:39 +0000 |
365 | +++ tests/test_hwe_support_status.py 2018-10-01 16:16:20 +0000 |
366 | @@ -38,13 +38,13 @@ |
367 | ) |
368 | |
369 | INSTALLED_UNSUPPORTED_HWE_PKG_NAMES = ( |
370 | - INSTALLED_UNSUPPORTED_HWE_KERNEL_PKG_NAMES \ |
371 | + INSTALLED_UNSUPPORTED_HWE_KERNEL_PKG_NAMES |
372 | + INSTALLED_UNSUPPORTED_HWE_XORG_PKG_NAMES) |
373 | |
374 | def setUp(self): |
375 | self.cache = [] |
376 | - INSTALL = (self.INSTALLED_UNSUPPORTED_HWE_PKG_NAMES \ |
377 | - + self.INSTALLED_SUPPORTED_HWE_PKG_NAMES \ |
378 | + INSTALL = (self.INSTALLED_UNSUPPORTED_HWE_PKG_NAMES |
379 | + + self.INSTALLED_SUPPORTED_HWE_PKG_NAMES |
380 | + self.INSTALLED_OTHER_PKG_NAMES) |
381 | for name in INSTALL: |
382 | self.cache.append(make_mock_pkg(name)) |
383 | |
384 | === modified file 'tests/test_pep8.py' |
385 | --- tests/test_pep8.py 2018-09-27 14:15:39 +0000 |
386 | +++ tests/test_pep8.py 2018-10-01 16:16:20 +0000 |
387 | @@ -6,7 +6,7 @@ |
388 | import unittest |
389 | |
390 | # pep8 is overdoing it a bit IMO |
391 | -IGNORE_PEP8 = "E265,E402,E502" |
392 | +IGNORE_PEP8 = "E265,E402,W503" |
393 | IGNORE_FILES = ( |
394 | ) |
395 | |
396 | |
397 | === modified file 'tests/test_update_origin.py' |
398 | --- tests/test_update_origin.py 2018-09-27 14:15:39 +0000 |
399 | +++ tests/test_update_origin.py 2018-10-01 16:16:20 +0000 |
400 | @@ -90,9 +90,9 @@ |
401 | if o.archive == "xenial-security": |
402 | had_security = True |
403 | break |
404 | - if (is_in_updates \ |
405 | - and not is_in_security \ |
406 | - and had_security \ |
407 | + if (is_in_updates |
408 | + and not is_in_security |
409 | + and had_security |
410 | and len(pkg._pkg.version_list) > 2): |
411 | test_pkgs.add(pkg.name) |
412 | self.assertTrue(len(test_pkgs) > 0, |
413 | |
414 | === modified file 'tests/test_utils.py' |
415 | --- tests/test_utils.py 2018-09-27 14:15:39 +0000 |
416 | +++ tests/test_utils.py 2018-10-01 16:16:20 +0000 |
417 | @@ -32,7 +32,7 @@ |
418 | mock.mock_open(read_data=data)) as mock_file: |
419 | assert open("/proc/1/stat").read() == data |
420 | mock_file.assert_called_with("/proc/1/stat") |
421 | - self.assertTrue(utils.is_child_of_process_name("init") \ |
422 | + self.assertTrue(utils.is_child_of_process_name("init") |
423 | or utils.is_child_of_process_name("systemd")) |
424 | self.assertFalse(utils.is_child_of_process_name("mvo")) |
425 |
laney@bionic> pycodestyle . --ignore= E265,E402, W503
laney@bionic>
Great, thanks!