Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set CRON trigger fields #938

Closed
wants to merge 1 commit into from

Conversation

WillDaSilva
Copy link
Contributor

Changes

Fixes #923

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) added which would fail without your patch
  • You've updated the documentation (in docs/, in case of behavior changes or new
    features)
  • You've added a new changelog entry (in docs/versionhistory.rst).

If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.

Updating the changelog

If there are no entries after the last release, use **UNRELEASED** as the version.
If, say, your patch fixes issue #999, the entry should look like this:

* Fix big bad boo-boo in the async scheduler (#999 <https://github.com/agronholm/apscheduler/issues/999>_; PR by @yourgithubaccount)

If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.

@agronholm
Copy link
Owner

The proper fix would be to override __init__() to accept the individual fields, and call __attrs_init__() to fill in the fields we want to keep, and then fill in the _fields attribute. A test that fails without the fix would also be required.

@WillDaSilva
Copy link
Contributor Author

A test that fails without the fix would also be required.

Yup. I plan to add one before I mark this as ready for review.

fill in the fields we want to keep

@agronholm I'm not sure what you mean by this. Don't we want to keep all of the fields? Specifically, that is:

  • year
  • month
  • day
  • week
  • day_of_week
  • hour
  • minute
  • second
  • start_time
  • end_time
  • timezone
  • last_fire_time

If you feel you know how to fix it, and that fixing it yourself would be easier than helping me fix it, feel free to take it away. Otherwise I'm happy to see this through. Whatever's easiest for you.

@agronholm
Copy link
Owner

The initializer parameters from year to second were only supposed to be used to fill out the appropriate fields, and should not be stored in the instance. That this happened was an artifact of the class being transformed into an attrs class. Before I started using attrs in APScheduler, I had intended these to be InitVars when the trigger class was going to be a data class, but attrs does not have such a feature. Instead, its docs recommend overriding __init__(). I'll see about doing this tomorrow.

@agronholm
Copy link
Owner

Closing in favor of commit 0240dce.

@agronholm agronholm closed this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'CronTrigger' object has no attribute 'year' when try to pause schedule
2 participants