-
Notifications
You must be signed in to change notification settings - Fork 0
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 more things #24
Type more things #24
Conversation
sig/graft/hook_point.rbs
Outdated
@@ -66,7 +66,7 @@ module Graft | |||
|
|||
def disabled?: (String key) -> bool | |||
|
|||
module Prepend | |||
module Prepend : HookPoint |
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 does this mean?
Does it mean HookPoint
class will include this module?
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 self type parameter constraints the Prepend
module to only be mixed in HookPoint
, therefore Prepend
can assume having access to HookPoint
methods.
This happens automatically in HookPoint#initialize
:
def initialize(hook_point, strategy = DEFAULT_STRATEGY)
@klass_name, @method_kind, @method_name = HookPoint.parse(hook_point)
@strategy = strategy
extend HookPoint.strategy_module(strategy)
end
The actual implementation of a given strategy is composed into HookPoint
, which only provides a uniform interface largely independent of the strategy.
Steep does static type checking, so: a. sees the conditional `def` twice b. can't have conditional definitions c. uses one definition for both With `define_method`, Steep considers the definition dynamic and does not try to check the method.
Two main cases: - `attr_*` needs `@dynamic`: soutaro/steep#1036 - three `define_method` because of the `RUBY_VERSION` condition
This `self` constraint declares what the module can extend, and therefore makes the corresponding `self` methods visible inside these modules.
When using `case` steep types the unreachable `else` as `bot`, which ends up having no `#inspect`. Theoretically we would remove the unreachable fallback (`else` or simply code after `end`) but out of caution we want this safety check. Workaround it with a few `if`.
This is done in two steps: - Split per-version code, each into their own file - Type only for one (current) version category - Ignore the other (legacy) type category Both could be type-checked with targets, but this would need this issue to be solved: soutaro/steep#978
This also resolves steep typing without hints, and is actually more consistent.
And now typing passes! The trickier bits were mostly because:
|
This is an attempt to fix as much typing issues as possible, ideally all.