igittigitt

raw JSON →
2.1.5 verified Fri May 01 auth: no python

A spec-compliant gitignore parser for Python. It loads .gitignore rules and provides a matcher to check if a path is ignored. Current version 2.1.5, requires Python >=3.8.0. Active development on GitHub.

pip install igittigitt
error ModuleNotFoundError: No module named 'igittigitt'
cause Package not installed or installed in a different environment.
fix
Run: pip install igittigitt
error AttributeError: 'IgnoreRules' object has no attribute 'parse_gitignore'
cause Trying to call parse_gitignore as a method on an instance. It is a module-level function.
fix
Use from igittigitt import parse_gitignore; result = parse_gitignore('.gitignore')
error TypeError: is_ignored() missing 1 required positional argument: 'path'
cause Calling is_ignored without arguments.
fix
rules.is_ignored('relative/path')
gotcha IgnoreRules.is_ignored expects a path relative to the gitignore rules, not an absolute path. Using absolute paths may produce incorrect results.
fix Provide relative paths, e.g., 'src/main.py' instead of '/home/user/project/src/main.py'.
gotcha Pattern matching behavior differs from git: igittigitt does not handle negated patterns (leading '!') correctly in all edge cases. Double-check complex .gitignore files.
fix Test your patterns with both igittigitt and git check-ignore to ensure consistency.
deprecated The function 'parse_gitignore' returns a dict, not an IgnoreRules object. Many users expect IgnoreRules from it.
fix Use IgnoreRules directly: rules = IgnoreRules(); rules.parse_file('.gitignore').

Create IgnoreRules, add rules, and test paths.

from igittigitt import IgnoreRules
rules = IgnoreRules()
rules.parse_rule_string('*.pyc')
assert rules.is_ignored('foo.pyc') == True