Merge ~cjwatson/lazr.sshserver:pyupgrade into lazr.sshserver:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 15d3b420dc7e4e34241d71f171a3f56097b23bc0
Proposed branch: ~cjwatson/lazr.sshserver:pyupgrade
Merge into: lazr.sshserver:main
Diff against target: 323 lines (+20/-53)
14 files modified
.pre-commit-config.yaml (+4/-0)
src/lazr/sshserver/__init__.py (+0/-1)
src/lazr/sshserver/accesslog.py (+0/-3)
src/lazr/sshserver/auth.py (+1/-4)
src/lazr/sshserver/events.py (+0/-3)
src/lazr/sshserver/service.py (+1/-4)
src/lazr/sshserver/session.py (+1/-4)
src/lazr/sshserver/sftp.py (+1/-6)
src/lazr/sshserver/tests/__init__.py (+0/-1)
src/lazr/sshserver/tests/test_accesslog.py (+2/-6)
src/lazr/sshserver/tests/test_auth.py (+7/-11)
src/lazr/sshserver/tests/test_events.py (+1/-5)
src/lazr/sshserver/tests/test_session.py (+1/-5)
tox.ini (+1/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+437443@code.launchpad.net

Commit message

Run pyupgrade

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

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 0837591..76be99b 100644
3--- a/.pre-commit-config.yaml
4+++ b/.pre-commit-config.yaml
5@@ -14,6 +14,10 @@ repos:
6 - id: debug-statements
7 - id: end-of-file-fixer
8 - id: trailing-whitespace
9+- repo: https://github.com/asottile/pyupgrade
10+ rev: v3.3.1
11+ hooks:
12+ - id: pyupgrade
13 - repo: https://github.com/psf/black
14 rev: 22.12.0
15 hooks:
16diff --git a/src/lazr/sshserver/__init__.py b/src/lazr/sshserver/__init__.py
17index f688203..a8bf348 100644
18--- a/src/lazr/sshserver/__init__.py
19+++ b/src/lazr/sshserver/__init__.py
20@@ -16,7 +16,6 @@
21
22 "The lazr.sshserver package."
23
24-__metaclass__ = type
25 __all__ = []
26
27 try:
28diff --git a/src/lazr/sshserver/accesslog.py b/src/lazr/sshserver/accesslog.py
29index c18c7a9..b4f04be 100644
30--- a/src/lazr/sshserver/accesslog.py
31+++ b/src/lazr/sshserver/accesslog.py
32@@ -3,9 +3,6 @@
33
34 """Logging for the SSH server."""
35
36-from __future__ import absolute_import, print_function
37-
38-__metaclass__ = type
39 __all__ = [
40 "LoggingManager",
41 ]
42diff --git a/src/lazr/sshserver/auth.py b/src/lazr/sshserver/auth.py
43index 8bfc634..84aabac 100644
44--- a/src/lazr/sshserver/auth.py
45+++ b/src/lazr/sshserver/auth.py
46@@ -9,9 +9,6 @@ Launchpad's SSH server authenticates users against a XML-RPC service (see
47 case of failed authentication (see `SSHUserAuthServer`).
48 """
49
50-from __future__ import absolute_import, print_function
51-
52-__metaclass__ = type
53 __all__ = [
54 "LaunchpadAvatar",
55 "PublicKeyFromLaunchpadChecker",
56@@ -53,7 +50,7 @@ class NoSuchPersonWithName(xmlrpc.Fault):
57 msg_template = "No such person or team: %(person_name)s"
58
59 def __init__(self, person_name):
60- super(NoSuchPersonWithName, self).__init__(
61+ super().__init__(
62 self.error_code, self.msg_template % {"person_name": person_name}
63 )
64
65diff --git a/src/lazr/sshserver/events.py b/src/lazr/sshserver/events.py
66index 5d0165b..c58d59a 100644
67--- a/src/lazr/sshserver/events.py
68+++ b/src/lazr/sshserver/events.py
69@@ -3,9 +3,6 @@
70
71 """Events generated by the SSH server."""
72
73-from __future__ import absolute_import, print_function
74-
75-__metaclass__ = type
76 __all__ = [
77 "AuthenticationFailed",
78 "AvatarEvent",
79diff --git a/src/lazr/sshserver/service.py b/src/lazr/sshserver/service.py
80index 2d0622f..f9a8960 100644
81--- a/src/lazr/sshserver/service.py
82+++ b/src/lazr/sshserver/service.py
83@@ -6,9 +6,6 @@
84 An `SSHService` object can be used to launch the SSH server.
85 """
86
87-from __future__ import absolute_import, print_function
88-
89-__metaclass__ = type
90 __all__ = [
91 "SSHService",
92 ]
93@@ -148,7 +145,7 @@ class Factory(SSHFactory):
94 try:
95 if self._moduli_path is not None:
96 return primes.parseModuliFile(self._moduli_path)
97- except IOError:
98+ except OSError:
99 pass
100 return None
101
102diff --git a/src/lazr/sshserver/session.py b/src/lazr/sshserver/session.py
103index cdeefc3..3168895 100644
104--- a/src/lazr/sshserver/session.py
105+++ b/src/lazr/sshserver/session.py
106@@ -3,9 +3,6 @@
107
108 """Patched SSH session for the Launchpad server."""
109
110-from __future__ import absolute_import, print_function
111-
112-__metaclass__ = type
113 __all__ = [
114 "DoNothingSession",
115 "PatchedSSHSession",
116@@ -16,7 +13,7 @@ from twisted.conch.ssh import channel, connection, session
117 from zope.interface import implementer
118
119
120-class PatchedSSHSession(session.SSHSession, object):
121+class PatchedSSHSession(session.SSHSession):
122 """Session adapter that corrects bugs in Conch.
123
124 This object provides no custom logic for Launchpad, it just addresses some
125diff --git a/src/lazr/sshserver/sftp.py b/src/lazr/sshserver/sftp.py
126index 1335ce8..3fa6026 100644
127--- a/src/lazr/sshserver/sftp.py
128+++ b/src/lazr/sshserver/sftp.py
129@@ -3,9 +3,6 @@
130
131 """Generic SFTP server functionality."""
132
133-from __future__ import absolute_import, print_function
134-
135-__metaclass__ = type
136 __all__ = [
137 "FileIsADirectory",
138 "FileTransferServer",
139@@ -25,9 +22,7 @@ class FileIsADirectory(Exception):
140
141 def __init__(self, path, extra=None):
142 self.path = path
143- super(FileIsADirectory, self).__init__(
144- "File is a directory: %r" % path
145- )
146+ super().__init__("File is a directory: %r" % path)
147
148
149 class FileTransferServer(filetransfer.FileTransferServer):
150diff --git a/src/lazr/sshserver/tests/__init__.py b/src/lazr/sshserver/tests/__init__.py
151index fde15ac..126b89a 100644
152--- a/src/lazr/sshserver/tests/__init__.py
153+++ b/src/lazr/sshserver/tests/__init__.py
154@@ -16,5 +16,4 @@
155
156 "The lazr.sshserver tests."
157
158-__metaclass__ = type
159 __all__ = []
160diff --git a/src/lazr/sshserver/tests/test_accesslog.py b/src/lazr/sshserver/tests/test_accesslog.py
161index f855def..d921345 100644
162--- a/src/lazr/sshserver/tests/test_accesslog.py
163+++ b/src/lazr/sshserver/tests/test_accesslog.py
164@@ -3,10 +3,6 @@
165
166 """Tests for the logging system of the sshserver."""
167
168-from __future__ import absolute_import, print_function
169-
170-__metaclass__ = type
171-
172 import logging
173 import os
174 import sys
175@@ -29,7 +25,7 @@ class LoggingManagerMixin:
176 def makeLogger(self, name=None):
177 if name is None:
178 self._log_count += 1
179- name = "%s-%s" % (self.id().split(".")[-1], self._log_count)
180+ name = "{}-{}".format(self.id().split(".")[-1], self._log_count)
181 return logging.getLogger(name)
182
183 def installLoggingManager(
184@@ -57,7 +53,7 @@ class TestLoggingBreezyInteraction(BrzTestCase, LoggingManagerMixin):
185 directory = self.useFixture(fixtures.TempDir()).path
186 self.overrideEnv("BRZ_LOG", os.path.join(directory, "brz.log"))
187 breezy.get_global_state()
188- super(TestLoggingBreezyInteraction, self).setUp()
189+ super().setUp()
190
191 def test_leaves_brz_handlers_unchanged(self):
192 # Breezy's log handling is untouched by logging setup.
193diff --git a/src/lazr/sshserver/tests/test_auth.py b/src/lazr/sshserver/tests/test_auth.py
194index adea2c4..658b979 100644
195--- a/src/lazr/sshserver/tests/test_auth.py
196+++ b/src/lazr/sshserver/tests/test_auth.py
197@@ -1,10 +1,6 @@
198 # Copyright 2009-2018 Canonical Ltd. This software is licensed under the
199 # GNU Lesser General Public License version 3 (see the file LICENSE).
200
201-from __future__ import absolute_import, print_function
202-
203-__metaclass__ = type
204-
205 import base64
206 import functools
207 import io
208@@ -101,9 +97,9 @@ class MockSSHTransport(SSHServerTransport):
209 pass
210
211
212-class UserAuthServerMixin(object):
213+class UserAuthServerMixin:
214 def setUp(self):
215- super(UserAuthServerMixin, self).setUp()
216+ super().setUp()
217 self.portal = Portal(MockRealm())
218 self.transport = MockSSHTransport(self.portal)
219 self.user_auth = auth.SSHUserAuthServer(self.transport)
220@@ -219,7 +215,7 @@ class TestUserAuthServer(UserAuthServerMixin, testtools.TestCase):
221 # An initial SSH_MSG_USERAUTH_REQUEST packet may be sent without a
222 # signature to query whether publickey authentication would be
223 # acceptable. See RFC 4252, Section 7.
224- class MockLogin(object):
225+ class MockLogin:
226 def __init__(self, portal):
227 self.portal = portal
228
229@@ -255,7 +251,7 @@ class TestUserAuthServer(UserAuthServerMixin, testtools.TestCase):
230 def test_worksAroundShortParamikoSignatures(self):
231 # paramiko < 2.0.0 truncates RSA signatures whose most significant
232 # byte is zero. auth_publickey tolerates this.
233- class MockLogin(object):
234+ class MockLogin:
235 def __init__(self, portal):
236 self.portal = portal
237
238@@ -331,14 +327,14 @@ class TestAuthenticationBannerDisplay(UserAuthServerMixin, testtools.TestCase):
239 run_tests_with = AsynchronousDeferredRunTest
240
241 def setUp(self):
242- super(TestAuthenticationBannerDisplay, self).setUp()
243+ super().setUp()
244 self.portal.registerChecker(MockChecker())
245 self.user_auth.serviceStarted()
246 self.key_data = self._makeKey()
247
248 def tearDown(self):
249 self.user_auth.serviceStopped()
250- super(TestAuthenticationBannerDisplay, self).tearDown()
251+ super().tearDown()
252
253 def _makeKey(self):
254 keydir = sibpath(__file__, "keys")
255@@ -524,7 +520,7 @@ class TestPublicKeyFromLaunchpadChecker(testtools.TestCase):
256 return failure.Failure(UnauthorizedLogin())
257
258 def setUp(self):
259- super(TestPublicKeyFromLaunchpadChecker, self).setUp()
260+ super().setUp()
261 self.authserver = self.FakeAuthenticationEndpoint()
262
263 @defer.inlineCallbacks
264diff --git a/src/lazr/sshserver/tests/test_events.py b/src/lazr/sshserver/tests/test_events.py
265index a3e790a..fc6582e 100644
266--- a/src/lazr/sshserver/tests/test_events.py
267+++ b/src/lazr/sshserver/tests/test_events.py
268@@ -3,10 +3,6 @@
269
270 """Tests for the logging events."""
271
272-from __future__ import absolute_import, print_function
273-
274-__metaclass__ = type
275-
276 import logging
277
278 import testtools
279@@ -62,7 +58,7 @@ class TestLoggingEvent(testtools.TestCase):
280 self.assertLogs([record], notify, logging_event)
281
282 def setUp(self):
283- super(TestLoggingEvent, self).setUp()
284+ super().setUp()
285 logger = logging.getLogger(self.getUniqueString())
286 logger.setLevel(logging.DEBUG)
287 self.logger = logger
288diff --git a/src/lazr/sshserver/tests/test_session.py b/src/lazr/sshserver/tests/test_session.py
289index aebc200..388944b 100644
290--- a/src/lazr/sshserver/tests/test_session.py
291+++ b/src/lazr/sshserver/tests/test_session.py
292@@ -3,10 +3,6 @@
293
294 """Tests for generic SSH session support."""
295
296-from __future__ import absolute_import, print_function
297-
298-__metaclass__ = type
299-
300 import testtools
301 from twisted.conch.interfaces import ISession
302 from twisted.conch.ssh import connection
303@@ -51,7 +47,7 @@ class TestDoNothing(testtools.TestCase):
304 """Tests for DoNothingSession."""
305
306 def setUp(self):
307- super(TestDoNothing, self).setUp()
308+ super().setUp()
309 self.session = DoNothingSession(None)
310
311 def test_getPtyIsANoOp(self):
312diff --git a/tox.ini b/tox.ini
313index b8f1aca..16b91cd 100644
314--- a/tox.ini
315+++ b/tox.ini
316@@ -13,6 +13,7 @@ commands =
317 deps =
318 .[test]
319 py35: breezy<3.2.0
320+ py36: breezy<3.3.0
321
322 [testenv:lint]
323 basepython =

Subscribers

People subscribed via source and target branches