Skip to content
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

add types to DependencySnapshot #8986

Merged
merged 5 commits into from
Feb 6, 2024
Merged

Conversation

jakecoffman
Copy link
Member

I changed a few of the memoized methods into methods that calculate during initialization as the types work out much more easily this way.

@jakecoffman jakecoffman requested a review from a team as a code owner February 5, 2024 18:20
@jakecoffman jakecoffman added the sorbet 🍦 Relates to Sorbet types label Feb 5, 2024
@@ -170,7 +170,7 @@ def mark_job_as_processed(base_commit_sha)
span&.finish
end

sig { params(dependencies: T::Array[T::Hash[Symbol, T.untyped]], dependency_files: T::Array[DependencyFile]).void }
sig { params(dependencies: T::Array[T::Hash[Symbol, T.untyped]], dependency_files: T::Array[String]).void }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess runtime validation isn't working for this part of the code because it's been wrong and I don't see any TypeErrors for it. It would happen for each job so we'd definitely notice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we're exposing this now, and can we verify that it's actually always taking a string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see in all the smoke tests, the data for the update_dependency_list endpoint's dependency_files is always an array of strings: https://github.com/dependabot/smoke-tests/blob/258269368c3c68116cf569bfed8bbafa5fcdc8e5/tests/smoke-bundler.yaml#L97

How come we're exposing this now

Now that we've got more and more files typed, things are falling into place and mistakes made earlier are getting fixed. If there was no runtime error then no problem I guess 🤷


@dependencies = parse_files!
@dependencies = T.let(parse_files!, T::Array[Dependabot::Dependency])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of interesting that Sorbet doesn't infer the types for these methods that are defined in the same file.

@jakecoffman jakecoffman merged commit 8399736 into main Feb 6, 2024
121 checks passed
@jakecoffman jakecoffman deleted the jakecoffman/type-dep-snap branch February 6, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sorbet 🍦 Relates to Sorbet types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants