Skip to content

Apply strict sorbet typings for python files #11908

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

randhircs
Copy link
Contributor

@randhircs randhircs commented Mar 26, 2025

To enhance the code robustness and make it more reliable by providing sorbet type fix as strict.

Added signature and made method body change to make it compatible with sorbet type strict.

Feature to add sorbet type as strict and make code more robust.

Anything you want to highlight for special attention from reviewers?
To check if the return type are correct.

How will you know you've accomplished your goal?
All the tests and linters pass successfully.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@randhircs randhircs requested a review from a team as a code owner March 26, 2025 22:18
@randhircs randhircs self-assigned this Mar 26, 2025
@JamieMagee JamieMagee added the sorbet 🍦 Relates to Sorbet types label Mar 27, 2025
@randhircs randhircs force-pushed the randhircs/python-sorbet-strict-5 branch 2 times, most recently from 0cf594a to 6b70b77 Compare April 3, 2025 17:24
@kbukum1
Copy link
Contributor

kbukum1 commented Apr 16, 2025

@JamieMagee ,

Do you see any problem with this PR? If not we can merge this??

@kbukum1 kbukum1 requested a review from JamieMagee April 16, 2025 20:55
@kbukum1 kbukum1 force-pushed the randhircs/python-sorbet-strict-5 branch from 000a0c9 to 951988a Compare April 16, 2025 22:18
def package_hashes_for(name:, version:, algorithm:)
index_urls = @index_urls || [nil]
index_urls = @index_urls&.any? ? @index_urls : [nil]
Copy link
Contributor

@kbukum1 kbukum1 Apr 16, 2025

Choose a reason for hiding this comment

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

Review Tip: Instead of adding nil to index_urls before sending it, we've updated the place where we are using index_urls to add nil to the array if it's empty.

@@ -449,7 +457,7 @@ def deps_to_augment_hashes_for(updated_content, original_content)

sig { params(name: String, version: String, algorithm: String).returns(T::Array[String]) }
def package_hashes_for(name:, version:, algorithm:)
index_urls = @index_urls || [nil]
index_urls = @index_urls&.any? ? @index_urls : [nil]
Copy link
Contributor

@kbukum1 kbukum1 Apr 16, 2025

Choose a reason for hiding this comment

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

Review Tip: Instead of adding nil to index_urls before sending it, we've updated the place where we are using index_urls to add nil to the array if it's empty.

# If there are no credentials that replace the base, we need to
# ensure that the base URL is included in the list of extra-index-urls.
[nil, *urls]
urls
Copy link
Contributor

@kbukum1 kbukum1 Apr 16, 2025

Choose a reason for hiding this comment

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

Review Tip: Instead of adding nil to index_urls before sending it, we've updated the place where we are using index_urls to add nil to the array if it's empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can even omit this last urls

@@ -468,7 +468,7 @@

context "when credentials do not replace base" do
it "returns nil and authed urls for all credentials" do
expect(instance.send(:pip_compile_index_urls)).to eq([nil, "authed_url"])
expect(instance.send(:pip_compile_index_urls)).to eq(["authed_url"])
Copy link
Contributor

@kbukum1 kbukum1 Apr 16, 2025

Choose a reason for hiding this comment

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

Review Tip: Instead of adding nil to index_urls before sending it, we've updated the place where we are using index_urls to add nil to the array if it's empty.

@kbukum1 kbukum1 changed the title Provided fix for sorbet type as strict in python module Apply strict sorbet typings for python files Apr 16, 2025
@kbukum1 kbukum1 force-pushed the randhircs/python-sorbet-strict-5 branch from b83d61f to d1b6f01 Compare April 16, 2025 23:11

old_req = T.must(T.must(dependency).previous_requirements)
.find { |r| r[:file] == file.name }

return file.content unless old_req
return file.content if old_req == "==#{T.must(dependency).version}"
content = file.content
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to reassign content?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: python sorbet 🍦 Relates to Sorbet types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants