jd / tenacity

Retrying library for Python
http://tenacity.readthedocs.io
Apache License 2.0
6.75k stars 281 forks source link

MyPy 1.8.0 don't recognize `tenacity.Retrying()` as a callable #428

Open hussein-awala opened 10 months ago

hussein-awala commented 10 months ago

I'm trying to update MyPy version in Airflow to 1.8.0, but I'm getting a strange error when I run it on this code:

def run_with_advanced_retry(self, _retry_args: dict[Any, Any], *args: Any, **kwargs: Any) -> Any:
    self._retry_obj = tenacity.Retrying(**_retry_args)
    return self._retry_obj(self.run, *args, **kwargs)

The error is the following:

airflow/providers/http/hooks/http.py:247: error: Never not callable  [misc]
            return self._retry_obj(self.run, *args, **kwargs)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1838 source files)
Error 1 returned
rudolfbyker commented 9 months ago

Shouldn't this

def run_with_advanced_retry(self, _retry_args: dict[Any, Any], *args: Any, **kwargs: Any) -> Any:
    self._retry_obj = tenacity.Retrying(**_retry_args)
    return self._retry_obj(self.run, *args, **kwargs)

rather be this

def run_with_advanced_retry(self, _retry_args: dict[Any, Any], *args: Any, **kwargs: Any) -> Any:
    self._retry_obj = tenacity.Retrying(**_retry_args)
    return self._retry_obj(self.run)(*args, **kwargs)

? :)

hussein-awala commented 8 months ago

@rudolfbyker I tested it and still have the same issue:

airflow/providers/http/hooks/http.py:261: error: Never not callable  [misc]
            return self._retry_obj(self.run)(*args, **kwargs)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
Error 1 returned