Skip to content

Add types for activejob v8.1 - #1090

Merged
github-actions[bot] merged 7 commits into
ruby:mainfrom
amatsuda:activejob-8.1
Oct 14, 2026
Merged

github-actions[bot] merged 7 commits into
ruby:mainfrom
amatsuda:activejob-8.1

Conversation

@amatsuda

Copy link
Copy Markdown
Member

Adds signatures for activejob 8.1, based on 8.1.4.

The latest version in this repository was activejob 6.0, whose generated file came from Rails 6.0. Like the other Rails 8.1 gems (#1084, #1086, #1087), this PR regenerates the RBS from the 8.1.4 source and carries over the hand-written parts.

How it is made

activejob-generated.rbs comes from rbs prototype rb run on lib, then post-processed the same way as the other Rails 8.1 gems:

  • Drop members that core, dependencies, or the hand-written RBS already define
  • Fill missing type arguments of generic classes with untyped
  • Drop mixins and superclasses that can't be resolved
  • Add accessors defined with class_attribute, mattr_accessor, and cattr_accessor, and methods defined with delegate. A cattr_accessor inside included do ... end goes to the class that includes the concern, like class_attribute
  • Carry over typed signatures from 6.0 where the method still has the same parameters (6)

The job generator in lib/rails is left out, since its superclass comes from railties, which activejob doesn't depend on.

Changes to the hand-written RBS

The first commit copies 6.0's hand-written files unchanged, so the following commits show only the 8.1-specific changes:

  • Remove the fake Que::Job and SuckerPunch::Job. Rails no longer has those adapters
  • Add logger and log_arguments to ActiveJob::Base. Logging defines them in its included block
  • ActiveJob::Base extends ActiveSupport::Callbacks::ClassMethods and ActiveSupport::Rescuable::ClassMethods, so jobs have rescue_from

Return types

job_id, arguments, executions, exception_executions, queue_name, priority, locale, timezone, enqueued_at, enqueue_error, and enqueue/perform_later, which return the job, or false if it couldn't be enqueued.

Optional blocks

rbs prototype marks a &block param as required unless the body checks it. All required blocks were checked against the source, and the 14 that only forward the block or don't use it were made optional: for example, before_perform :method_name, and assert_no_enqueued_jobs without a block.

Tests

Each commit that changes types adds tests that fail without it. bin/test gems/activejob/8.1 and RuboCop's strict cops pass on every commit from the generation commit onward.

The existing gems that depend on activejob (actionmailer 7.0, actiontext 7.2, and activestorage 7.0) still resolve to activejob 6.0, and their tests pass.

🤖 Generated with Claude Code

amatsuda and others added 7 commits October 13, 2026 18:59
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Generated with `rbs prototype rb` from the activejob 8.1.4 source and
post-processed the same way as the other Rails 8.1 gems: drop members
already defined elsewhere, fill missing type arguments, add accessors
defined with class_attribute, mattr_accessor, and cattr_accessor, add
methods defined with delegate, and carry over typed signatures from 6.0
where the method still has the same parameters.

The job generator in lib/rails is left out, as its superclass comes from
railties, which activejob doesn't depend on.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Rails no longer has QueAdapter or SuckerPunchAdapter, so nothing refers
to Que::Job or SuckerPunch::Job.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Logging defines them on the job class with cattr_accessor and
class_attribute in its included block, which rbs prototype doesn't see.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
job_id, arguments, executions, queue_name, priority, and the other job
attributes, enqueue, and perform_later, which returns the job or false
when it couldn't be enqueued.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
rbs prototype marks a block as required unless the method checks it.
These forward the block or don't use it: the callbacks with method names
(before_perform :foo), assert_no_enqueued_jobs and
assert_no_performed_jobs without a block, and a few internal methods.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…:Base

ActiveJob::Callbacks and ActiveJob::Exceptions include
ActiveSupport::Callbacks and ActiveSupport::Rescuable, so job classes
have rescue_from and set_callback.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@amatsuda Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

activejob

You changed RBS files for an existing gem.
You need to get approval from the reviewers of this gem.

@ksss, @tk0miya, please review this pull request.
If this change is acceptable, please make a review comment including APPROVE from here.
Screen Shot 2024-03-19 at 14 13 36

After that, the PR author or the reviewers can merge this PR.
Just comment /merge to merge this PR.

@ksss ksss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

@github-actions

Copy link
Copy Markdown

Thanks for your review, @ksss!

@amatsuda, @ksss This PR is ready to be merged.
Just comment /merge to merge this PR.

@amatsuda

Copy link
Copy Markdown
Member Author

/merge

@github-actions
github-actions Bot merged commit bdd4198 into ruby:main Oct 14, 2026
7 checks passed
@amatsuda
amatsuda deleted the activejob-8.1 branch October 14, 2026 11:38
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.

2 participants