Commit 3bf45e6
### Summary
Fixes #20958.
--exclude-gitignore now respects patterns in .git/info/exclude, not just
.gitignore files. Previously, mypy ignored .git/info/exclude entirely,
causing files matched by those patterns to still be checked.
### Changes
File: mypy/modulefinder.py — find_gitignores()
File: test-data/unit/cmdline.test
Added handling for .git/info/exclude inside the git root detection
branch. When find_gitignores identifies a directory as a git root (i.e.
it contains a .git folder), it now also checks for .git/info/exclude. If
the file exists, it is parsed with PathSpec.from_lines("gitignore", ...)
and included in the returned list of gitignore specs, alongside any
.gitignore found in the same directory. Parse errors are printed to
stderr and the file is skipped, matching the existing behavior for
malformed .gitignore files.
---------
Co-authored-by: Cindy Wang <[email protected]>
1 parent 880e9b6 commit 3bf45e6
2 files changed
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
731 | 739 | | |
732 | 740 | | |
733 | 741 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
992 | 1003 | | |
993 | 1004 | | |
994 | 1005 | | |
| |||
0 commit comments