Skip to content

Fix IO#reopen, add open3 missing sigs #2359

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HoneyryderChuck
Copy link
Contributor

IO#reopen should be able to receive the same kwargs that IO#open receives; also, the mode can be an integer too.

Have a separate commit adding missing sigs for open3. @soutaro this is currently a WIP, as the sigs can't be expressed fully in RBS:

  • most functions accept an optional options hash at the end, despite commands (string) already supporting optional (string) args as well. it's like a second set of optional args, and this can't be expressed in RBS.
  • some functions (i.e. pipeline_w return an array where the first element is stdin/stdout (IO) and the rest is one or more wait threads. "variable size" tuples can't be expressed in RBS yet as well.

like in initialize, it can also receive an integer as mode; also, the same accepted kwargs from initialize are also accepted here
Copy link
Collaborator

@ksss ksss left a comment

Choose a reason for hiding this comment

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

I think it would be better with test code.

# Open3.capture2('echo', 'hello', 'world')
# # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
#
def self.capture2: (?Hash[String, String] env, *String cmds, ?Hash[untyped, untyped] options) -> [IO, Process::Status]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a syntax error.
It seems to me that it would be better expressed in overload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, hence why I opened this PR in a broken state. I believe that this is a valid and common signature across the stdlib (i.e. options hash optionally at the end) that RBS should be able to acknowledge. I don't think that overload would express it better.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for IO#popen

@HoneyryderChuck
Copy link
Contributor Author

@ksss I'll write the tests once we address the broken behaviour for this type of signature 👍

@@ -143,5 +240,827 @@ module Open3
# Open3.capture2e('echo', 'hello', 'world')
# # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
#
def self.capture2e: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
def self.capture2e: (?Hash[String, String] env, *String cmds, ?Hash[untyped, untyped] options) -> [IO, Process::Status]
Copy link
Contributor

Choose a reason for hiding this comment

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

The capture* methods return strings, not streams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy