Skip to content

Add types for actionmailer v8.1 - #1092

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

github-actions[bot] merged 17 commits into
ruby:mainfrom
amatsuda:actionmailer-8.1

Conversation

@amatsuda

Copy link
Copy Markdown
Member

Adds signatures for actionmailer 8.1, based on 8.1.4.

This PR is stacked on #1090 (activejob 8.1), because actionmailer 8.1 needs activejob 8.1's signatures. Until that is merged, its commits show up here too. The commits for this PR are the ones starting with actionmailer:.

The latest version in this repository was actionmailer 7.0, which had only hand-written signatures for the main mailer API. This PR adds signatures generated from the 8.1.4 source and carries over the hand-written ones.

How it is made

actionmailer-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 the modules included inside included do ... end, accessors defined with class_attribute, mattr_accessor, and cattr_accessor, and methods defined with delegate
  • Generate the methods defined inside class_methods do ... end as the concern's ClassMethods, which rbs prototype skips
  • Make the generated classes extend the ClassMethods of the concerns they include, directly or through other concerns, as ActiveSupport::Concern does

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

Changes to the hand-written RBS

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

  • Remove the fake Mail::Message. actionmailer depends on mail, whose RBS in this repository declares it
  • MessageDelivery#processed is renamed to processed?. There's no processed method
  • Add delivery_job and deliver_later_queue_name to ActionMailer::Base. QueuedDelivery defines them in its included block
  • ActionMailer::Base extends the ClassMethods of the concerns it includes. Only the ones from Action Pack and Action View were listed, so mailers had no before_deliver, rescue_from, deliveries, or with

Return types

deliver_later and deliver_later! return the enqueued job, or false if it couldn't be enqueued. ActionMailer::Base.deliveries and capture_emails return Array[Mail::Message].

Optional blocks

All required blocks were checked against the source, and the 10 that only forward or store the block were made optional: for example, before_deliver :method_name, assert_no_emails and assert_enqueued_emails without a block, and Collector#any.

Tests

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

🤖 Generated with Claude Code

amatsuda and others added 16 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>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
7.0 had only hand-written signatures. 8.1 adds signatures generated with
`rbs prototype rb` from the actionmailer 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 the modules included inside
`included do ... end`, and add accessors defined with class_attribute,
mattr_accessor, and cattr_accessor and methods defined with delegate.
Methods defined inside `class_methods do ... end` are generated as the
concern's ClassMethods.

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

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
actionmailer depends on mail, whose RBS in this repository declares it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MessageDelivery has no processed method. processed? returns the
processed mailer or message, or nil.

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 store it: the callbacks with method names
(before_deliver :foo), Collector#any, and the test assertions such as
assert_no_emails and assert_enqueued_emails, which check the current
deliveries when called without a block.

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

QueuedDelivery defines them on the mailer class with class_attribute in
its included block, which rbs prototype doesn't see.

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

Only the ones from Action Pack and Action View were listed, so mailers
had no before_deliver, rescue_from, deliveries, or with.

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

deliver_later and deliver_later! return the enqueued job, or false if it
couldn't be enqueued. deliveries is delegated to Mail::TestMailer.

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

The generated classes now extend the ClassMethods of the concerns they
include, directly or through other concerns, as ActiveSupport::Concern
does. ActionMailer::TestCase gets tests and determine_default_mailer.

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

actionmailer

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

@ksss, @ydah, @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.


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 e0f9050 into ruby:main Oct 14, 2026
6 checks passed
@amatsuda
amatsuda deleted the actionmailer-8.1 branch October 14, 2026 15:46
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