{"id":23103,"library":"gitmatch","title":"gitmatch","description":"Library for matching file paths against gitignore-style patterns. Version 0.3.0, released infrequently.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/bmsauer/gitmatch","tags":["gitignore","path-matching","pattern-matching","file-filter"],"install":[{"cmd":"pip install gitmatch","lang":"bash","label":"install from PyPI"}],"dependencies":[],"imports":[{"note":"PathMatch is a common guess but does not exist.","wrong":"from gitmatch import PathMatch","symbol":"GitMatch","correct":"from gitmatch import GitMatch"},{"note":"The match function returns a boolean.","wrong":"","symbol":"match","correct":"from gitmatch import match"}],"quickstart":{"code":"from gitmatch import GitMatch\n\npatterns = ['*.pyc', '__pycache__/']\nmatcher = GitMatch(patterns)\nprint(matcher.matches('foo.pyc'))  # True\nprint(matcher.matches('main.py'))   # False","lang":"python","description":"Create a matcher from a list of patterns and test paths."},"warnings":[{"fix":"Use patterns like '*.log' not '/tmp/*.log'.","message":"GitMatch expects patterns relative to the root, not absolute paths. Do not include leading slashes.","severity":"gotcha","affected_versions":"*"},{"fix":"matcher = GitMatch([str(p) for p in patterns])","message":"The GitMatch constructor does not accept pathlib.Path objects directly; convert to str first.","severity":"gotcha","affected_versions":"*"},{"fix":"Replace matcher(path) with matcher.matches(path).","message":"In version 0.3.0, the API changed: GitMatch instances are no longer callable. Use .matches() instead.","severity":"breaking","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from gitmatch import GitMatch'.","cause":"The class is named GitMatch, not PathMatch.","error":"ImportError: cannot import name 'PathMatch' from 'gitmatch'"},{"fix":"Use matcher.matches(path) instead of matcher(path).","cause":"In 0.3.0, the GitMatch object is no longer callable; you must call .matches().","error":"TypeError: 'GitMatch' object is not callable"},{"fix":"Convert Path objects to strings: GitMatch([str(p) for p in patterns])","cause":"GitMatch expects patterns as strings, not pathlib.Path objects.","error":"ValueError: Pattern must be a string"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}