Repository: spacemanspiff2007/eascheduler (language: python)

Issue:
A cancelled OneTimeJob still shows remaining time
When a `OneTimeJob` gets canceled it still shows a value for `job.remaining()` instead of `None`
A cancelled OneTimeJob still shows remaining time
When a `OneTimeJob` gets canceled it still shows a value for `job.remaining()` instead of `None`


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 84a57dd..00cf27c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,8 @@
-/.mypy_cache
-/.pytest_cache
+**/.mypy_cache
+**/.pytest_cache
 /.idea
 
-__pycache__
+**/__pycache__
 
 /build
 /venv
diff --git a/readme.md b/readme.md
index 05d026e..ea4360b 100644
--- a/readme.md
+++ b/readme.md
@@ -5,7 +5,7 @@
 ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/eascheduler)
 
 [![PyPI](https://img.shields.io/pypi/v/eascheduler)]((https://pypi.org/project/EAScheduler/))
-[![Downloads](https://pepy.tech/badge/eascheduler/month)](https://pepy.tech/project/eascheduler/month)
+[![Downloads](https://pepy.tech/badge/eascheduler/month)](https://pepy.tech/project/eascheduler)
 
 
 
@@ -19,6 +19,10 @@ Easy Async Scheduler (or EAScheduler) is a lightweight asyncio scheduler with a
 
 ## Changelog
 
+#### 0.18 (14.12.2022)
+- Fix for OneTimeJOb incorrectly showing a remaining time after the execution
+- Dependency update
+
 #### 0.1.7 (27.07.2022)
 - Added py.typed
 
diff --git a/requirements.txt b/requirements.txt
index 64ed634..1cdf07c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,13 +2,13 @@
 -r requirements_setup.txt
 
 # Testing
-pytest          >= 7.1,   < 7.2
-pytest-asyncio  >= 0.19 , < 0.20
+pytest          >= 7.2,   < 7.3
+pytest-asyncio  >= 0.20 , < 0.21
 
 # Docs
-sphinx                      >= 5.1,     < 5.2
-sphinx_autodoc_typehints    >= 1.18,    < 1.19
-sphinx_rtd_theme == 1.0.0
+sphinx                      >= 5.3,     < 5.4
+sphinx_autodoc_typehints    >= 1.19,    < 1.20
+sphinx_rtd_theme            == 1.1.1
 
 # static checker
-mypy >= 0.971
+mypy >= 0.991
diff --git a/requirements_setup.txt b/requirements_setup.txt
index c482221..15bff66 100644
--- a/requirements_setup.txt
+++ b/requirements_setup.txt
@@ -1,3 +1,3 @@
 # Requirements to install and use this library
 pendulum == 2.1.2
-astral   == 2.2
+astral   == 3.2
diff --git a/src/eascheduler/__version__.py b/src/eascheduler/__version__.py
index 124e462..c3bb296 100644
--- a/src/eascheduler/__version__.py
+++ b/src/eascheduler/__version__.py
@@ -1,1 +1,1 @@
-__version__ = '0.1.7'
+__version__ = '0.1.8'
diff --git a/src/eascheduler/jobs/job_one_time.py b/src/eascheduler/jobs/job_one_time.py
index 29f9e47..850761a 100644
--- a/src/eascheduler/jobs/job_one_time.py
+++ b/src/eascheduler/jobs/job_one_time.py
@@ -3,6 +3,7 @@
 from datetime import timedelta
 from typing import Union
 
+from eascheduler.const import FAR_FUTURE
 from eascheduler.jobs.job_base import get_first_timestamp, ScheduledJobBase
 
 
@@ -12,4 +13,5 @@ def _schedule_first_run(self, first_run: Union[None, int, float, timedelta, dt_t
         self._set_next_run(get_first_timestamp(first_run))
 
     def _schedule_next_run(self):
+        self._next_run = FAR_FUTURE
         self._parent = None


Test patch:
diff --git a/tests/jobs/test_job_onetime.py b/tests/jobs/test_job_onetime.py
index 0a05c3d..1bb8a9f 100644
--- a/tests/jobs/test_job_onetime.py
+++ b/tests/jobs/test_job_onetime.py
@@ -50,6 +50,23 @@ async def test_init():
     j.cancel()
 
 
+async def test_next_run():
+    set_now(2001, 1, 1, 12, 0, 0)
+
+    s = AsyncScheduler()
+    j = OneTimeJob(s, SyncExecutor(lambda: 1 / 0))
+
+    j._schedule_first_run(None)
+
+    assert j.remaining() is not None
+    assert j._parent is not None
+    cmp_local(j._next_run,  datetime(2001, 1, 1, 12, 0, 0))
+
+    j._schedule_next_run()
+    assert j._parent is None
+    assert j.remaining() is None
+
+
 async def test_func_remaining():
     set_now(2001, 1, 1, 12, 0, 0)
 
@@ -69,3 +86,5 @@ async def test_func_remaining():
     assert j.remaining() == timedelta(hours=2)
 
     j.cancel()
+
+    assert j.remaining() is None
diff --git a/tests/jobs/test_job_sun.py b/tests/jobs/test_job_sun.py
index 2b00a83..5be7071 100644
--- a/tests/jobs/test_job_sun.py
+++ b/tests/jobs/test_job_sun.py
@@ -16,7 +16,7 @@
     [
         (DawnJob,    time( 6, 34,  4), time( 6, 12,  6)),
         (SunriseJob, time( 7, 15, 39), time( 6, 49, 53)),
-        (SunsetJob,  time(15,  4, 48), time(15, 50, 24)),
+        (SunsetJob,  time(15,  4, 49), time(15, 50, 25)),
         (DuskJob,    time(15, 46, 23), time(16, 28, 14)),
     ]
 )