Skip to content
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

Names for dependent variables #4

Open
svivek opened this issue May 30, 2021 · 0 comments
Open

Names for dependent variables #4

svivek opened this issue May 30, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@svivek
Copy link
Member

svivek commented May 30, 2021

The following test fails

def test_multiple_dependents_failure():
    fillers = {
        "person": [
            {"name": "Jack", "pronoun": "he", "noun": "man"},
            {"name": "Jill", "pronoun": "she", "noun": "woman"},
        ],
        "place": [
            {"location": "New York", "pronoun": "it"},
            {"location": "Chicago", "pronoun": "it"},
        ],
    }

    template = '{{name}} {{p | type("pronoun")}} {{noun}} {{p}}'

    pytest.raises(Exception):
        m = MadLibTemplate(template, fillers)

The expected behavior is that there should be confusion with which pronoun is to be used. But the template is created with the assumption that the first pronoun is used. This may be okay, but unsatisfactory and can lead to silent bugs downstream.

Maybe one way to get around this is to allow for types to be specified using fully qualified names like:

'{{person.name}} {{p | type("person.pronoun")}} {{person.noun}} {{p}}'

This will remove all ambiguity about which pronoun we are talking about.

@svivek svivek added the bug Something isn't working label May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant