trycua/cua

Variable shadowing in computer class breaks shared directories.

Open

#124 aperta il 23 apr 2025

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)HTML (1051 fork)batch import
good first issue

Metriche repository

Star
 (16.722 star)
Metriche merge PR
 (Merge medio 1g 9h) (119 PR mergiate in 30 g)

Descrizione

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.

Guida contributor