-
Notifications
You must be signed in to change notification settings - Fork 22
Translate T.cast
and T.must
into RBS comments
#714
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
5e801ba
to
23a9d85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to constructs like:
foo = T.cast(T.must(T.must(bar).baz).quux, String)
If we are not handling them then it might be good to make that explicit in the option messages and with tests.
@@ -11,6 +11,9 @@ class Assertions < Thor | |||
desc "translate", "Translate type assertions from/to RBI and RBS" | |||
option :from, type: :string, aliases: :f, desc: "From format", enum: ["rbi"], default: "rbi" | |||
option :to, type: :string, aliases: :t, desc: "To format", enum: ["rbs"], default: "rbs" | |||
option :let, type: :boolean, desc: "Translate `T.let` to `nil #: String?`", default: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inclusion of nil
here looks out of place to me:
option :let, type: :boolean, desc: "Translate `T.let` to `nil #: String?`", default: true | |
option :let, type: :boolean, desc: "Translate `T.let` to `#: String`", default: true |
I think a better message would be:
option :let, type: :boolean, desc: "Translate `T.let` to `nil #: String?`", default: true | |
option :let, type: :boolean, desc: "Translate `T.let(x, String)` to `x #: String?`", default: true |
option :cast, type: :boolean, desc: "Translate `T.cast` to `# as String`", default: true | ||
option :must, type: :boolean, desc: "Translate `T.must` to `# as not nil`", default: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my suggestion above is accepted, then better messages would be:
option :cast, type: :boolean, desc: "Translate `T.cast` to `# as String`", default: true | |
option :must, type: :boolean, desc: "Translate `T.must` to `# as not nil`", default: true | |
option :cast, type: :boolean, desc: "Translate `T.cast(x, String)` to `x # as String`", default: true | |
option :must, type: :boolean, desc: "Translate `T.must(x)` to `x # as !nil`", default: true |
option :cast, type: :boolean, desc: "Translate `T.cast` to `# as String`", default: true | ||
option :must, type: :boolean, desc: "Translate `T.must` to `# as not nil`", default: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option :cast, type: :boolean, desc: "Translate `T.cast` to `# as String`", default: true | |
option :must, type: :boolean, desc: "Translate `T.must` to `# as not nil`", default: true | |
option :cast, type: :boolean, desc: "Translate `T.cast` to `# as String`", default: true | |
option :must, type: :boolean, desc: "Translate `T.must` to `# as !nil`", default: true |
@annotation_methods << :let if let | ||
@annotation_methods << :cast if cast | ||
@annotation_methods << :must if must | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to do:
@annotation_methods.freeze |
here.
This will now allow to translate
T.must
into RBS comments so this:becomes this:
And
T.must
so this:becomes this: