From a3e23f4bbbb661406eceab7d206c74e623f32073 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Wed, 30 Oct 2024 09:31:05 +0700 Subject: [PATCH 1/2] Fix mypy errors --- django_rq/tests/test_views.py | 2 +- django_rq/utils.py | 4 +--- django_rq/views.py | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/django_rq/tests/test_views.py b/django_rq/tests/test_views.py index 405cab6d..d8473b16 100644 --- a/django_rq/tests/test_views.py +++ b/django_rq/tests/test_views.py @@ -412,7 +412,7 @@ def test_action_stop_jobs(self): self.assertEqual(len(canceled_job_registry), len(job_ids)) for job_id in job_ids: - self.assertIn(job_id, canceled_job_registry) + self.assertTrue(job_id in canceled_job_registry) # def test_scheduler_jobs(self): # # Override testing RQ_QUEUES diff --git a/django_rq/utils.py b/django_rq/utils.py index 828176eb..9b2bfcb3 100644 --- a/django_rq/utils.py +++ b/django_rq/utils.py @@ -141,9 +141,7 @@ def get_jobs( 1. If job data is not present in Redis, discard the result 2. If `registry` argument is supplied, delete empty jobs from registry """ - jobs = cast( - List[Optional[Job]], Job.fetch_many(job_ids, connection=queue.connection, serializer=queue.serializer) - ) + jobs = Job.fetch_many(job_ids, connection=queue.connection, serializer=queue.serializer) valid_jobs = [] for i, job in enumerate(jobs): if job is None: diff --git a/django_rq/views.py b/django_rq/views.py index 3df04867..1a19f409 100644 --- a/django_rq/views.py +++ b/django_rq/views.py @@ -267,8 +267,9 @@ def worker_details(request, queue_index, key): queue_index = int(queue_index) queue = get_queue_by_index(queue_index) worker = Worker.find_by_key(key, connection=queue.connection) + assert worker # Convert microseconds to milliseconds - worker.total_working_time = worker.total_working_time / 1000 # type: ignore[assignment] + worker.total_working_time = worker.total_working_time / 1000 queue_names = ', '.join(worker.queue_names()) From 0eced2bac34b1a9c77dd97ef547e1c78553da4e4 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Wed, 30 Oct 2024 10:07:11 +0700 Subject: [PATCH 2/2] Don't fail CI if mypy fails --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d82144b..fd35771d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,6 +57,14 @@ jobs: python -m pip install --upgrade pip pip install django-stubs[compatible-mypy] rq types-redis - - name: Run Test + - name: Run mypy + continue-on-error: true + id: mypy run: | mypy django_rq + + - name: Set Status + if: steps.mypy.outcome == 'failure' + run: | + echo "Mypy found errors, marking check as neutral" + exit 78 # Exit code 78 results in a neutral check