Skip to content

Incorrect names of arguments in Python function overloads #3574

@krassowski

Description

@krassowski

Describe the bug
For example here, the overload definition suggests that an argument remote_path can be supplied:

@overload
def upload_file(self, file: bytes, remote_path: str, timeout: int = 30 * 60) -> None:
"""Uploads a file to the specified path in the Sandbox. If a file already exists at
the destination path, it will be overwritten. This method is useful when you want to upload
small files that fit into memory.
Args:
file (bytes): File contents as a bytes object.
remote_path (str): Path to the destination file. Relative paths are resolved based on
the sandbox working directory.
timeout (int): Timeout for the upload operation in seconds. 0 means no timeout. Default is 30 minutes.
Example:
```python
# Upload a text file
content = b"Hello, World!"
sandbox.fs.upload_file(content, "tmp/hello.txt")
# Upload a local file
with open("local_file.txt", "rb") as f:
content = f.read()
sandbox.fs.upload_file(content, "tmp/file.txt")
# Upload binary data
import json
data = {"key": "value"}
content = json.dumps(data).encode('utf-8')
sandbox.fs.upload_file(content, "tmp/config.json")
```
"""

But doing so causes it to raises and error:

    await sandbox.fs.upload_file(
          ^^^^^^^^^^^^^^^^^^^^^^^
          remote_path="/tmp/test",
          file=b"test",
      )
TypeError: AsyncFileSystem.upload_file() got an unexpected keyword argument 'remote_path'

This is not surprising because the actual function definition does not accept remote_path at all:

def upload_file( # pyright: ignore[reportInconsistentOverload]
self, src: str | bytes, dst: str, timeout: int = 30 * 60
) -> None:
self.upload_files([FileUpload(src, dst)], timeout)

To Reproduce

Use keyword arguments with API

Expected behavior

The API overloads should not use parameter names which do not work.

If for some reason only positional-only arguments are expected, the overloads should use / marker to specify it (see https://peps.python.org/pep-0570/).

Screenshots
None

Environment (required fields):

  • Daytona client: Latest as quoted by code
  • Daytona Version: [Found in the dashboard]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions