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

[socket] Add RBS file for "socket" #699

Merged
merged 6 commits into from
Jul 5, 2021
Merged

Conversation

HoneyryderChuck
Copy link
Contributor

Added RBS signatures for the "socket" package (no tests).

core/socket.rbs Outdated
# could be called like this:
# sock.setsockopt(:SOCKET, :REUSEADDR, true)
# sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
# sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true))
Copy link
Member

Choose a reason for hiding this comment

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

[Goodcheck] Prefer boolish over bool for method arguments and block return values (view)

See the doc below:
https://github.com/ruby/rbs/blob/78d04a2db0f1c4925d2b13c2939868edf9465d6c/docs/syntax.md#bool-or-boolish

Rule
rbs.prefer_boolish

You can close this issue if no need to fix it. Learn more.

This is a false detection. Closing.

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.

I really appreciate this great work! 🙏

I want to ask you to change the file name.

  • Could you move the file under stdlib/socket/0 directory, because socket is not built-in?
  • How about splitting files for each classes, like basic_socket.rbs, socket.rbs, ...? (This is optional but would make reading and future updates easier.)

core/socket.rbs Outdated

private

def __recv_nonblock: (untyped, untyped, untyped, untyped) -> untyped
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fine to leave it as is, I suppose? :)

Copy link
Member

Choose a reason for hiding this comment

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

Yes. It's fine to leave the defs here.

@soutaro soutaro self-assigned this Jul 4, 2021
@HoneyryderChuck
Copy link
Contributor Author

@soutaro thx. Just committed the changes you proposed. hope it's fine.

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.

Thank you so much! 👍

@soutaro soutaro merged commit e8d52c0 into ruby:master Jul 5, 2021
@HoneyryderChuck HoneyryderChuck deleted the socket branch July 5, 2021 07:07
# Socket.new(:UNIX, :STREAM) # UNIX stream socket
# Socket.new(:UNIX, :DGRAM) # UNIX datagram socket
#
def initialize: (Symbol domain, Symbol socktype, ?Integer protocol) -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we can write socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) where the parameters are Integer?

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.

3 participants