Skip to content

Commit

Permalink
emit a warning if "include_regex" matched no versions
Browse files Browse the repository at this point in the history
fixes #269.
  • Loading branch information
lilydjwg committed Apr 26, 2024
1 parent 5140fa2 commit d13cbee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nvchecker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,19 @@ def substitute_version(
return version

def apply_list_options(
versions: List[Union[str, RichResult]], conf: Entry,
versions: List[Union[str, RichResult]],
conf: Entry,
name: str,
) -> Optional[Union[str, RichResult]]:
pattern = conf.get('include_regex')
if pattern:
if versions and pattern:
re_pat = re.compile(pattern)
versions = [x for x in versions
versions2 = [x for x in versions
if re_pat.fullmatch(str(x))]
if not versions2:
logger.warning('include_regex matched no versions',
name=name, versions=versions, regex=pattern)
versions = versions2

pattern = conf.get('exclude_regex')
if pattern:
Expand Down Expand Up @@ -363,7 +369,7 @@ def _process_result(r: RawResult) -> Union[RichResult, Exception]:
name=r.name, exc_info=r.version)
return version
elif isinstance(version, list):
version_str = apply_list_options(version, conf)
version_str = apply_list_options(version, conf, name)
if isinstance(version_str, RichResult):
url = version_str.url
gitref = version_str.gitref
Expand Down

0 comments on commit d13cbee

Please sign in to comment.