Skip to content

Pytype fails to start if exclude option includes paths with .pyc files #1579

@drewbrew

Description

@drewbrew

Hi, I think the changes introduced in #1419 are causing the exclude logic to crash on startup with a UnicodeDecodeError.

Here's how to replicate this:

  1. In a path with __pycache__ from old (pre-3.10) versions of Python (easy way appears to be python3.9 -m compileall .), add **/__pycache__/** to your exclude option in pytype.cfg (my use case is a Django project: I exclude **/migrations/ so that pytype doesn't complain about the auto-generated code)
  2. Using python 3.11, run pytype --config pytype.cfg
  3. Observe the crash during startup.

The naive ways to fix this would be to either add in if f.endswith(".pyc"): continue in expand_source_files() or enclose the call to read the line in a try/except UnicodeDecodeError: return False

Metadata

Metadata

Assignees

Labels

bugcat: infrastructuresupported platforms, dependency detection, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions