Skip to content

Expand default ignored directories#532

Open
StantonMatt wants to merge 1 commit into
bndr:masterfrom
StantonMatt:expand-default-ignore-dirs
Open

Expand default ignored directories#532
StantonMatt wants to merge 1 commit into
bndr:masterfrom
StantonMatt:expand-default-ignore-dirs

Conversation

@StantonMatt

Copy link
Copy Markdown

Summary

  • centralize the default scanner ignore list for reuse
  • ignore common generated/cache/environment directories such as .mypy_cache, .nox, build, dist, node_modules, and pypackages by default
  • add coverage that files inside default ignored directories do not contribute imports

Fixes #420.

Verification

  • .venv/bin/python -m unittest tests.test_pipreqs.TestPipreqs.test_get_all_imports_skips_default_ignored_directories
  • .venv/bin/python -m unittest tests.test_pipreqs
  • .venv/bin/python -m flake8 pipreqs tests
  • review-fix-loop: clean fresh review, no actionable correctness issues

@bubaizhanshen

Copy link
Copy Markdown

I checked this locally on Python 3.10.

The new default-ignore path works for the issue shape from #469/#495: with main.py importing requests and a .venv/lib/bad.py file containing undecodable bytes plus import click, get_all_imports() returns only ['requests']. So the scanner no longer reads into the virtualenv by default.

Checks I ran:

python -m unittest tests.test_pipreqs.TestPipreqs.test_get_all_imports_skips_default_ignored_directories tests.test_pipreqs.TestPipreqs.test_get_all_imports
python -m py_compile pipreqs/pipreqs.py tests/test_pipreqs.py
python -m flake8 pipreqs tests
git diff --check upstream/master...HEAD

All passed. I did not use test_ignored_directory as a signal here because it waits on a live PyPI request in this environment, but the default directory-pruning behavior changed by this PR looks good from this pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better external dependency identification (ignore dotfiles directories by default)

2 participants