Skip to content

Commit

Permalink
Updating "old" usage of super().
Browse files Browse the repository at this point in the history
Based on Pylint recommendations.
  • Loading branch information
dhermes committed Oct 5, 2020
1 parent 39abab0 commit e92e09b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/python/bezier/_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class Surface(triangle.Triangle):

def __init__(self, *args, **kwargs):
warnings.warn(DEPRECATION_MSG, DeprecationWarning)
super(Surface, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
2 changes: 1 addition & 1 deletion src/python/bezier/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Curve(_base.Base):
)

def __init__(self, nodes, degree, *, copy=True, verify=True):
super(Curve, self).__init__(nodes, copy=copy)
super().__init__(nodes, copy=copy)
self._degree = degree
self._verify_degree(verify)

Expand Down
2 changes: 1 addition & 1 deletion src/python/bezier/hazmat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ class UnsupportedDegree(NotImplementedError):
"""

def __init__(self, degree, supported=()):
super(UnsupportedDegree, self).__init__()
super().__init__()
self.degree = degree
"""int: The degree that the caller attempted to use."""
self.supported = supported
Expand Down
2 changes: 1 addition & 1 deletion src/python/bezier/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Triangle(_base.Base):
)

def __init__(self, nodes, degree, *, copy=True, verify=True):
super(Triangle, self).__init__(nodes, copy=copy)
super().__init__(nodes, copy=copy)
self._degree = degree
self._edges = None
self._verify_degree(verify)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/hazmat/test_triangle_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def test_opposed_tangencies(self):
from bezier.hazmat import algebraic_intersection

with self.assertRaises(NotImplementedError) as exc_info:
super(Test_algebraic_intersect, self).test_opposed_tangencies()
super().test_opposed_tangencies()
exc_args = exc_info.exception.args
self.assertEqual(len(exc_args), 2)
self.assertEqual(exc_args[0], algebraic_intersection._NON_SIMPLE_ERR)
Expand All @@ -975,7 +975,7 @@ def test_tangent_contained(self):
from bezier.hazmat import algebraic_intersection

with self.assertRaises(NotImplementedError) as exc_info:
super(Test_algebraic_intersect, self).test_tangent_contained()
super().test_tangent_contained()
exc_args = exc_info.exception.args
self.assertEqual(len(exc_args), 2)
self.assertEqual(exc_args[0], algebraic_intersection._NON_SIMPLE_ERR)
Expand Down
12 changes: 5 additions & 7 deletions tests/unit/test__triangle_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,19 @@ def _evaluate_cartesian_multi(nodes, degree, param_vals, dimension):
# the original to remove the ``@pytest.mark.slow`` decorator.
# pylint: disable=useless-super-delegation
def test_line_check_evaluate(self):
super(Test_speedup_subdivide_nodes, self).test_line_check_evaluate()
super().test_line_check_evaluate()

def test_quadratic_check_evaluate(self):
super(
Test_speedup_subdivide_nodes, self
).test_quadratic_check_evaluate()
super().test_quadratic_check_evaluate()

def test_cubic_check_evaluate(self):
super(Test_speedup_subdivide_nodes, self).test_cubic_check_evaluate()
super().test_cubic_check_evaluate()

def test_quartic_check_evaluate(self):
super(Test_speedup_subdivide_nodes, self).test_quartic_check_evaluate()
super().test_quartic_check_evaluate()

def test_on_the_fly(self):
super(Test_speedup_subdivide_nodes, self).test_on_the_fly()
super().test_on_the_fly()

# pylint: enable=useless-super-delegation

Expand Down
6 changes: 2 additions & 4 deletions tests/unit/test__triangle_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ def test_two_curved_polygons(self):
segment_ends_size, segments_size = sizes
self.assertGreaterEqual(segment_ends_size, 2)
self.assertGreaterEqual(segments_size, 6)
super_ = super(Test_speedup_geometric_intersect, self)
super_.test_two_curved_polygons()
super().test_two_curved_polygons()
# Make sure the workspace was **not** resized.
self.assertEqual(triangle_workspace_sizes(), sizes)

def test_resize_both(self):
reset_triangle_workspaces(segment_ends_size=1, segments_size=1)
super_ = super(Test_speedup_geometric_intersect, self)
super_.test_two_curved_polygons()
super().test_two_curved_polygons()
# Make sure the sizes were resized from (1, 1).
self.assertEqual(triangle_workspace_sizes(), (2, 6))

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class NumPyTestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
import numpy as np

super(NumPyTestCase, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.addTypeEqualityFunc(np.ndarray, self.assertArrayEqual)

def assertArrayEqual(self, arr1, arr2, msg=None):
Expand Down

0 comments on commit e92e09b

Please sign in to comment.