Skip to content

Commit

Permalink
Remove super() with args
Browse files Browse the repository at this point in the history
As well as some related format change, removing unimported.

Bug: chromium:1408280
Change-Id: I6ae08c2d1244e3ed005ff0cbb0a33b2d07602363
Reviewed-on: https://chromium-review.googlesource.com/c/catapult/+/4185396
Reviewed-by: Sean McCullough <[email protected]>
Commit-Queue: Funing Wang <[email protected]>
  • Loading branch information
funingg authored and Catapult LUCI CQ committed Jan 24, 2023
1 parent c95933a commit 45986b0
Show file tree
Hide file tree
Showing 146 changed files with 339 additions and 1,163 deletions.
2 changes: 1 addition & 1 deletion catapult_build/run_with_typ.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion catapult_build/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion common/bin/run_tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion common/bin/update_chrome_reference_binaries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
#
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
Expand Down
2 changes: 1 addition & 1 deletion common/py_trace_event/bin/run_tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion common/py_trace_event/py_trace_event/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

class ProcessSubclass(_RealProcess):
def __init__(self, shim, *args, **kwards):
multiprocessing.get_context("forkserver")
_RealProcess.__init__(self, *args, **kwards)
self._shim = shim

def run(self,*args,**kwargs):
def run(self, *args, **kwargs):
from . import log
log._disallow_tracing_control()
try:
Expand Down
12 changes: 7 additions & 5 deletions common/py_trace_event/py_trace_event/trace_event_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def _test_trace(self, disable=True, format=None):
if disable:
trace_event.trace_disable()

def child(resp):
# test tracing is not controllable in the child
resp.put(trace_event.is_tracing_controllable())

def testNoImpl(self):
orig_impl = trace_event.trace_event_impl
try:
Expand Down Expand Up @@ -396,14 +400,12 @@ def child_function():
self.assertEquals(parent_close['ph'], 'E')

@unittest.skipIf(sys.platform == 'win32', 'crbug.com/945819')
@unittest.skipIf(sys.version_info[0] == 3, 'Python3 pickle issue')
# TODO: Upgrade PY3 version and activate it
def testTracingControlDisabledInChildButNotInParent(self):
def child(resp):
# test tracing is not controllable in the child
resp.put(trace_event.is_tracing_controllable())

with self._test_trace():
q = multiprocessing.Queue()
p = multiprocessing.Process(target=child, args=[q])
p = multiprocessing.Process(target=self.child, args=[q])
p.start()
# test tracing is controllable in the parent
self.assertTrue(trace_event.is_tracing_controllable())
Expand Down
2 changes: 1 addition & 1 deletion common/py_utils/bin/run_tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
8 changes: 2 additions & 6 deletions common/py_utils/py_utils/cloud_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,15 @@ def _GetConfigInstructions():
class PermissionError(CloudStorageError):

def __init__(self):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(PermissionError, self).__init__(
super().__init__(
'Attempted to access a file from Cloud Storage but you don\'t '
'have permission. ' + self._GetConfigInstructions())


class CredentialsError(CloudStorageError):

def __init__(self):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(CredentialsError, self).__init__(
super().__init__(
'Attempted to access a file from Cloud Storage but you have no '
'configured credentials. ' + self._GetConfigInstructions())

Expand Down
8 changes: 2 additions & 6 deletions common/py_utils/py_utils/cloud_storage_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,12 @@ def CleanTimeStampFile():
class GetIfChangedTests(BaseFakeFsUnitTest):

def setUp(self):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(GetIfChangedTests, self).setUp()
super().setUp()
self._orig_read_hash = cloud_storage.ReadHash
self._orig_calculate_hash = cloud_storage.CalculateHash

def tearDown(self):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(GetIfChangedTests, self).tearDown()
super().tearDown()
cloud_storage.CalculateHash = self._orig_calculate_hash
cloud_storage.ReadHash = self._orig_read_hash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,20 @@

class AnnotatedSymbol(snippet.Symbol):
def __init__(self, symbol_type, children):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AnnotatedSymbol, self).__init__(symbol_type, children)
super().__init__(symbol_type, children)
self._modified = False

@property
def modified(self):
if self._modified:
return True
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
return super(AnnotatedSymbol, self).modified
return super().modified

def __setattr__(self, name, value):
if (hasattr(self.__class__, name) and
isinstance(getattr(self.__class__, name), property)):
self._modified = True
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
return super(AnnotatedSymbol, self).__setattr__(name, value)
return super().__setattr__(name, value)

def Cut(self, child):
for i in range(len(self._children)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def Annotate(cls, nodes):
return [cls(nodes[:i])] + nodes[i:]

def __init__(self, children):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(Reference, self).__init__(-1, children)
super().__init__(-1, children)

@property
def type_name(self):
Expand Down
4 changes: 1 addition & 3 deletions common/py_utils/py_utils/slots_metaclass_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class NaughtyClass2(NiceClass):
__slots__ = ()

def __init__(self, naughty):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(NaughtyClass2, self).__init__(42)
super().__init__(42)
self._naughty = naughty # pylint: disable=assigning-non-slot

# SlotsMetaclass is happy that __slots__ is defined, but python won't be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@ def __init__(self):

class DummyExceptionWithParameterImpl1(_PrivateDummyException):
def __init__(self, parameter):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(DummyExceptionWithParameterImpl1, self).__init__()
super().__init__()
del parameter
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@

class DummyExceptionWithParameterImpl2(discover_dummyclass.DummyException):
def __init__(self, parameter1, parameter2):
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(DummyExceptionWithParameterImpl2, self).__init__()
super().__init__()
del parameter1, parameter2
4 changes: 1 addition & 3 deletions common/py_utils/py_utils/webpagereplay_go_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def __init__(self, label, path):
path: A string of the path in this error.
"""
# TODO(https://crbug.com/1262295): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(ReplayNotFoundError, self).__init__()
super().__init__()
self.args = (label, path)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion common/py_vulcanize/bin/run_py_tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env vpython3
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
8 changes: 2 additions & 6 deletions dashboard/bq_export/bq_export/split_by_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def __init__(self,
:timestamp_property: a str of the name of the timestamp property to filter
on.
"""
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(ReadTimestampRangeFromDatastore, self).__init__()
super().__init__()
self._query_params = query_params
self._time_range_provider = time_range_provider
self._step = step
Expand All @@ -71,9 +69,7 @@ def expand(self, pcoll): # pylint: disable=invalid-name
class _QueryFn(beam.DoFn):

def __init__(self, query_params, timestamp_property):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(ReadTimestampRangeFromDatastore._QueryFn, self).__init__()
super().__init__()
self._query_params = query_params
self._timestamp_property = timestamp_property

Expand Down
29 changes: 4 additions & 25 deletions dashboard/dashboard/add_histograms_queue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from flask import Flask
import json
import mock
import six
if six.PY2:
import webapp2
import sys
import uuid
import webtest
Expand Down Expand Up @@ -89,17 +86,8 @@ def AddHistogramsQueuePost():
class AddHistogramsQueueTest(testing_common.TestCase):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AddHistogramsQueueTest, self).setUp()
if six.PY2:
app = webapp2.WSGIApplication([
('/add_histograms_queue',
add_histograms_queue.AddHistogramsQueueHandler)
])
self.testapp = webtest.TestApp(app)
else:
self.testapp = webtest.TestApp(flask_app)
super().setUp()
self.testapp = webtest.TestApp(flask_app)
self.SetCurrentUser('[email protected]', is_admin=True)

def testPostHistogram(self):
Expand Down Expand Up @@ -633,17 +621,8 @@ def testCreateRowEntities_DoesNotAddTraceUriIfDiagnosticIsEmpty(self):
class AddHistogramsQueueTestWithUploadCompletionToken(testing_common.TestCase):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AddHistogramsQueueTestWithUploadCompletionToken, self).setUp()
if six.PY2:
app = webapp2.WSGIApplication([
('/add_histograms_queue',
add_histograms_queue.AddHistogramsQueueHandler)
])
self.testapp = webtest.TestApp(app)
else:
self.testapp = webtest.TestApp(flask_app)
super().setUp()
self.testapp = webtest.TestApp(flask_app)
testing_common.SetIsInternalUser('[email protected]', True)
self.SetCurrentUser('[email protected]')

Expand Down
24 changes: 3 additions & 21 deletions dashboard/dashboard/add_histograms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import mock
import random
import six
if six.PY2:
import webapp2
import string
import sys
import unittest
Expand Down Expand Up @@ -192,21 +190,8 @@ def UploadsInfoGet(token_id):
class AddHistogramsBaseTest(testing_common.TestCase):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AddHistogramsBaseTest, self).setUp()
if six.PY2:
app = webapp2.WSGIApplication([
('/add_histograms', add_histograms.AddHistogramsHandler),
('/add_histograms/process',
add_histograms.AddHistogramsProcessHandler),
('/add_histograms_queue',
add_histograms_queue.AddHistogramsQueueHandler),
('/uploads/(.+)', uploads_info.UploadInfoHandler),
])
self.testapp = webtest.TestApp(app)
else:
self.testapp = webtest.TestApp(flask_app)
super().setUp()
self.testapp = webtest.TestApp(flask_app)
testing_common.SetIsInternalUser('[email protected]', True)
self.SetCurrentUser('[email protected]', is_admin=True)
oauth_patcher = mock.patch.object(api_auth, 'oauth')
Expand Down Expand Up @@ -1645,10 +1630,7 @@ def testLogDebugInfo_NoLogUrls(self, mock_log):
class AddHistogramsUploadCompleteonTokenTest(AddHistogramsBaseTest):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AddHistogramsUploadCompleteonTokenTest, self).setUp()

super().setUp()
self._TrunOnUploadCompletionTokenExperiment()
hs = _CreateHistogram(
master='master',
Expand Down
4 changes: 1 addition & 3 deletions dashboard/dashboard/add_point_queue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
class GetOrCreateAncestorsTest(testing_common.TestCase):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(GetOrCreateAncestorsTest, self).setUp()
super().setUp()
self.SetCurrentUser('[email protected]', is_admin=True)

def testGetOrCreateAncestors_GetsExistingEntities(self):
Expand Down
14 changes: 2 additions & 12 deletions dashboard/dashboard/add_point_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import mock
import six
if six.PY2:
import webapp2
import webtest

from google.appengine.api import datastore_errors
Expand Down Expand Up @@ -197,16 +195,8 @@ def AddPointQueuePost():
class AddPointTest(testing_common.TestCase):

def setUp(self):
# TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire.
# pylint: disable=super-with-arguments
super(AddPointTest, self).setUp()
if six.PY2:
app = webapp2.WSGIApplication([('/add_point', add_point.AddPointHandler),
('/add_point_queue',
add_point_queue.AddPointQueueHandler)])
self.testapp = webtest.TestApp(app)
else:
self.testapp = webtest.TestApp(flask_app)
super().setUp()
self.testapp = webtest.TestApp(flask_app)
units_to_direction.UpdateFromJson(_UNITS_TO_DIRECTION_DICT)
self.SetCurrentUser(
'[email protected]', is_admin=True)
Expand Down
Loading

0 comments on commit 45986b0

Please sign in to comment.