palantir / palantir/conjure-python
Generate a real Python 'set' for the Conjure set<T> type
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 27
- Forks
- 19
- Avg merge
- 12h 22m
- Merged PRs (30d)
- 15
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the generator that emits the shown SetExample fields and ListType annotations. Update the generated representation for set and set to enforce uniqueness, then verify the generated properties and type annotations reflect that set-like behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100