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

Generate a real Python 'set' for the Conjure set<T> type #27

Open
iamdanfox opened this issue Oct 26, 2018 · 0 comments · Fixed by palantir/conjure-python-client#39
Open

Comments

@iamdanfox
Copy link
Contributor

What's happening

Given the Conjure definition:

SetExample:
  fields:
    items: set<string>
    doubleItems: set<double>

conjure-python 3.9.0 doesn't actually enforce uniqueness of the items field because it generates a list:

class SetExample(ConjureBeanType):

    @classmethod
    def _fields(cls):
        # type: () -> Dict[str, ConjureFieldDefinition]
        return {
            'items': ConjureFieldDefinition('items', ListType(str)),
            'double_items': ConjureFieldDefinition('doubleItems', ListType(float))
        }

    _items = None # type: List[str]
    _double_items = None # type: List[float]

    def __init__(self, double_items, items):
        # type: (List[float], List[str]) -> None
        self._items = items
        self._double_items = double_items

    @property
    def items(self):
        # type: () -> List[str]
        return self._items

    @property
    def double_items(self):
        # type: () -> List[float]
        return self._double_items

What should happen

We should codegen a python type that actually enforces uniqueness, e.g. set or frozenset: https://docs.python.org/2/library/stdtypes.html#set

derenrich pushed a commit to derenrich/conjure-python that referenced this issue Jan 8, 2019
bulldozer-bot bot pushed a commit to palantir/conjure-python-client that referenced this issue Feb 1, 2019
## Before this PR
<!-- Describe the problem you encountered with the current state of the world (or link to an issue) and why it's important to fix now. -->
- Comparison of Union types was broken
- No tests for enum or union types
- No way to represent Sets separate from Lists

## After this PR
This PR does a few things:
- fixes and tests #17
- adds tests for the union and enum types which had bugs before
- adds a SetType for the eventual native support for frozenset to resolve palantir/conjure-python#27 later


<!-- Reference any existing GitHub issues, e.g. 'fixes #000' or 'relevant to #000' -->
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 a pull request may close this issue.

1 participant