Repository: mlflow/mlflow

Issue:
Call `super()` without arguments
🚨 When you work on this issue, please make sure the following 🚨

- Follow https://opensource.com/article/19/7/create-pull-request-github if you're unfamiliar with how to create a pull request on GitHub.
- Create a PR from a non-master branch.
- Do not create commits on GitHub UI. [The DCO bot](https://github.com/apps/dco) doesn't work well with commits created on GitHub UI.
- Sign off your commits by using the `-s` flag (e.g. `git commit -s -m "fix typo"`).
- Reference this issue in the PR with `Close #5987`.
- Do not modify the PR template because our CI checks will fail.
- Ping me before you start working on this issue.

---

We don't support Python 2 anymore and need to call `super()` with arguments. For example,

https://github.com/mlflow/mlflow/blob/ba6312ab000ddd165b0973342aec11760f6879a5/tests/onnx/test_onnx_model_export.py#L109

can be fixed to:

```
            super(MyModel, self).__init__() 
```


The following files contain `super()` called with arguments:

```
> pylint --enable super-with-arguments $(git ls-files | grep '\.py$')
************* Module mlflow.sagemaker
mlflow/sagemaker/__init__.py:1801:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module mlflow.sklearn
mlflow/sklearn/__init__.py:492:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module mlflow.utils.autologging_utils.safety
mlflow/utils/autologging_utils/safety.py:225:16: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
mlflow/utils/autologging_utils/safety.py:232:25: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
mlflow/utils/autologging_utils/safety.py:244:16: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module test_onnx_model_export
tests/onnx/test_onnx_model_export.py:109:12: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module test_paddle_model_export
tests/paddle/test_paddle_model_export.py:58:12: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
tests/paddle/test_paddle_model_export.py:280:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
```


Discussion:
Hey @harupy  I would like to work on this issue.
@Regis-Caelum thanks!

Resolving patch:
diff --git a/mlflow/sagemaker/__init__.py b/mlflow/sagemaker/__init__.py
--- a/mlflow/sagemaker/__init__.py
+++ b/mlflow/sagemaker/__init__.py
@@ -1798,7 +1798,7 @@ class SageMakerDeploymentClient(BaseDeploymentClient):
     """
 
     def __init__(self, target_uri):
-        super(SageMakerDeploymentClient, self).__init__(target_uri=target_uri)
+        super().__init__(target_uri=target_uri)
 
         # Default region_name and assumed_role_arn when
         # the target_uri is `sagemaker` or `sagemaker:/`
diff --git a/mlflow/sklearn/__init__.py b/mlflow/sklearn/__init__.py
--- a/mlflow/sklearn/__init__.py
+++ b/mlflow/sklearn/__init__.py
@@ -489,7 +489,7 @@ def __init__(self, sk_model, original_exception):
         :param sk_model: The custom sklearn model to be pickled
         :param original_exception: The original exception raised
         """
-        super(_SklearnCustomModelPicklingError, self).__init__(
+        super().__init__(
             f"Pickling custom sklearn model {sk_model.__class__.__name__} failed "
             f"when saving model: {str(original_exception)}"
         )
diff --git a/mlflow/utils/autologging_utils/safety.py b/mlflow/utils/autologging_utils/safety.py
--- a/mlflow/utils/autologging_utils/safety.py
+++ b/mlflow/utils/autologging_utils/safety.py
@@ -222,16 +222,14 @@ def create_managed_run():
 
         class PatchWithManagedRun(patch_function):
             def __init__(self):
-                super(PatchWithManagedRun, self).__init__()
+                super().__init__()
                 self.managed_run = None
 
             def _patch_implementation(self, original, *args, **kwargs):
                 if not mlflow.active_run():
                     self.managed_run = create_managed_run()
 
-                result = super(PatchWithManagedRun, self)._patch_implementation(
-                    original, *args, **kwargs
-                )
+                result = super()._patch_implementation(original, *args, **kwargs)
 
                 if self.managed_run:
                     mlflow.end_run(RunStatus.to_string(RunStatus.FINISHED))
@@ -241,7 +239,7 @@ def _patch_implementation(self, original, *args, **kwargs):
             def _on_exception(self, e):
                 if self.managed_run:
                     mlflow.end_run(RunStatus.to_string(RunStatus.FAILED))
-                super(PatchWithManagedRun, self)._on_exception(e)
+                super()._on_exception(e)
 
         return PatchWithManagedRun
 


Test patch:
diff --git a/tests/onnx/test_onnx_model_export.py b/tests/onnx/test_onnx_model_export.py
--- a/tests/onnx/test_onnx_model_export.py
+++ b/tests/onnx/test_onnx_model_export.py
@@ -106,7 +106,7 @@ def onnx_model(model, sample_input, tmpdir):
 def multi_tensor_model(dataset):
     class MyModel(nn.Module):
         def __init__(self, n):
-            super(MyModel, self).__init__()
+            super().__init__()
             self.linear = torch.nn.Linear(n, 1)
             self._train = True
 
diff --git a/tests/paddle/test_paddle_model_export.py b/tests/paddle/test_paddle_model_export.py
--- a/tests/paddle/test_paddle_model_export.py
+++ b/tests/paddle/test_paddle_model_export.py
@@ -55,7 +55,7 @@ def get_dataset():
 def pd_model():
     class Regressor(paddle.nn.Layer):
         def __init__(self, in_features):
-            super(Regressor, self).__init__()
+            super().__init__()
             self.fc_ = Linear(in_features=in_features, out_features=1)
 
         @paddle.jit.to_static
@@ -277,7 +277,7 @@ def get_dataset_built_in_high_level_api():
 
 class UCIHousing(paddle.nn.Layer):
     def __init__(self):
-        super(UCIHousing, self).__init__()
+        super().__init__()
         self.fc_ = paddle.nn.Linear(13, 1, None)
 
     def forward(self, inputs):  # pylint: disable=arguments-differ