[restful-api] Introduce Steep Typechecking#226
Open
hayat01sh1da wants to merge 5 commits intomasterfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Why (Purpose)
Introducing rbs-inline + Steep brings static type checking to Ruby/Rails codebases that otherwise rely entirely on runtime behavior. The goals are:
# rbs_inline: enabledopt-in comment lets you roll it out file-by-file without disrupting existing code2. What (Procedures)
2-1. Scope
12 projects total — 8 pure Ruby CLI projects and 4 Rails projects.
coding-tests/rubypr-title-printers/rubyjson-data-sorters/rubyitunes-file-delimiter-replacer/rubytemplate-creators/rubyfile-extension-converters/rubyfile-cleaners/rubygithub-wiki-organisers/rubytutorials/.../restful-apitutorials/.../perfect-ruby-on-railstutorials/.../e-navigatorbotpress-accuracy-checkers/ruby-on-rails2-2. Steps performed
rbs-inlineandsteepgems to each Rails project'sGemfile(in:development, :testgroup withrequire: false)# rbs_inline: enabledmagic comment to every.rbfile underapp/,spec/,test/,src/,exec/— respecting existing# frozen_string_literal: trueplacementrbs-inline→ output stored insig/generated/mirroring source treeSteepfilein each project root, declaring:checktargets (source + test directories)signature "sig"for generated.rbsfileslibraryentries for stdlib/gems with RBS definitions (e.g.minitest,csv,json,fileutils,net-smtp,observer,ostruct,psych)2-3. Steepfile library declarations per project
csv,ostructnet-smtp,observer,ostructminitest,net-smtp,observer,ostruct,psychminitestjson,net-httpfileutils,jsondate,fileutilsfileutilsfileutilsfileutilsfileutils3. How (Operation and Maintenance)
3-1. Regenerating signatures after code changes
For pure Ruby projects (no Bundler):
rbs-inline --output sig/generated src/ exec/ test/3-2. Running type checks
3-3. When adding new files
# rbs_inline: enabledas the first line (after# frozen_string_literal: trueif present)rbs-inlineto generate the.rbsfilesteep checkto verify3-4. When adding new gems
If a new gem provides RBS types (check ruby/gem_rbs_collection), add a
library "<gem>"entry toSteepfile.4. Pros & Cons
4-1. Pros
NoMethodError, nil misuse, wrong argument types at analysis time.rbssignatures stay in sync with code viarbs-inlineregeneration# rbs_inline: enabled— no big-bang migration4-2. Cons
rbs-inlineafter changes.rbsfiles contain only structure (class/module/method names) withuntypedsignaturessteep check— regressions can slip through