-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ModuleCollectorMixin] adds option to find & call functions to collec…
…t_top_level_attributes_in_module (Recidiviz/recidiviz-data#28837) ## Description of the change adds the ability to collect attributes returned by a callable instead of requiring all attributes must be defined in the global scope. the callable must have no arguments and a return type that is either a list of the specified attribute (or its subclasses) or an attribute itself (or its subclasses). in order to do so, this PR adds `explode_callables` and `callable_prefix` as kwargs to `ModuleCollectorMixin.collect_top_level_attributes_in_module`. the approach in this PR: (1) hopes that functions are accurately typed (ty mypy) but still backstops against the case in which they are not by validating the actual return vars of the function (2) relies on `typing.get_args` and `typing.get_origin` all existing invocations of `collect_top_level_attributes_in_module` should remain unchanged. i agree the naming of `explode_callables` feels a little ridiculous, but is taken from `pandas.explode` which felt relevantly similar and is also kinda fun ¯\\_(ツ)_/¯ ## Type of change > All pull requests must have at least one of the following labels applied (otherwise the PR will fail): | Label | Description | |----------------------------- |----------------------------------------------------------------------------------------------------------- | | Type: Bug | non-breaking change that fixes an issue | | Type: Feature | non-breaking change that adds functionality | | Type: Breaking Change | fix or feature that would cause existing functionality to not work as expected | | Type: Non-breaking refactor | change addresses some tech debt item or prepares for a later change, but does not change functionality | | Type: Configuration Change | adjusts configuration to achieve some end related to functionality, development, performance, or security | | Type: Dependency Upgrade | upgrades a project dependency - these changes are not included in release notes | ## Related issues Useful for for Recidiviz/recidiviz-data#28613 Prework for Recidiviz/recidiviz-data#28815, Recidiviz/recidiviz-data#28854 ## Checklists ### Development **This box MUST be checked by the submitter prior to merging**: - [x] **Double- and triple-checked that there is no Personally Identifiable Information (PII) being mistakenly added in this pull request** These boxes should be checked by the submitter prior to merging: - [x] Tests have been written to cover the code changed/added as part of this pull request ### Code review These boxes should be checked by reviewers prior to merging: - [x] This pull request has a descriptive title and information useful to a reviewer - [x] Potential security implications or infrastructural changes have been considered, if relevant GitOrigin-RevId: c4dde0a85d35dec1add27efd7536f5965d3e317f
- Loading branch information
Showing
11 changed files
with
587 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.