Skip to content

fix: use the filter key in is_relevant instead of always matching type - #93

Merged
lwoodblake merged 1 commit into
masterfrom
fix-issue-81
Oct 20, 2026
Merged

lwoodblake merged 1 commit into
masterfrom
fix-issue-81

Conversation

@willnewton

Copy link
Copy Markdown
Contributor

Closes #81

Problem

helpers.is_relevant compared every filter value against event["type"]["name"] and never used the key, so sb.events(match_id, filters={"player": "Lionel Messi"}) silently matched nothing.

Change

  • is_relevant now looks up event[key]. Dict attributes (type, player, team, ...) are compared by name; scalar attributes (e.g. minute) are compared directly.
  • Missing attributes never match.
  • filters={"type": ...} behaves as before.
  • Added tests/statsbombpy_test/test_helpers.py.

Notes

The issue also suggested rejecting unsupported keys with a validation error; I went with filtering by the given key instead. Happy to add validation as a follow-up if preferred.

🤖 Generated with Claude Code

Filters were all compared against event["type"]["name"], so filtering on
any other attribute (e.g. player) silently matched nothing.

Closes #81

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@lwoodblake lwoodblake self-assigned this Oct 20, 2026
@lwoodblake
lwoodblake self-requested a review October 20, 2026 15:32

@lwoodblake lwoodblake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this fix. Tests cover relevant situations and tests pass.

@lwoodblake
lwoodblake merged commit dc4a246 into master Oct 20, 2026
6 checks passed
@lwoodblake
lwoodblake deleted the fix-issue-81 branch October 20, 2026 15:47
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.

filters in events() ignores the filter key — every filter matches against type

2 participants