JelleZijlstra / autotyping

Automatically add simple type annotations to your code
241 stars 20 forks source link

Question: how to exclude virtual environment? #63

Open jamesbraza opened 11 months ago

jamesbraza commented 11 months ago

When adding the below to my .libcst.codemod.yaml:

blacklist_patterns: ['repo\/venv\/']

I get a bunch of FileNotFoundErrors:

Codemodding /Users/user/code/repo/venv/lib/python3.10/site-packages/Bio/Entrez/__init__.py
Traceback (most recent call last):
  File "/Users/user/code/repo/venv/lib/python3.10/site-packages/libcst/codemod/_cli.py", line 314, in _execute_transform
    newcode = invoke_formatter(config.formatter_args, newcode)
  File "/Users/user/code/repo/venv/lib/python3.10/site-packages/libcst/codemod/_cli.py", line 56, in invoke_formatter
    subprocess.check_output(
  File "/Users/user/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Users/user/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/user/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/user/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/user/code/repo/black'

I currently have Python 3.10.13 with:

autotyping==23.3.0
libcst==1.1.0

How can I exclude a virtual environment from autotyping when running:

python -m libcst.tool codemod autotyping.AutotypeCommand . --aggressive
jamesbraza commented 11 months ago

Actually, I realized the FileNotFoundError comes from the fact that black is being used with the default libCST config under the formatter item. After pip install black, the FileNotFoundError goes away.

However, autotyping still keeps formatting the venv. How can one exclude a virtual environment when running autotyping?