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

development_tools: add type signatures #12149

Merged
merged 3 commits into from Sep 30, 2021

Conversation

FnControlOption
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Redefining the existing method DevelopmentTools.custom_installation_instructions as a method alias https://srb.help/5037
    35 |    alias custom_installation_instructions installation_instructions
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-alias custom_installation_instructions installation_instructions
+def custom_installation_instructions
+  installation_instructions
+end

Expected T::Boolean but found T.nilable(Pathname) for method result type https://srb.help/7005
    29 |    end
            ^^^
 def installed?
-  locate("clang") || locate("gcc")
+  locate("clang").present? || locate("gcc").present?
 end

This code is unreachable https://srb.help/7006
    21 |    return false if MacOS::Xcode.version && MacOS::Xcode.version < "8.0"
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This code is unreachable https://srb.help/7006
    22 |    return false if MacOS::CLT.version && MacOS::CLT.version < "8.0"
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-return false if MacOS::Xcode.version && MacOS::Xcode.version < "8.0"
-return false if MacOS::CLT.version && MacOS::CLT.version < "8.0"
+return false if !MacOS::Xcode.version.null? && MacOS::Xcode.version < "8.0"
+return false if !MacOS::CLT.version.null? && MacOS::CLT.version < "8.0"

Comment on lines 90 to 92
# Returns a Pathname object corresponding to Xcode.app's Developer
# directory or nil if Xcode.app is not installed.
sig { returns(Pathname) }
Copy link
Member

Choose a reason for hiding this comment

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

Given the comment here:

Suggested change
# Returns a Pathname object corresponding to Xcode.app's Developer
# directory or nil if Xcode.app is not installed.
sig { returns(Pathname) }
# Returns a Pathname object corresponding to Xcode.app's Developer
# directory or nil if Xcode.app is not installed.
sig { returns(T.nilable(Pathname)) }

Not entirely sure why Sorbet doesn't notice that however?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pathname#cleanpath returns T.untyped. Opened sorbet/sorbet#4660.

tmp = Pathname.new(dir).cleanpath
T.assert_type! tmp, Pathname
tmp
Expected a type but found T.untyped for T.assert_type! https://srb.help/7007
     106 |              T.assert_type! tmp, Pathname
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -62,6 +64,7 @@ def custom_installation_instructions
EOS
end

sig { returns(T::Hash[String, T.untyped]) }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sig { returns(T::Hash[String, T.untyped]) }
sig { returns(T::Hash[String, T.nilable(String)]) }

@@ -20,6 +21,7 @@ def default_compiler
:gcc
end

sig { returns(T::Hash[String, T.untyped]) }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sig { returns(T::Hash[String, T.untyped]) }
sig { returns(T::Hash[String, T.nilable(String)]) }

and probably append .to_s.presence to Glibc version and .to_s to oldest CPU.

def subversion_handles_most_https_certificates?
true
end

sig { returns(T::Hash[String, T.untyped]) }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sig { returns(T::Hash[String, T.untyped]) }
sig { returns(T::Hash[String, T.nilable(String)]) }

and append .to_s to CPU family.

installation_instructions
end

# TODO: This method appears to be unused. Can it be deleted?
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great work! I'm happy when @Bo98 is.

@Bo98
Copy link
Member

Bo98 commented Sep 30, 2021

Thanks!

@Bo98 Bo98 merged commit 24543c6 into Homebrew:master Sep 30, 2021
@github-actions github-actions bot added the outdated PR was locked due to age label Oct 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants