New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce factory_dict. #6622

Merged
merged 3 commits into from Oct 12, 2018

Conversation

Projects
None yet
2 participants
@jsirois
Copy link
Member

jsirois commented Oct 11, 2018

This generates values from keys when no entry is present, a feature
you might guess collections.defaultdict would support by passing keys
through to default_factory functions.

Update products to use this.
PR #6618 will also pull it in or else it will be used in a follow-up.

Introduce factory_dict.
This generates values from keys when no entry is present, a feature
you might guess collections.defaultdict would support by passing keys
through to default_factory functions.

Update products to use this.
PR #6618 will also pull it in or else it will be used in a follow-up.

@jsirois jsirois force-pushed the jsirois:factory_dict branch from a91602c to b1dd7c8 Oct 11, 2018

@stuhood
Copy link
Member

stuhood left a comment

Thanks!

def factory_dict(value_factory, *args, **kwargs):
"""A dict whose values are computed by `value_factory` when a `__getitem__` key is missing.
Not that values retrieved by any other method will not be lazily computed; eg: via `get`.

This comment has been minimized.

@stuhood

stuhood Oct 11, 2018

Member

Note*

This comment has been minimized.

@jsirois

jsirois Oct 12, 2018

Member

Damn. Thanks for catching. I'll fix and submit without a CI burn. Typos are becoming eco-disasters.

@jsirois jsirois merged commit e8cfb68 into pantsbuild:master Oct 12, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@jsirois jsirois deleted the jsirois:factory_dict branch Oct 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment