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

Improve #to_str and #to_json for Version::NULL. #15403

Merged
merged 1 commit into from
May 11, 2023

Conversation

reitermarkus
Copy link
Member

@reitermarkus reitermarkus commented May 11, 2023

  • 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?

Mentioned this here: #15402 (comment)


sig { returns(String) }
def to_str
raise NoMethodError, "undefined method `to_str' for #{self.class}:NULL" if null?
Copy link
Member Author

Choose a reason for hiding this comment

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

This is kinda hacky, would probably make more sense to deprecate Version#to_str instead.

Copy link
Member

@Bo98 Bo98 May 11, 2023

Choose a reason for hiding this comment

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

Sounds tricky to deprecate given implicit conversions - can't really search to see what does that and there's likely cases in formulae (which we only run full CI on when we touch them). And all over place really for stuff like: Pathname("...")/version

But doing what you're doing here for NULL does seem worthwhile to stop any subtle bugs.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the Pathname("...")/version case we could actually implement Version#to_path instead.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't exactly much of an improvement over to_str though.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds tricky to deprecate given implicit conversions

Agreed 👍🏻

@reitermarkus reitermarkus force-pushed the version-null-to_str branch 2 times, most recently from 7e73196 to e081a42 Compare May 11, 2023 09:53
@reitermarkus reitermarkus requested a review from Bo98 May 11, 2023 09:57
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.

Thanks @reitermarkus!


sig { returns(String) }
def to_str
raise NoMethodError, "undefined method `to_str' for #{self.class}:NULL" if null?
Copy link
Member

Choose a reason for hiding this comment

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

Sounds tricky to deprecate given implicit conversions

Agreed 👍🏻

@reitermarkus reitermarkus force-pushed the version-null-to_str branch from e081a42 to 5c9c089 Compare May 11, 2023 17:17
@reitermarkus reitermarkus enabled auto-merge May 11, 2023 17:17
@reitermarkus reitermarkus merged commit aa450ea into Homebrew:master May 11, 2023
@reitermarkus reitermarkus deleted the version-null-to_str branch May 11, 2023 17:33
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2023
@nandahkrishna
Copy link
Member

@reitermarkus For some reason this commit seems to be causing a weird CI failure on Linux (at Homebrew/homebrew-core#135761), or so git bisect tells me. We have:

$ brew install -sdv sbcl
...
/usr/bin/env tar --extract --no-same-owner --file /home/linuxbrew/.cache/Homebrew/downloads/d7b3eb2dadc3855f0103ab9789d3ab39e733dc7f17bac5b9c62f2c8bb1ebd2f2--sbcl-2.3.4-source.tar.bz2 --directory /tmp/d20230704-32234-1gq982l
/usr/bin/env cp -pR /tmp/d20230704-32234-1gq982l/sbcl-2.3.4/. /tmp/sbcl-20230704-32234-1j56edt/sbcl-2.3.4
==> Temporary files retained at:
/tmp/sbcl-20230704-32234-1j56edt
Error: An exception occurred within a child process:
  TypeError: no implicit conversion of MacOSVersion into String

And I'm unable to debug the exact cause of this. Do you think you could look into this or point me to a fix?

@Bo98
Copy link
Member

Bo98 commented Jul 4, 2023

ENV["SBCL_MACOSX_VERSION_MIN"] = MacOS.version if OS.mac? should fix it (or .to_s but I prefer the if given that's the direction we're generally going).

Technically it's a compatibility break yeah. Though it's hard to deprecate the old behaviour and we seem to have survived a few weeks without many noticing. We perhaps could have a special to_str in MacOSVersion that doesn't throw an error until we properly deprecate MacOS.version fully on Linux. I think I mentioned that in Slack at the time but no one mentioned the issue again in the weeks since.

@nandahkrishna
Copy link
Member

Ah alright. I thought it should be fixed in Homebrew/brew but I'll just edit the Formula for now. Thanks!

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.

5 participants