Merge ~cjwatson/launchpadlib:pyupgrade into launchpadlib:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 5ecb0dd8bc968420496fe33bbf0130bc1046a758
Proposed branch: ~cjwatson/launchpadlib:pyupgrade
Merge into: launchpadlib:main
Diff against target: 46 lines (+7/-6)
3 files modified
.pre-commit-config.yaml (+5/-0)
src/launchpadlib/launchpad.py (+1/-3)
src/launchpadlib/testing/launchpad.py (+1/-3)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+412003@code.launchpad.net

Commit message

Apply pyupgrade

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Personally I like the % and f-string formatting and the format thing not so much.

I would have ran pyupgrade with `--keep-percent-format` until we are on Python 3.6 and use f-strings, but as I said this is a very personal thing, and certainly no blocker :-)

LGTM!

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Fine by me. I've added `--keep-percent-format` - how's this?

Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Excellent :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
2index fe333f3..7304ab5 100644
3--- a/.pre-commit-config.yaml
4+++ b/.pre-commit-config.yaml
5@@ -15,6 +15,11 @@ repos:
6 rev: 3.9.2
7 hooks:
8 - id: flake8
9+- repo: https://github.com/asottile/pyupgrade
10+ rev: v2.29.0
11+ hooks:
12+ - id: pyupgrade
13+ args: [--keep-percent-format]
14 - repo: https://github.com/psf/black
15 rev: 21.9b0
16 hooks:
17diff --git a/src/launchpadlib/launchpad.py b/src/launchpadlib/launchpad.py
18index cbe5cbd..9363d9b 100644
19--- a/src/launchpadlib/launchpad.py
20+++ b/src/launchpadlib/launchpad.py
21@@ -243,9 +243,7 @@ class Launchpad(ServiceRoot):
22
23 @classmethod
24 def _is_sudo(cls):
25- return set(["SUDO_USER", "SUDO_UID", "SUDO_GID"]) & set(
26- os.environ.keys()
27- )
28+ return {"SUDO_USER", "SUDO_UID", "SUDO_GID"} & set(os.environ.keys())
29
30 @classmethod
31 def authorization_engine_factory(cls, *args):
32diff --git a/src/launchpadlib/testing/launchpad.py b/src/launchpadlib/testing/launchpad.py
33index c3d65bc..a97b995 100644
34--- a/src/launchpadlib/testing/launchpad.py
35+++ b/src/launchpadlib/testing/launchpad.py
36@@ -411,9 +411,7 @@ class FakeResource(object):
37 name or if C{value}'s type is not valid for the attribute.
38 """
39 representation = self._application.representation_definitions[xml_id]
40- parameters = dict(
41- (child.get("name"), child) for child in representation.tag
42- )
43+ parameters = {child.get("name"): child for child in representation.tag}
44 if name not in parameters:
45 raise IntegrityError("%s not found" % name)
46 parameter = parameters[name]

Subscribers

People subscribed via source and target branches