Skip to content

Conversation

@nicopauss
Copy link

@nicopauss nicopauss commented Jul 9, 2025

Like allowlist_item and blocklist_item options, add new methods to ParseCallbacks, ParseCallbacks::allow_item() and ParseCallbacks::block_item(), to be able to allow and block items from being generated.

allowlist_* and blocklist_* options work with regexes and are inserted in a RegexSet.

There are two issues with this approach:

  1. In some cases we want to have more flexibility than just using regexes. If we want to have dynamic conditions to allow or block items, using regexes can be limited.
  2. RegexSet scales linearly with the number of elements inserted. This means that if we have a huge number of items that we want to allow or block, regexes and RegexSet are not necessarily the most appropriate data structures.

Using a new method in ParseCallbacks solves these two issues.
We can manually decide the appropriate rules and data structure to match the items.

This method takes precedences over the allowlist_* options.
If at least one of the parse callbacks returns Block, the generation of the bindings for the item is blocked.
If all the parse callbacks that don't return None return Allow, the bindings for the item are generated.
If all the parse callbacks return None (the default implementation), the allowlist_* options are used instead.

@nicopauss nicopauss force-pushed the intersec/add-parse-callbacks-methods branch from 430055d to 89385ad Compare July 9, 2025 20:02
@nicopauss nicopauss force-pushed the intersec/add-parse-callbacks-methods branch from 89385ad to 0b570dc Compare February 10, 2026 16:13
@nicopauss nicopauss changed the title Add ParseCallbacks::allow_item() and ParseCallbacks::block_item(). Add ParseCallbacks::allow_or_block_item(). Feb 10, 2026
Like `allowlist_item` and `blocklist_item` options, add new methods to
`ParseCallbacks`, `ParseCallbacks::allow_item()` and
`ParseCallbacks::block_item()`, to be able to allow and block items from
being generated.

`allowlist_*` and `blocklist_*` options work with regexes and are
inserted in a RegexSet.

There are two issues with this approach:
1. In some cases, we want to have more flexibility than just using
   regexes. If we want to have dynamic conditions to allow or block
   items, using regexes can be limited.
2. RegexSet scales linearly with the number of elements inserted. This
   means that if we have a huge number of items that we want to allow or
   block, regexes and RegexSet are not necessarily the most appropriate
   data structures.

Using a new method in `ParseCallbacks` solves these two issues.
We can manually decide the appropriate rules and data structure to match
the items.

This method takes precedences over the `allowlist_*` options.
If at least one of the parse callbacks returns `Block`, the generation
of the bindings for the item is blocked.
If all the parse callbacks that don't return `None` return `Allow`, the
bindings for the item are generated.
If all the parse callbacks return `None` (the default implementation),
the `allowlist_*` options are used instead.
@nicopauss nicopauss force-pushed the intersec/add-parse-callbacks-methods branch from 0b570dc to f819034 Compare February 10, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants