-
-
Notifications
You must be signed in to change notification settings - Fork 30
feat(hatch hook): add support for exclude patterns as paths with wildcards #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| def rewrite_modules(paths: List[Path], ns: str, top_ns: str) -> None: | ||
| for path in paths: | ||
| rewritten_bricks = parsing.rewrite_modules(path, ns, top_ns) | ||
|
|
||
| for item in rewritten_bricks: | ||
| print(f"Updated {item} with new top namespace for local imports.") | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is refactored to separate function. The rewrite is only applicable when there's a defined top_ns (i.e. when publishing several public packages and to avoid namespace collisions).
| def ignore_paths(root: Path, patterns: Set[str]): | ||
| def fn(current_path: str, names: List[str]): | ||
| current = Path(current_path).resolve() | ||
|
|
||
| return {name for name in names if any_match(root, patterns, name, current)} | ||
|
|
||
| return fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A custom ignore-function according to the way shutil uses ignore. The default shutil.ignore_patterns only handles names (files or folders) and will not ignore paths. That is why there's need of a custom ignore function.
|



Description
Add support for exclude patterns that are paths, with or without wildcards.
Motivation and Context
Continued work from #339 and the discussion #338
This feature will make it possible to define exclude patterns in the Hatch config, such as:
How Has This Been Tested?
✅ CI
✅ Local testing using
hatch buildTypes of changes
Checklist: