8000 refactor: Use Hash#fetch instead of Hash#[] to resolve type errors by tk0miya · Pull Request #1286 · soutaro/steep · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: Use Hash#fetch instead of Hash#[] to resolve type errors #1286

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

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

tk0miya
Copy link
Contributor
@tk0miya tk0miya commented Oct 18, 2024

135 -> 47

Note: Hash#fetch raises KeyError. So we need to merge this carefully. I'm okay to divide this PR to smaller ones.

8000
@@ -46,7 +46,7 @@ def collect_changes(request)

changes[path] ||= []
request[:params][:contentChanges].each do |change|
changes[path] << Services::ContentChange.new(
changes.fetch(path) << Services::ContentChange.new(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel a bit strange about the combination of Hash#fetch and Array#<<...

when singleton_method
methods = factory.definition_builder.build_singleton(type_name).methods

if singleton_method == :new
methods[:new] || methods[:initialize]
methods[:new] || methods.fetch(:initialize)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also a bit strange. The left hand is #[], but the right hand is #fetch. It's a little difficult to understand the behavior for me.

@tk0miya tk0miya force-pushed the refactor/Hash.fetch branch from 41350c8 to 61a9792 Compare October 18, 2024 13:22
@tk0miya tk0miya changed the title refactor: Use Hash#[] to resolve type errors refactor: Use Hash#fetch instead of Hash#[] to resolve type errors Oct 18, 2024
@tk0miya tk0miya force-pushed the refactor/Hash.fetch branch from 61a9792 to f706145 Compare October 18, 2024 13:36
@soutaro soutaro force-pushed the refactor/Hash.fetch branch from f706145 to e7f2834 Compare November 25, 2024 04:44
Copy link
Owner
@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

Thanks! 🎉

@soutaro soutaro added this to the Steep 1.9 milestone Nov 25, 2024
@soutaro soutaro enabled auto-merge November 25, 2024 04:45
@soutaro soutaro merged commit cf972b5 into soutaro:master Nov 25, 2024
16 checks passed
@tk0miya tk0miya deleted the refactor/Hash.fetch branch November 25, 2024 05:07
@soutaro soutaro added the Released The PR is already included in a published release label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released The PR is already included in a published release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0