AdithyaSK's picture
AdithyaSK HF Staff
Publish 100 swe_next Harbor tasks
d40299b verified
|
Raw History Blame Contribute Delete
1.84 kB
## `schedule.next_run()` does not support filtering by tag
Currently, calling `schedule.next_run()` with a tag argument raises a `TypeError` because the function doesn't accept any parameters. There is no way to ask "when is the next run for jobs with a specific tag?"
### Reproduction
```python
import schedule
from schedule import every
def job(): pass
every(5).seconds.do(job).tag("tag1")
every(2).hours.do(job).tag("tag1", "tag2")
every(1).minutes.do(job).tag("tag1", "tag3", "tag2")
# Trying to get the next run time for jobs tagged "tag1"
print(schedule.next_run("tag1"))
```
This raises:
```
TypeError: next_run() takes 0 positional arguments but 1 was given
```
Similarly, `schedule.default_scheduler.next_run` (a property) cannot be called with a tag to filter results, and there is no `get_next_run(tag)` method on the `Scheduler` class.
### Expected behavior
- `schedule.next_run("tag1")` should return the `next_run` datetime of the earliest-scheduled job that has the tag `"tag1"`.
- `schedule.next_run("tag4")` should return `None` if no jobs have that tag.
- `schedule.default_scheduler.get_next_run("tag2")` should return the earliest next run among jobs tagged `"tag2"`.
- Calling `schedule.next_run()` with no arguments should continue to work as before (returning the global next run across all jobs).
### Actual behavior
Passing any tag argument to `schedule.next_run()` raises `TypeError: next_run() takes 0 positional arguments but 1 was given`. There is no tag-aware method available on the `Scheduler` class either.
Work in `/workspace`. Submit your fix in the existing Python source files under `schedule`. Preserve the other public behavior. The environment is offline; dependencies are preinstalled. Grading runs the repository's test suite in a fresh environment, using your submitted source files.