potiuk commented on code in PR #56509:
URL: https://github.com/apache/airflow/pull/56509#discussion_r2426973200
##########
airflow-core/src/airflow/utils/file.py:
##########
@@ -102,24 +102,21 @@ def compile(pattern: str, base_dir: Path,
definition_file: Path) -> _IgnoreRule
relative_to = definition_file.parent
ignore_pattern = GitWildMatchPattern(pattern)
- return _GlobIgnoreRule(ignore_pattern, relative_to)
+ return _GlobIgnoreRule(wild_match_pattern=ignore_pattern,
relative_to=relative_to)
@staticmethod
def match(path: Path, rules: list[_IgnoreRule]) -> bool:
- """Match a list of ignore rules against the supplied path."""
+ """Match a list of ignore rules against the supplied path, accounting
for exclusion rules and ordering."""
matched = False
- for r in rules:
- if not isinstance(r, _GlobIgnoreRule):
- raise ValueError(f"_GlobIgnoreRule cannot match rules of type:
{type(r)}")
- rule: _GlobIgnoreRule = r # explicit typing to make mypy play
nicely
+ for rule in rules:
+ if not isinstance(rule, _GlobIgnoreRule):
+ raise ValueError(f"_GlobIgnoreRule cannot match rules of type:
{type(rule)}")
rel_path = str(path.relative_to(rule.relative_to) if
rule.relative_to else path.name)
- matched = rule.wild_match_pattern.match_file(rel_path) is not None
-
- if matched:
- if not rule.wild_match_pattern.include:
- return False
-
- return matched
+ if (
+ rule.wild_match_pattern.include is not None
+ and rule.wild_match_pattern.match_file(rel_path) is not None
+ ):
+ matched = rule.wild_match_pattern.include
return matched
Review Comment:
Also might be worth checking if
https://github.com/apache/airflow/issues/56126 is also fixed (maybe adding a
test)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]