cua icon indicating copy to clipboard operation
cua copied to clipboard

Variable shadowing in computer class breaks shared directories.

Open brad-kenstler opened this issue 8 months ago • 3 comments

This section in the Computer.__init__ method:

 if shared_directories:
    for path in shared_directories:
        abs_path = os.path.abspath(os.path.expanduser(path))  # type: ignore[attr-defined]
        if not os.path.exists(abs_path):  # type: ignore[attr-defined]
            raise ValueError(f"Shared directory does not exist: {path}")
        self.shared_paths.append(abs_path)

fails with:

abs_path = os.path.abspath(os.path.expanduser(path))  # type: ignore[attr-defined]
               ^^^^^^^
AttributeError: 'str' object has no attribute 'path'

because the module name is being shadowed by the init variable os, which is a string (macos, linux).

Please fix.

brad-kenstler avatar Apr 23 '25 05:04 brad-kenstler

See: https://github.com/trycua/cua/pull/145

Resolved by renaming the argument os to os_type to avoid collision with the module

FinnBorge avatar Apr 29 '25 01:04 FinnBorge

@brad-kenstler can you review to see whether this can be closed now that a solution has been implemented?

FinnBorge avatar May 02 '25 19:05 FinnBorge

Is this issue still open or is it closed? It is showing open but the PR was submitted by @FinnBorge

Amrithesh-Kakkoth avatar Jul 17 '25 09:07 Amrithesh-Kakkoth