Registry / serialization / gitignorefile

gitignorefile

JSON →
library1.1.2pypypi✓ verified 81d ago

A spec-compliant `.gitignore` parser for Python (version 1.1.2). It reads `.gitignore` files and matches file paths against the rules, supporting all features of the Git gitignore specification. The library is actively maintained.

pip install gitignorefile
INSTALL
IMPORT
SIG · GITIGNOREFILE
G
gitignorefile
serializationpythonv1.1.2
Install
3.2s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ignore
from gitignorefile import ignore
from gitignorefile import read_gitignore
ignored
from gitignorefile import ignored
parse
from gitignorefile import parse

Basic usage: read .gitignore file and check if a path is ignored.

import os from gitignorefile import read_gitignore, GitignoreFile ignores = read_gitignore('.gitignore') checker = GitignoreFile(ignores) print(checker.match('some_file.py')) # True/False
Debug
Known issues
gotchaThe `match` method expects paths relative to the .gitignore file location, not absolute paths.
fix
Ensure you pass paths relative to the directory containing the .gitignore file.
affects: all
gotchaThe library only supports regular files, not directories. Calling `match` on a directory path may give unexpected results.
fix
Use the `is_ignored_dir` property or check for directory separately.
affects: all
deprecatedThe `read_gitignore` function returns a list, but older documentation suggested it returns a different format.
fix
Update to version 1.0+; the return type is now a list of rules.
affects: <1.0
breakingVersion 1.0 changed the API from `GitignoreFile(rules)` to accept a list of rule objects, not raw strings.
fix
Always pass the output of `read_gitignore` to the constructor.
affects: >=1.0
Upgrade
Version history
1.1.2latest on PyPI · released Sep 4, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
gitignorefile — pip install gitignorefile · libregistry