{"id":21386,"library":"gitignorant","title":"gitignorant — A parser for gitignore files","description":"Gitignorant is a Python library for parsing and evaluating .gitignore rules. It provides a simple API to check whether a given path would be ignored by a set of gitignore patterns. The current version is 0.4.0, targeting Python >=3.7, with infrequent releases.","status":"active","version":"0.4.0","language":"python","source_language":"en","source_url":"https://github.com/valohai/gitignorant","tags":["gitignore","parser","file-matching","git"],"install":[{"cmd":"pip install gitignorant","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The class GitIgnoreMatcher is the primary entry point.","wrong":"","symbol":"GitIgnoreMatcher","correct":"from gitignorant import GitIgnoreMatcher"}],"quickstart":{"code":"from gitignorant import GitIgnoreMatcher\n\nmatcher = GitIgnoreMatcher(\n    patterns=['*.pyc', '__pycache__/'],\n    base_path='/project'\n)\nprint(matcher.is_ignored('foo.py'))  # False\nprint(matcher.is_ignored('bar.pyc'))  # True\nprint(matcher.is_ignored('__pycache__/cache.py'))  # True","lang":"python","description":"Create a matcher from a list of patterns and check if paths are ignored."},"warnings":[{"fix":"Pass paths relative to the base_path (e.g., 'subdir/file.py' not '/abs/path/subdir/file.py').","message":"Paths are relative to base_path; do not pass absolute paths or paths with leading slashes.","severity":"gotcha","affected_versions":"all"},{"fix":"Always wrap a single pattern in a list: GitIgnoreMatcher(patterns=['pattern'], ...).","message":"Patterns must be list of strings; a single string will cause silent failure (iterates over characters).","severity":"gotcha","affected_versions":"all"},{"fix":"Add '.git/' to your patterns list explicitly.","message":"The library does not automatically ignore .git folder; you must include it if needed.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use patterns=['*.log'] instead of patterns='*.log'","cause":"Passing a single pattern string instead of a list causes Python to iterate over characters.","error":"TypeError: 'str' object is not callable"},{"fix":"Ensure base_path is an existing directory. If loading from a file, use from pathlib import Path and check Path('file').exists().","cause":"base_path or patterns file path does not exist.","error":"FileNotFoundError: [Errno 2] No such file or directory: '<path>'"},{"fix":"Create a GitIgnoreMatcher instance and call its is_ignored method.","cause":"Confusing the module function (not present) with the method on a matcher instance.","error":"AttributeError: module 'gitignorant' has no attribute 'is_ignored'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}