Skip to content

Comments

stop, retry: add compatibility wrappers for __call__ methods#140

Merged
mergify[bot] merged 1 commit intojd:masterfrom
immerrr:add-backward-compatibility-for-cb-classes
Aug 20, 2018
Merged

stop, retry: add compatibility wrappers for __call__ methods#140
mergify[bot] merged 1 commit intojd:masterfrom
immerrr:add-backward-compatibility-for-cb-classes

Conversation

@immerrr
Copy link
Contributor

@immerrr immerrr commented Aug 19, 2018

They can be called side-stepping the "primary" backward compatibility shim
provided by BaseRetrying class, for example when an inherited class uses an old
signature in a "return super().call"

This should fix #139

@immerrr
Copy link
Contributor Author

immerrr commented Aug 19, 2018

Newly generated warnings look like this:

$ pytest -Wonce 
===================================================================================== test session starts =====================================================================================
platform linux -- Python 3.6.4, pytest-3.6.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/immerrr/src/tenacity, inifile:
collected 80 items                                                                                                                                                                            

tenacity/tests/test_asyncio.py ..                                                                                                                                                       [  2%]
tenacity/tests/test_tenacity.py ...........................................................................                                                                             [ 96%]
tenacity/tests/test_tornado.py ...                                                                                                                                                      [100%]

====================================================================================== warnings summary =======================================================================================
<<...some warnings snipped...>>

  /home/immerrr/src/tenacity/tenacity/tests/test_tenacity.py:127: DeprecationWarning: "tenacity.stop.stop_after_attempt.__call__" method must be called with single "retry_state" parameter
    attempt_number, seconds_since_start)

tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential
  /home/immerrr/src/tenacity/tenacity/tests/test_tenacity.py:191: DeprecationWarning: "tenacity.wait.wait_exponential.__call__" method must be called with single "retry_state" parameter
    self.assertEqual(r.wait(1, 0), 2)

<<...some warnings snipped...>>

tenacity/tests/test_tenacity.py::TestWaitConditions::test_fixed_sleep
  /home/immerrr/src/tenacity/tenacity/tests/test_tenacity.py:154: DeprecationWarning: "tenacity.wait.wait_fixed.__call__" method must be called with single "retry_state" parameter
    self.assertEqual(1, r.wait(12, 6546))

<<...some warnings snipped...>>

  /home/immerrr/src/tenacity/tenacity/tests/test_tenacity.py:991: DeprecationWarning: "tenacity.retry.retry_if_exception.__call__" method must be called with single "retry_state" parameter
    return super(MyRetry, self).__call__(attempt)

jd
jd previously approved these changes Aug 20, 2018
@jd
Copy link
Owner

jd commented Aug 20, 2018

Thanks a lot @immerrr!

@jd
Copy link
Owner

jd commented Aug 20, 2018

There are some pep8 errors though :)

@immerrr immerrr force-pushed the add-backward-compatibility-for-cb-classes branch from 47d1226 to d8e9d4f Compare August 20, 2018 12:44
They can be called side-stepping the "primary" backward compatibility shim
provided by BaseRetrying class, for example when an inherited class uses an old
signature in a "return super().__call__"
@immerrr immerrr force-pushed the add-backward-compatibility-for-cb-classes branch from d8e9d4f to a181af8 Compare August 20, 2018 13:06
@immerrr
Copy link
Contributor Author

immerrr commented Aug 20, 2018

@jd fixed

@mergify mergify bot merged commit 1d05520 into jd:master Aug 20, 2018
@immerrr immerrr deleted the add-backward-compatibility-for-cb-classes branch August 20, 2018 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tenacity 5.0.0 breaks compat

2 participants