Increase the usage of augmented assignment statements
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 999
- PR merge metrics
- No merged PRs in 30d
Description
:eyes: Some source code analysis tools can help to find opportunities for improving software components.
:thought_balloon: I propose to [increase the usage of augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements "Augmented assignment statements") accordingly.
```diff
diff --git a/schedule/__init__.py b/schedule/__init__.py
index 83a9581..666c044 100644
--- a/schedule/__init__.py
+++ b/schedule/__init__.py
@@ -726,7 +726,7 @@ class Job(object):
and self.at_time > now.time()
and self.interval == 1
):
- self.next_run = self.next_run - datetime.timedelta(days=1)
+ self.next_run -= datetime.timedelta(days=1)
elif self.unit == "hours" and (
self.at_time.minute > now.minute
or (
@@ -734,9 +734,9 @@ class Job(object):
and self.at_time.second > now.second
)
):
- self.next_run = self.next_run - datetime.timedelta(hours=1)
+ self.next_run -= datetime.timedelta(hours=1)
elif self.unit == "minutes" and self.at_time.second > now.second:
- self.next_run = self.next_run - datetime.timedelta(minutes=1)
+ self.next_run -= datetime.timedelta(minutes=1)
if self.start_day is not None and self.at_time is not None:
# Let's see if we will still make that time we specified today
if (self.next_run - datetime.datetime.now()).days >= 7:
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open schedule/__init__.py and inspect the Job logic around the shown next_run updates. Confirm that the three subtraction assignments can use augmented assignment without changing behavior, then run the existing project tests to verify scheduling behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100