-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added sorbet typecheck under python module on 5 files #11261
base: main
Are you sure you want to change the base?
Conversation
0032c61
to
601f7de
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.
You have to change the typed:true
to typed:strict
; see this example
Sure, I change it. |
1b814d7
to
6799716
Compare
6799716
to
bf7b0ec
Compare
… setup_file_sanitizer.rb, language_version_manager.rb,pipenv_runner.rb,index_finder.rb
aca58f5
to
955f98a
Compare
@@ -198,14 +198,15 @@ def setup_python_environment | |||
nil | |||
end | |||
|
|||
sig { params(package_manager: String, version: String).void } | |||
sig { params(package_manager: String, version: String).returns(T.nilable(T::Boolean)) } |
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.
why is this a nilable boolean?
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.
Yes, I also think all conditions are handled. It shouldn't be nillable.
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.
Yeah, I corrected it now, thanks to both of you.
@@ -383,6 +394,7 @@ def parsed_requirement_files | |||
raise Dependabot::DependencyFileNotEvaluatable, e.message | |||
end | |||
|
|||
sig { params(requirements: T.untyped).returns(T.untyped) } |
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.
are requirements actually untyped?
@@ -8,11 +8,13 @@ | |||
require "dependabot/python/file_parser" | |||
require "dependabot/python/native_helpers" |
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.
can you update the typed: strict here too?
@@ -32,7 +33,7 @@ class FileParser < Dependabot::FileParsers::Base | |||
pipfile: "dev-packages", | |||
lockfile: "develop" | |||
} | |||
].freeze | |||
].freeze, T::Array[T::Hash[T.untyped, T.untyped]]) |
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.
Suggested Change: Instead of using T::Hash[T.untyped, T.untyped]
, use T::Hash[Symbol, String]
(or another more specific type) to improve type safety and clarity.
Reasoning:
T.untyped
allows any type, which weakens Sorbet’s ability to provide meaningful type checks.- By specifying
Symbol
as the key type andString
as the value type (or another suitable type if necessary), you:- Make the code's intent clearer.
- Enable Sorbet to catch potential mismatches early.
- Provide better documentation for others reading or maintaining the code.
def group_from_filename(filename) | ||
if filename.include?("dev") then ["dev-dependencies"] | ||
else | ||
["dependencies"] | ||
end | ||
end | ||
|
||
sig { params(dep: T.untyped).returns(T::Boolean) } | ||
def blocking_marker?(dep) |
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 is this T.untyped
? Is it something changing dependency to the situation?
@@ -316,6 +320,9 @@ def blocking_marker?(dep) | |||
end | |||
end | |||
|
|||
sig do | |||
params(marker: T.untyped, python_version: T.any(String, Integer, Gem::Version)).returns(T::Boolean) | |||
end |
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.
I think T.untyped
is not proper unless necessary
@@ -337,6 +344,10 @@ def marker_satisfied?(marker, python_version) | |||
result | |||
end | |||
|
|||
sig do | |||
params(condition: T.untyped, |
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.
Same here, T.untyped
?
end | ||
|
||
sig { returns(T.untyped) } |
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.
I think we do have return type here but not sure.
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.
I think mostly there are lots of T.untyped
which is not preferred approach. The typing doesn't have any value when it is T.untyped.
What are you trying to accomplish?
Requirement is to add Sorbet TypeCheck under Python module, Selected files are updated with TypeCheck.
Anything you want to highlight for special attention from reviewers?
TypeCheck are having correct data type params and return data type.
How will you know you've accomplished your goal?
Checklist