-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Type livecheck.rb
.
#15279
Type livecheck.rb
.
#15279
Conversation
e7f467e
to
db5bafa
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.
Sorry, I don't think having this in livecheck is the right approach. As mentioned in Slack, audit.rb
already provides throttling for formulae: we should use the same approach for casks.
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.
Sorry, I don't think having this in livecheck is the right approach. As mentioned in Slack,
audit.rb
already provides throttling for formulae: we should use the same approach for casks.
I agree with Mike. I unfortunately wasn't explicit in past discussions but when I mentioned handling throttling outside of livecheck, I was thinking that it would be in line with the setup that we have for formulae (e.g., handled in an audit_exceptions/throttled_casks.json
file in cask taps).
This is based on “version is a multiple of n”, which definitely will not work for most cask versions. Also, having this in audit is the wrong approach in my opinion. It handles the symptom (open version bump PRs), not the source of the problem (opening them in the first place). At the point where we run CI for a PR, a failing audit is more maintenance work than just approving the version bump. So it should be handled in |
db5bafa
to
8c9a779
Compare
Happy to merge one type-checking is 💚, thanks @reitermarkus!
@reitermarkus can you elaborate on why you don't think this will work and what you were/are proposing instead?
I don't agree that this is necessary, honestly. This doesn't seem different to another audit and I'd like to see evidence that these audits are being ignored in bumps before we deviate approach here. In general: I think casks and formulae for both user and contributors should be as similar as possible. Where they deviate it adds friction, bugs and confusing for everyone. Sometimes this is necessary, many times it is not. |
Ignoring audits in bumps was suggested here: Homebrew/homebrew-cask#145518 |
Library/Homebrew/livecheck.rb
Outdated
@@ -13,12 +13,9 @@ | |||
# [`brew livecheck` documentation](https://docs.brew.sh/Brew-Livecheck). | |||
class Livecheck | |||
extend Forwardable | |||
extend T::Sig |
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.
This can (and needs to be) removed due to #15306
Testing the specific content of error messages is fragile IME (for instance, it could also break on a sorbet update). If you waned to be thorough, one suggestion could be a test helper that expects a |
I think just testing for any My question was more a decision between these options:
|
Ah, ok, I think I better understand now. Yeah, testing that a sig'd method raises a TypeError with the wrong type would generally not be useful. (We do have the wrinkle though that folks generally have runtime type checking disabled, but also that tests force runtime typechecking 🤕. I guess it would come down to the specific code and how likely it is for an end user to be able to force the wrong types in…) |
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 do we want to do here regarding
TypeError
s? Remove the explicit errors or just simplify the tests to not check the error message?
Since type checking doesn't come into play when brew livecheck
is run, we still need the manual exceptions in the DSL methods. We can't cover those lines with tests after the Livecheck
DSL is typed (since Sorbet raises a TypeError
before we can reach the manual exception), so keeping those test cases around wouldn't make a functional difference. We would basically be testing Sorbet at that point, which we don't want to do.
Unless we can disable Sorbet's type checking for these specific test cases, I would say: leave the manual exceptions in the Livecheck
DSL methods and we can just remove the related test cases in livecheck_spec.rb
. There's some related Sorbet runtime documentation that seemingly explains how to control the runtime for specific type signatures but I'm not sure if any of it is feasible in relation to how we do things with brew typecheck
, brew tests
, etc. I haven't looked into it but I figured I would mention it, at least.
The other test failures I'm seeing relate to the signature for package_or_resource
. We should arguably be using Cask::Cask
(since that's what we're working with in brew livecheck
) but that leads to a bunch of type errors based on how we're creating test cask objects, so we'll need to find a way of creating the test casks as Cask::Cask
objects.
I'm also seeing failures in relation to livecheckable_f
in livecheck_spec.rb
(e.g., Parameter 'package_or_resource': Expected type T.any(Cask::Cask, Resource, T.class_of(Formula)), got type #<Class:0x0000000116a2d4d0> with value #<Formula formula_name (sta...-core/Formula/formula_name.rb>
) but I'm not immediately sure what the issue is there.
It could very easily. We could start setting |
Yes, I agree. At the very least |
Makes sense to me. I haven't ever run livecheck with |
I've opened a PR to bit the bullet and enable this for all Homebrew's developer commands and everyone with |
(assuming that PR gets merged: I think, yes, we can strip all |
Library/Homebrew/livecheck.rb
Outdated
@@ -37,7 +35,8 @@ def initialize(package_or_resource) | |||
# | |||
# @param cask_name [String] name of cask to inherit livecheck info from | |||
# @return [String, nil] |
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 do you think of removing the YARD type annotations? (yard-sorbet
is just going to use the sig
types anyway)
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 YARD types are redundant (as mentioned) but the parameter descriptions are still useful for documentation purposes. If we can keep the descriptions but omit the types, that makes sense to me (i.e., we wouldn't have to waste time keeping the YARD types in line with the Sorbet method signatures).
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.
Agreed that it'd be nice to try and drop these types.
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'd be nice if we could just swap out all the YARD types for sorbet sig
s. I filed AaronC81/sord#167 since that's the most similar project, I should have some bandwidth to take a stab at it in the summer.
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.
Ideally, docs would be correctly generated from
sig {
params(
# name of cask to inherit livecheck info from
cask_name: String
).returns(T.nilable(String))
}
5e6a11e
to
eb91a87
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.
The requested YARD changes look good. I have a couple questions, but they aren't blocking (and apologies if i missed any earlier discussion).
Also, I'd rather we use T.absurd
for exhuastiveness checking over the approach we're using here (and elsewhere), but that would require us to enable runtime errors for that specific method (which isn't difficult, just something we've consciously avoided for all sorbet runtime checks).
I ran out of time today but I'll test and review this again in the next day or two (hopefully Friday evening, EDT). |
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.
One tweak needed and good to merge 👍🏻. Thanks @reitermarkus!
eb91a87
to
2eb41b1
Compare
2eb41b1
to
dfc9d94
Compare
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?