trycua/cua

Variable shadowing in computer class breaks shared directories.

Aberta

#124 aberto em 23 de abr. de 2025

 (3 comentários) (0 reação) (0 responsável)HTML (1.051 forks)batch import
good first issue

Métricas do repositório

Stars
 (16.722 estrelas)
Métricas de merge de PR
 (Mesclagem média 1d 9h) (119 fundiu PRs em 30d)

Description

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.

Guia do colaborador