Skip to content

Open3 method signatures do not allow the optional env hash as first argument #37

@eoinkelly

Description

@eoinkelly

Many methods in the Open3 module allow us to optionally pass a Hash as the first positional argument (the hash is used to set the environment for the spawned process) e.g.

stdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts])

The type signatures for these methods currently forbid this e.g.

module Open3
sig do
params(
cmd: T.any(String, T::Array[String]),
opts: T::Hash[Symbol, T.untyped],
block: T.proc.params(stdin: IO, stdout: IO, stderr: IO, wait_thr: Thread).void
).returns([IO, IO, IO, Thread])
end
def self.popen3(*cmd, **opts, &block); end

I can "fix" this by changing the type of the cmd from T.any(String, T::Array[String]) to cmd: T.any(String, T::Array[String], T::Hash[String, String]) but that seems wrong to me. Is there a better way to express these method signatures?

I'm happy to attempt a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions