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
Refactor module_function to reduce rbi need #15249
Conversation
52f7367
to
cd12c5f
Compare
cd12c5f
to
f8b27e6
Compare
# TODO: bump version when new Xcode macOS SDK is released | ||
# NOTE: We only track the major version of the SDK. | ||
::Version.new("13") | ||
end | ||
private :latest_sdk_version |
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 was useless, since it only affected the instance method, which was already private. For example: https://github.com/Homebrew/brew/blob/e98bfdd/Library/Homebrew/os/mac/xcode.rb#L69
f8b27e6
to
af8a422
Compare
af8a422
to
df5c584
Compare
Thanks again @dduugg! |
@@ -32,7 +32,7 @@ def initialize(regex, max_length, replacement) | |||
# rewrite_shebang detected_python_shebang, bin/"script.py" | |||
# | |||
# @api public | |||
sig { params(rewrite_info: RewriteInfo, paths: T::Array[T.any(String, Pathname)]).void } |
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.
It looks like sig
validation is another victim of module_function
(I had to revert this due to the instance use in Formula
, but kept the type signature fix here).
Utils::Shebang::RewriteInfo.new( | ||
%r{^#! ?/usr/bin/(?:env )?python(?:[23](?:\.\d{1,2})?)?( |$)}, | ||
28, # the length of "#! /usr/bin/env pythonx.yyy " | ||
"#{python_path}\\1", | ||
) | ||
end | ||
|
||
def detected_python_shebang(formula = self, use_python_from_path: false) | ||
def self.detected_python_shebang(formula = self, use_python_from_path: false) |
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 is a mixin module as documented above and this breaks it.
See formulae which invoke include Language::Python::Shebang
and call detected_python_shebang
.
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.
Reverted in #15259, PTAL
module_function | ||
|
||
def detected_perl_shebang(formula = self) | ||
def self.detected_perl_shebang(formula = self) |
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.
Ditto
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?module_function
is hard to get right, as it creates methods in multiple namespaces (a private instance and a public class method), and the resulting code needs to make sure that references resolve in both places. Aliases and visibility modifiers are also hard to get right. (It's also confusing for end users, as it creates uncertainty around which is the right way to make use of the module.)A lot of this was cleaned up when enabling typechecking, but i've ported a few more in this PR. This was primarily motivated by the desire to reduce the need for custom
.rbi
files, which have been cut by 30% (70 → 49).