Skip to content

feat: 1) support length_not_equal comparison; 2) All length comparators support numbers; 3) Optimize the is_true and is_not_true comparisons#5218

Open
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/feat-newCompare-len-not-eq
Open

feat: 1) support length_not_equal comparison; 2) All length comparators support numbers; 3) Optimize the is_true and is_not_true comparisons#5218
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/feat-newCompare-len-not-eq

Conversation

@wangliang181230
Copy link
Copy Markdown
Contributor

@wangliang181230 wangliang181230 commented May 6, 2026

What this PR does / why we need it?

  1. support length_not_equal comparison
  2. All length comparators support numbers
  3. Optimize the is_true and is_not_true comparisons

Summary of your change

  1. 判断器的条件,添加 长度不等于 (len_not_eq) 比较
  2. 所有长度比较器都支持数字的长度比较

    封装及复用长度计算方法 compute_length(source_value, target_value)

  3. 优化 is_trueis_not_true 判断器

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 6, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

if not match:
regex = fnmatch.translate(wildcard)
match = re.compile(regex).match
match = re.compile(regex).fullmatch
Copy link
Copy Markdown
Contributor Author

@wangliang181230 wangliang181230 May 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注:与正则比较器相同的调整。see e86ae7e
但其实最终效果是一样的,因为经过 fnmatch.translate(wildcard) 转换后的正则,会以 \Z 结尾,它的效果和 fullmatch 一样,就是从代码层面明确最终使用的是fullmatch 的效果,更容易让人理解。

return source_value is True
except Exception:
return False
return source_value is True
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_not_trueis_true 没有异常需要捕获,直接去掉。

@wangliang181230 wangliang181230 changed the title feat: 1) support length_not_equal comparison; 2) All length comparators support numbers feat: 1) support length_not_equal comparison; 2) All length comparators support numbers; 3) Optimize the is_true and is_not_true comparisons May 12, 2026
…tors support numbers; 3) Optimize the `is_true` and `is_not_true` comparisons
@wangliang181230 wangliang181230 force-pushed the PR/feat-newCompare-len-not-eq branch from 4f4867b to 35516f5 Compare May 12, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants