{"id":7264,"library":"globmatch","title":"globmatch","description":"globmatch provides functions for matching a path against one or more glob patterns in Python. Unlike the standard library's `glob` module, it does not interact with the filesystem, focusing solely on generic string matching. It extends `fnmatch` capabilities by supporting the `**` pattern for matching zero or more directories. The current version is 2.0.0, with releases historically being infrequent but demonstrating active maintenance.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/vidartf/globmatch","tags":["glob","pattern matching","filepaths","wildcard"],"install":[{"cmd":"pip install globmatch","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"glob_match","correct":"from globmatch import glob_match"}],"quickstart":{"code":"from globmatch import glob_match\n\n# Basic matching\nprint(glob_match('foo/config', ['**/config']))  # Expected: True\nprint(glob_match('foo/bar/config', ['**/config'])) # Expected: True\nprint(glob_match('foo/config/bar', ['foo/config'])) # Expected: False (needs /** for sub-elements)\n\n# Matching dotfiles\nprint(glob_match('.git/gitconfig', ['.git/**'])) # Expected: True\n\n# Multiple patterns\npatterns = ['!.git', '**/config'] # Match config, but not if it's in .git\nprint(glob_match('.git/config', patterns, match_all=True)) # Expected: False\nprint(glob_match('myproject/config', patterns, match_all=True)) # Expected: True","lang":"python","description":"Demonstrates basic usage of `glob_match` with single and multiple patterns, including recursive matching with `**` and handling of dotfiles. The `match_all=True` parameter ensures all patterns are considered, enabling exclusion patterns."},"warnings":[{"fix":"Upgrade to `globmatch` 2.0.0 or higher. Thoroughly test existing glob patterns, especially those involving `**` on Windows paths or patterns targeting dotfiles, to ensure expected behavior.","message":"Version 2.0.0 introduced fixes for the `**` pattern on Windows and for matching dotfiles. Code relying on previous, potentially incorrect, behavior in these areas may break.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"If you intend to match files or directories nested deeply, use `**` (e.g., `some/path/**/*.txt`) instead of `*` (e.g., `some/path/*.txt`) for the recursive part.","message":"The `*` wildcard in `globmatch` matches zero or more characters within a single path segment only (i.e., it does not cross path separators like `/` or `\\`). For matching across zero or more directories recursively, you must explicitly use the `**` wildcard.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you need to find files on the filesystem that match a glob pattern, use Python's standard `glob` module (`glob.glob` or `pathlib.Path.glob`), ensuring `recursive=True` is set for `**` patterns.","message":"`globmatch` is purely a string pattern matching library and does not interact with the filesystem. It cannot be used to find or list actual files on disk. Its purpose is to test if a given string path matches a glob pattern.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Use the `**` wildcard for recursive matching across directories. Change the pattern to `['path/**/file']`.","cause":"The `*` wildcard only matches within a single path component. It does not cross directory boundaries.","error":"glob_match('path/to/file', ['path/*/file']) returns False when it should match 'path/subdir/file'."},{"fix":"If your goal is to find actual files on the filesystem, use Python's built-in `glob.glob()` or `pathlib.Path.glob()` functions. `globmatch` is for abstract path string matching.","cause":"The `globmatch` library *only* matches strings against patterns; it does not list or interact with files on the filesystem. This is a common confusion with shell globbing or Python's `glob` module.","error":"My patterns work in bash/zsh but globmatch doesn't find files."},{"fix":"Ensure you are using `globmatch` version `2.0.0` or newer. This version specifically addressed these compatibility and matching issues.","cause":"Older versions of `globmatch` (prior to 2.0.0) had known issues with `**` patterns on Windows and inconsistent matching of dotfiles.","error":"`glob_match('foo/.config', ['.config'])` returns `False` or inconsistent results on Windows."}]}