Finalize methods that do not support overrides#16640
Finalize methods that do not support overrides#16640MikeMcQuaid merged 2 commits intoHomebrew:masterfrom
Conversation
| cc: T.nilable(String), | ||
| build_bottle: T::Boolean, | ||
| bottle_arch: T.nilable(String), | ||
| ).returns(T.untyped) |
There was a problem hiding this comment.
Note that this method currently returns nil or T::Private::Types::Void::VOID, which is clumsy/incorrect to encode in a type signature. However, we currently have a test that relies on this being nil/non-nil depending on circumstance, so I didn't undertake a refactor. Feel free to weigh in if you want this to be resolved by other means though.
There was a problem hiding this comment.
I think this is kinda weird, since ENV#prepend_path can technically return nil masked as T::Private::Types::Void::VOID, right?
There was a problem hiding this comment.
I'd say this should always return nil, or we just remove the test and make it .void.
Probably the latter since we don't have any test/usage that uses the return value anyways.
There was a problem hiding this comment.
Agreed that we should probably update the test here.
There was a problem hiding this comment.
I made the return type consistently void, and also updated the test to assert no error occurs (very roughly equivalent to checking for nil return, in this case).
| env: T.nilable(String), | ||
| cc: T.nilable(String), | ||
| build_bottle: T::Boolean, | ||
| bottle_arch: T.nilable(String), |
There was a problem hiding this comment.
params are based on https://github.com/Homebrew/brew/blob/master/Library/Homebrew/extend/ENV.rb#L36-L39 (though I noticed that build_bottle is T.nilable(T::Boolean) in some places)
There was a problem hiding this comment.
I think T::Boolean is preferable in most cases. We should adjust the call sites to avoid T.nilable(T::Boolean) being passed where this is still the case.
|
@dduugg what's the latest here? |
fc2a670 to
e7e4ecc
Compare
Sorry for the latency here, PTAL. I've updated the signature and test per comments. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good, thanks for the quick update @dduugg!
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?I noticed some methods with comments discouraging overrides. Let's enforce that in code instead.
See: https://sorbet.org/docs/final