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

Add signatures for Gem::Version #610

Merged
merged 1 commit into from Mar 7, 2021
Merged

Add signatures for Gem::Version #610

merged 1 commit into from Mar 7, 2021

Conversation

ybiquitous
Copy link
Contributor

interface _HashLike[K, V]
def each_pair: () { ([ K, V ]) -> untyped } -> self
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[note] According to this advice: #605 (comment)


# True if the `version` string matches RubyGems' requirements.
#
def self.correct?: (_ToS version) -> bool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[note] It seems that nil should not be received because of the deprecation below:

$ ruby -e 'Gem::Version.correct?(nil)'
nil versions are discouraged and will be deprecated in Rubygems 4

Copy link
Member

Choose a reason for hiding this comment

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

Ah! _ToS cannot reject nil...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I missed it… 😓

I want to improve this, but can we do it? (If we can, I will create a new PR)
It's not so bad as-is, though. 😅

# Load custom marshal format. It's a string for backwards (RubyGems 1.3.5 and
# earlier) compatibility.
#
def marshal_load: (Array[String] array) -> void
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[note] #marshal_load returns nil actually, but I think it should return void because #marshal_load calls internally #initialize:

https://github.com/rubygems/rubygems/blob/v3.2.11/lib/rubygems/version.rb#L273-L275

@ybiquitous ybiquitous marked this pull request as ready for review February 25, 2021 02:17
@pocke
Copy link
Member

pocke commented Feb 25, 2021

I guess we can remove Gem::Version from polyfill.rbs.

rbs/sig/polyfill.rbs

Lines 5 to 18 in 448b67a

module Gem
class Version
def self.correct?: (String) -> bool
def self.create: (String?) -> instance?
include Comparable
def prerelease?: () -> bool
def release: () -> self
def version: () -> String
end

The polyfill is for type checking for RBS itself. you can try using it with Steep and ./steep/Gemfile.

@ybiquitous
Copy link
Contributor Author

@pocke Thanks for the comment. Should we add signature as below to remove the polyfill (not add library "rubygems")?

 target :lib do
   signature "sig"
+  signature "stdlib/rubygems"
   check "lib"
   ignore "lib/rbs/parser.rb"

Because the published version of rbs is used in steep/Gemfile:

rbs/steep/Gemfile.lock

Lines 28 to 29 in 448b67a

rbs (1.0.4)
steep (0.41.0)

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

💎

@soutaro soutaro merged commit 086661e into ruby:master Mar 7, 2021
@ybiquitous ybiquitous deleted the add-signature-for-gem-version branch March 7, 2021 08:42
soutaro pushed a commit that referenced this pull request Mar 8, 2021
The `Gem::Version` signature has been added with PR #610.
I think we now can remove the polyfill of `Gem::Version`.

Follow-up of <#610 (comment)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants