Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Steepで使えるコマンドを見てみよう
Search
ikuma-t
February 03, 2022
Programming
1.3k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Steepで使えるコマンドを見てみよう
omotesando.rb#71の登壇資料です
ikuma-t
February 03, 2022
More Decks by ikuma-t
See All by ikuma-t
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.5k
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
1.2k
いまさらのStorybook
ikumatadokoro
0
1.1k
これで最後にしたい! Astroと立ち向かう 6度目の個人ブログ再開発
ikumatadokoro
6
2.7k
Panda CSS と Ark UI ではじめる個人開発
ikumatadokoro
4
3.1k
見た目から始める生産性向上
ikumatadokoro
12
6.2k
ぼくが 美容師さんに伝えたかった バンドの話
ikumatadokoro
0
370
Railsアプリをコスパよく読むための環境整備
ikumatadokoro
2
1.4k
HTTPを手で書いて学ぶ ファイルアップロードの仕組み
ikumatadokoro
82
34k
Other Decks in Programming
See All in Programming
パスワード再設定メールのURLについて知っておこう
uyuki234
0
180
Modernizing iOS Apps
seyfoyun
0
120
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.4k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
120
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
120
Performance Optimization With LLMs
xleitix
0
200
contenteditable と日本語入力に向き合う
colorful12
0
220
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
160
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
1
200
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
120
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
460
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
We Are The Robots
honzajavorek
0
400
Facilitating Awesome Meetings
lara
57
7.2k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Everyday Curiosity
cassininazir
0
360
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Scaling GitHub
holman
464
140k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
480
Google's AI Overviews - The New Search
badams
0
1.6k
Leo the Paperboy
mayatellez
10
2.4k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Transcript
Steep で使えるコマンドを見てみよう! Omotesando.rb#71 @ikuma-t
Self Introduction 🗣 名前 - ikuma-t 🐤 Twitter - @ikumatdkr
😸 GitHub - IkumaTadokoro ✍️ Blog - セットプチフォッカ FJORD BOOT CAMP ってところでエンジニア目指して勉強しています 最近はじめてのGem をつくりました:jp_local_gov 趣味は作曲家めぐり・ツール漁り・アニメ鑑賞・ドット絵 自己紹介
みなさん、RBS 書いてますか? 自分はあんまり書いていない
RBS といえばSteep
型書いて、steep check して終わり
Steep には steep check 以外にも 使用できるコマンドがある
Steep には steep check 以外にも使用できるコマンドがある コマンド 概要 init Steepfile を作成する
check 静的チェックを実行する validate 型定義自体の文法チェックを実行する project Steepfile に基づいて対象プロジェクトの構造を表示する stats お型付け具合をチェックする watch リアルタイムで変更をキャッチして、静的チェックを実行できる langserver LSP を起動する annotations インラインアノテーションの一覧を表示する
Steep で使えるコマンドを見てみよう! 検証はSteep 0.47.0 で行っています
steep project Steepfile で定義されているプロジェクトを出力する 1 $ steep project 2 3
Target: 4 lib: 5 sources: 6 patterns: 7 - lib 8 ignores: 9 files: 10 - lib/jp_local_gov/base.rb 11 ... 12 signatures: 13 patterns: 14 - sig 15 files: 16 - sig/jp_local_gov/base.rbs 17 ... 18 libraries: 19 library dirs: 20 - core: ...
steep validate 型定義の文法的誤りをチェックできる ソース 1 def hoge?(word) 2 word.size ==
1 3 end RBS def hoge?: (String word) >- bool 実行結果 1 $ steep validate 2 sig/jp_local_gov.rbs:28:27: [error] sig/jp_local_gov.rbs:28:27...28:28: Syntax error: 3 │ Diagnostic ID: RBS::SyntaxError 4 │ 5 └ def hoge?: (String word) >- bool 6 ~
steep stats 型付けの統計情報を確認することができる 1 $ steep stats --format={csv | table}
で出力形式を切り替えることができる(デフォルトはSTDOUT.tty? に則る) 小規模なGem ですら100% にすることはできなかったのだ… Refs: https://github.com/soutaro/steep/pull/360 2 3 # Calculating stats: 4 5 Target File Status Typed calls Untyped calls All calls Typed % 6 -------------------------------------------------------------------------------------------------- 7 lib lib/jp_local_gov.rb success 69 5 74 93% 8 lib lib/jp_local_gov/base.rb success 4 0 4 100% 9 lib lib/jp_local_gov/local_gov.rb success 8 0 8 100% 10 lib lib/jp_local_gov/random.rb success 16 4 20 80% 11 lib lib/jp_local_gov/version.rb success 0 0 0 100% ` `
折り返し:steep check はTea が出る steep check を実行した際にエラーがなければ、Tea 「🫖」が出る 5 No
type error detected. 🫖 実は出てくるのは「🫖」だけではなくて、ほかの絵文字(全4 種)が出ることもある。 残りの絵文字はだいたい10% くらいの確率で出るので試してみては? 1 # Type checking files: 2 3 ...................................................................... 4
steep annotations インラインアノテーションの使用箇所を一覧することができる RBS 1 # @type var hoge: String
2 hoge = "hoge" steep annotations の実行 1 $ steep annotations 2 lib/jp_local_gov/random.rb:18:4:def: def sample_data 3 @type var hoge: String Refs: https://github.com/soutaro/steep/blob/master/manual/annotations.md ` `
steep watch webpack のwatch モードみたいなもの(公式談) ソースの変更時に静的チェックをリアルタイムで実行してくれる RBS 側はコマンドを実行した時点での情報を参照している模様 Refs: https://github.com/soutaro/steep/pull/77
1 # 監視対象のディレクトリを指定して起動 2 steep watch lib 3 👀 Watching directories, Ctrl-C to stop. # 監視状態になる 4 🔬 Type checking updated files... # ソース側が変更されると、自動でチェックが行われる 5 lib/jp_local_gov.rb:81:6: [error] Cannot allow method body have type `::Integer` because declared as type `::Array 6 │ ::Integer <: ::Array[::String] 7 │ ::Numeric <: ::Array[::String] 8 │ ::Object <: ::Array[::String] 9 │ ::BasicObject <: ::Array[::String] 10 │ 11 │ Diagnostic ID: Ruby::MethodBodyTypeMismatch 12 │ 13 └ def prefecture_code_list 14 ~~~~~~~~~~~~~~~~~~~~ 15 🔬 Type checking updated files...
steep langserver LSP… なんですが、ごめんなさい、RubyMine で実証できませんでした🙏 Refs: https://github.com/soutaro/steep/pull/79 一応ここのPR のコメントでRubyMine での実行方法も書いてあるけどうまくいかない…
まとめ Steep にはあんまり知られていないけど、いろんなコマンドがある! Steep をどんどん使って、Ruby での型定義を活発にしていこう!(私はAST を頑 張って勉強します… )