Skip to content

Add ActiveModel::Translation human_attribute_name type#1007

Open
babashunya wants to merge 1 commit intoruby:mainfrom
babashunya:activemodel/human_attribute_name
Open

Add ActiveModel::Translation human_attribute_name type#1007
babashunya wants to merge 1 commit intoruby:mainfrom
babashunya:activemodel/human_attribute_name

Conversation

@babashunya
Copy link
Contributor

Overview

The human_attribute_name method in ActiveModel::Translation had untyped for both arguments and return value.

Since the implementation always returns String (either from I18n.translate or .humanize fallback), and the first argument accepts String or Symbol (.to_s is called internally), the type has been updated to be more specific.

References

@babashunya babashunya force-pushed the activemodel/human_attribute_name branch from 32f8129 to 4e3d760 Compare February 27, 2026 07:23
## Overview

The `human_attribute_name` method in `ActiveModel::Translation` had `untyped` for both arguments and return value.

Since the implementation always returns `String` (either from `I18n.translate` or `.humanize` fallback), and the first argument accepts `String` or `Symbol` (`.to_s` is called internally), the type has been updated to be more specific.

## References

- human_attribute_name
  - https://api.rubyonrails.org/classes/ActiveModel/Translation.html#method-i-human_attribute_name
  - https://github.com/rails/rails/blob/main/activemodel/lib/active_model/translation.rb
@babashunya babashunya force-pushed the activemodel/human_attribute_name branch from 4e3d760 to 155ec9f Compare February 27, 2026 07:27
@babashunya babashunya marked this pull request as ready for review February 27, 2026 08:19
@github-actions
Copy link

@babashunya 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

activemodel

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

@hibariya, @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.

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.

1 participant