cyounkins: Closing and re-opening to re-trigger travis CI
diff --git a/tenacity/wait.py b/tenacity/wait.py
index 84d3bfa..d3c835f 100644
--- a/tenacity/wait.py
+++ b/tenacity/wait.py
@@ -155,7 +155,7 @@ class wait_exponential(wait_base):
     @_compat.wait_dunder_call_accept_old_params
     def __call__(self, retry_state):
         try:
-            exp = self.exp_base ** retry_state.attempt_number
+            exp = self.exp_base ** (retry_state.attempt_number - 1)
             result = self.multiplier * exp
         except OverflowError:
             return self.max

wait_exponential has unexpected first delay
Hi there! Thank you for `tenacity`!

The first delay for `wait_exponential` is `2 * multiplier`, and to me that is unexpected. In version `5.0.4`:

```
In [14]: t0 = time.time()
    ...: t_last = t0
    ...: @retry(wait=wait_exponential(multiplier=0.2), stop=stop_after_attempt(5))
    ...: def wait():
    ...:     current_time = time.time()
    ...:     global t_last
    ...:     print("%.2f - %.2f" % (current_time - t0, current_time - t_last))
    ...:     t_last = current_time
    ...:     raise Exception
    ...: print("total - delta")
    ...: wait()
total - delta
0.00 - 0.00
0.40 - 0.40
1.21 - 0.80
2.81 - 1.60
6.01 - 3.20
```

To me it would make more sense for the first delay to be `1 * multiplier`. Others may expect the first retry to occur immediately with no delay, or maybe they want the sequence to be 0.1, 0.2, 0.4, 0.8, etc. which doesn't seem possible with just `wait_exponential`.

Can this be considered a bug? Is this unexpected to others, or do others want to be able to create the sequence above?
diff --git a/tenacity/tests/test_tenacity.py b/tenacity/tests/test_tenacity.py
index 13c3559..acd1a46 100644
--- a/tenacity/tests/test_tenacity.py
+++ b/tenacity/tests/test_tenacity.py
@@ -188,23 +188,26 @@ class TestWaitConditions(unittest.TestCase):
             self.assertTrue(t <= 2)
 
     def test_exponential(self):
-        r = Retrying(wait=tenacity.wait_exponential(max=100))
-        self.assertEqual(r.wait(1, 0), 2)
-        self.assertEqual(r.wait(2, 0), 4)
-        self.assertEqual(r.wait(3, 0), 8)
-        self.assertEqual(r.wait(4, 0), 16)
-        self.assertEqual(r.wait(5, 0), 32)
-        self.assertEqual(r.wait(6, 0), 64)
+        r = Retrying(wait=tenacity.wait_exponential())
+        self.assertEqual(r.wait(1, 0), 1)
+        self.assertEqual(r.wait(2, 0), 2)
+        self.assertEqual(r.wait(3, 0), 4)
+        self.assertEqual(r.wait(4, 0), 8)
+        self.assertEqual(r.wait(5, 0), 16)
+        self.assertEqual(r.wait(6, 0), 32)
+        self.assertEqual(r.wait(7, 0), 64)
+        self.assertEqual(r.wait(8, 0), 128)
 
     def test_exponential_with_max_wait(self):
         r = Retrying(wait=tenacity.wait_exponential(max=40))
-        self.assertEqual(r.wait(1, 0), 2)
-        self.assertEqual(r.wait(2, 0), 4)
-        self.assertEqual(r.wait(3, 0), 8)
-        self.assertEqual(r.wait(4, 0), 16)
-        self.assertEqual(r.wait(5, 0), 32)
-        self.assertEqual(r.wait(6, 0), 40)
+        self.assertEqual(r.wait(1, 0), 1)
+        self.assertEqual(r.wait(2, 0), 2)
+        self.assertEqual(r.wait(3, 0), 4)
+        self.assertEqual(r.wait(4, 0), 8)
+        self.assertEqual(r.wait(5, 0), 16)
+        self.assertEqual(r.wait(6, 0), 32)
         self.assertEqual(r.wait(7, 0), 40)
+        self.assertEqual(r.wait(8, 0), 40)
         self.assertEqual(r.wait(50, 0), 40)
 
     def test_exponential_with_min_wait(self):
@@ -213,21 +216,23 @@ class TestWaitConditions(unittest.TestCase):
         self.assertEqual(r.wait(2, 0), 20)
         self.assertEqual(r.wait(3, 0), 20)
         self.assertEqual(r.wait(4, 0), 20)
-        self.assertEqual(r.wait(5, 0), 32)
-        self.assertEqual(r.wait(6, 0), 64)
-        self.assertEqual(r.wait(7, 0), 128)
-        self.assertEqual(r.wait(20, 0), 1048576)
+        self.assertEqual(r.wait(5, 0), 20)
+        self.assertEqual(r.wait(6, 0), 32)
+        self.assertEqual(r.wait(7, 0), 64)
+        self.assertEqual(r.wait(8, 0), 128)
+        self.assertEqual(r.wait(20, 0), 524288)
 
     def test_exponential_with_max_wait_and_multiplier(self):
         r = Retrying(wait=tenacity.wait_exponential(
             max=50, multiplier=1))
-        self.assertEqual(r.wait(1, 0), 2)
-        self.assertEqual(r.wait(2, 0), 4)
-        self.assertEqual(r.wait(3, 0), 8)
-        self.assertEqual(r.wait(4, 0), 16)
-        self.assertEqual(r.wait(5, 0), 32)
-        self.assertEqual(r.wait(6, 0), 50)
+        self.assertEqual(r.wait(1, 0), 1)
+        self.assertEqual(r.wait(2, 0), 2)
+        self.assertEqual(r.wait(3, 0), 4)
+        self.assertEqual(r.wait(4, 0), 8)
+        self.assertEqual(r.wait(5, 0), 16)
+        self.assertEqual(r.wait(6, 0), 32)
         self.assertEqual(r.wait(7, 0), 50)
+        self.assertEqual(r.wait(8, 0), 50)
         self.assertEqual(r.wait(50, 0), 50)
 
     def test_exponential_with_min_wait_and_multiplier(self):
@@ -236,21 +241,24 @@ class TestWaitConditions(unittest.TestCase):
         self.assertEqual(r.wait(1, 0), 20)
         self.assertEqual(r.wait(2, 0), 20)
         self.assertEqual(r.wait(3, 0), 20)
-        self.assertEqual(r.wait(4, 0), 32)
-        self.assertEqual(r.wait(5, 0), 64)
-        self.assertEqual(r.wait(6, 0), 128)
-        self.assertEqual(r.wait(7, 0), 256)
-        self.assertEqual(r.wait(20, 0), 2097152)
+        self.assertEqual(r.wait(4, 0), 20)
+        self.assertEqual(r.wait(5, 0), 32)
+        self.assertEqual(r.wait(6, 0), 64)
+        self.assertEqual(r.wait(7, 0), 128)
+        self.assertEqual(r.wait(8, 0), 256)
+        self.assertEqual(r.wait(20, 0), 1048576)
 
     def test_exponential_with_min_wait_and_max_wait(self):
         r = Retrying(wait=tenacity.wait_exponential(min=10, max=100))
         self.assertEqual(r.wait(1, 0), 10)
         self.assertEqual(r.wait(2, 0), 10)
         self.assertEqual(r.wait(3, 0), 10)
-        self.assertEqual(r.wait(4, 0), 16)
-        self.assertEqual(r.wait(5, 0), 32)
-        self.assertEqual(r.wait(6, 0), 64)
-        self.assertEqual(r.wait(7, 0), 100)
+        self.assertEqual(r.wait(4, 0), 10)
+        self.assertEqual(r.wait(5, 0), 16)
+        self.assertEqual(r.wait(6, 0), 32)
+        self.assertEqual(r.wait(7, 0), 64)
+        self.assertEqual(r.wait(8, 0), 100)
+        self.assertEqual(r.wait(9, 0), 100)
         self.assertEqual(r.wait(20, 0), 100)
 
     def test_legacy_explicit_wait_type(self):
@@ -375,13 +383,13 @@ class TestWaitConditions(unittest.TestCase):
         fn = tenacity.wait_random_exponential(0.5, 60.0)
 
         for _ in six.moves.range(1000):
-            self._assert_inclusive_range(fn(make_retry_state(1, 0)), 0, 1.0)
-            self._assert_inclusive_range(fn(make_retry_state(2, 0)), 0, 2.0)
-            self._assert_inclusive_range(fn(make_retry_state(3, 0)), 0, 4.0)
-            self._assert_inclusive_range(fn(make_retry_state(4, 0)), 0, 8.0)
-            self._assert_inclusive_range(fn(make_retry_state(5, 0)), 0, 16.0)
-            self._assert_inclusive_range(fn(make_retry_state(6, 0)), 0, 32.0)
-            self._assert_inclusive_range(fn(make_retry_state(7, 0)), 0, 60.0)
+            self._assert_inclusive_range(fn(make_retry_state(1, 0)), 0, 0.5)
+            self._assert_inclusive_range(fn(make_retry_state(2, 0)), 0, 1.0)
+            self._assert_inclusive_range(fn(make_retry_state(3, 0)), 0, 2.0)
+            self._assert_inclusive_range(fn(make_retry_state(4, 0)), 0, 4.0)
+            self._assert_inclusive_range(fn(make_retry_state(5, 0)), 0, 8.0)
+            self._assert_inclusive_range(fn(make_retry_state(6, 0)), 0, 16.0)
+            self._assert_inclusive_range(fn(make_retry_state(7, 0)), 0, 32.0)
             self._assert_inclusive_range(fn(make_retry_state(8, 0)), 0, 60.0)
             self._assert_inclusive_range(fn(make_retry_state(9, 0)), 0, 60.0)
 
@@ -408,13 +416,13 @@ class TestWaitConditions(unittest.TestCase):
             return float(sum(lst)) / float(len(lst))
 
         # skipping attempt 0
-        self._assert_inclusive_epsilon(mean(attempt[1]), 0.50, 0.04)
-        self._assert_inclusive_epsilon(mean(attempt[2]), 1, 0.08)
-        self._assert_inclusive_epsilon(mean(attempt[3]), 2, 0.16)
-        self._assert_inclusive_epsilon(mean(attempt[4]), 4, 0.32)
-        self._assert_inclusive_epsilon(mean(attempt[5]), 8, 0.64)
-        self._assert_inclusive_epsilon(mean(attempt[6]), 16, 1.28)
-        self._assert_inclusive_epsilon(mean(attempt[7]), 30, 2.56)
+        self._assert_inclusive_epsilon(mean(attempt[1]), 0.25, 0.02)
+        self._assert_inclusive_epsilon(mean(attempt[2]), 0.50, 0.04)
+        self._assert_inclusive_epsilon(mean(attempt[3]), 1, 0.08)
+        self._assert_inclusive_epsilon(mean(attempt[4]), 2, 0.16)
+        self._assert_inclusive_epsilon(mean(attempt[5]), 4, 0.32)
+        self._assert_inclusive_epsilon(mean(attempt[6]), 8, 0.64)
+        self._assert_inclusive_epsilon(mean(attempt[7]), 16, 1.28)
         self._assert_inclusive_epsilon(mean(attempt[8]), 30, 2.56)
         self._assert_inclusive_epsilon(mean(attempt[9]), 30, 2.56)
 

pip install -e .
parse_log_pytest
requirements.txt
pytest sphinx
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
docutils==0.18.1
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
MarkupSafe==2.0.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytz==2025.2
requests==2.27.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
-e git+https://github.com/jd/tenacity.git@531a28b921e27e916dde6346f98868c66bc4fcb2#egg=tenacity
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: tenacity
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - docutils==0.18.1
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytz==2025.2
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/tenacity

tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential_with_max_wait tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential_with_max_wait_and_multiplier tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential_with_min_wait tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential_with_min_wait_and_max_wait tenacity/tests/test_tenacity.py::TestWaitConditions::test_exponential_with_min_wait_and_multiplier tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_random_exponential tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_random_exponential_statistically
tenacity/tests/test_tenacity.py::TestBase::test_repr tenacity/tests/test_tenacity.py::TestStopConditions::test_legacy_explicit_stop_type tenacity/tests/test_tenacity.py::TestStopConditions::test_never_stop tenacity/tests/test_tenacity.py::TestStopConditions::test_retry_child_class_with_override_backward_compat tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_after_attempt tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_after_delay tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_all tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_and tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_any tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_backward_compat tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_func_with_retry_state tenacity/tests/test_tenacity.py::TestStopConditions::test_stop_or tenacity/tests/test_tenacity.py::TestWaitConditions::test_fixed_sleep tenacity/tests/test_tenacity.py::TestWaitConditions::test_incrementing_sleep tenacity/tests/test_tenacity.py::TestWaitConditions::test_legacy_explicit_wait_type tenacity/tests/test_tenacity.py::TestWaitConditions::test_no_sleep tenacity/tests/test_tenacity.py::TestWaitConditions::test_random_sleep tenacity/tests/test_tenacity.py::TestWaitConditions::test_random_sleep_without_min tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_arbitrary_sum tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_backward_compat tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_backward_compat_with_result tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_chain tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_chain_multiple_invocations tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_class_backward_compatibility tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_combine tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_double_sum tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_func tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_retry_state_attributes tenacity/tests/test_tenacity.py::TestWaitConditions::test_wait_triple_sum tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_all tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_and tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_any tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_if_exception_message_negative_no_inputs tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_if_exception_message_negative_too_many_inputs tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_if_not_result tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_if_result tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_or tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_try_again tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_try_again_forever tenacity/tests/test_tenacity.py::TestRetryConditions::test_retry_try_again_forever_reraise tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_defaults tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_child_class_with_override_backward_compat tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_function_object tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_exception_message tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_exception_message_match tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_exception_of_type tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_not_exception_message tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_not_exception_message_delay tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_if_not_exception_message_match tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_until_exception_of_type_attempt_number tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_until_exception_of_type_no_type tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_until_exception_of_type_wrong_exception tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_retry_with tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_with_stop_on_exception tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_with_stop_on_return_value tenacity/tests/test_tenacity.py::TestDecoratorWrapper::test_with_wait tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_after_attempts tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_attempts tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_sleep tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_sleep_backward_compat tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_sleep_backward_compat_method tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_sleep_log_raises tenacity/tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_sleep_log_returns tenacity/tests/test_tenacity.py::TestReraiseExceptions::test_reraise_by_default tenacity/tests/test_tenacity.py::TestReraiseExceptions::test_reraise_from_retry_error tenacity/tests/test_tenacity.py::TestReraiseExceptions::test_reraise_no_exception tenacity/tests/test_tenacity.py::TestReraiseExceptions::test_reraise_timeout_from_retry_error tenacity/tests/test_tenacity.py::TestStatistics::test_stats tenacity/tests/test_tenacity.py::TestStatistics::test_stats_failing tenacity/tests/test_tenacity.py::TestRetryErrorCallback::test_retry_error_callback tenacity/tests/test_tenacity.py::TestRetryErrorCallback::test_retry_error_callback_backward_compat
tenacity/wait.py
tenacity/wait.py