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

Merge type-instances correctly #19

Closed
waveform80 opened this issue Aug 21, 2021 · 1 comment
Closed

Merge type-instances correctly #19

waveform80 opened this issue Aug 21, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@waveform80
Copy link
Owner

Currently, when a Dict with Field keys is merged with a Dict with, say, Scalar keys, the result duplicates the typed entries and the subsequent sort (intended for fields) fails (because Scalar entries are unsortable):

Traceback (most recent call last):                                                                                                                                           
  File "/home/dave/envs/structa/bin/structa", line 33, in <module>
    sys.exit(load_entry_point('structa', 'console_scripts', 'structa')())
  File "/home/dave/projects/structa/structa/ui/cli.py", line 30, in main
    structure = get_structure(config)
  File "/home/dave/projects/structa/structa/ui/cli.py", line 230, in get_structure
    result = analyzer.merge(struct)
  File "/home/dave/projects/structa/structa/analyzer.py", line 272, in merge
    return self._merge(struct)
  File "/home/dave/projects/structa/structa/analyzer.py", line 315, in _merge
    return path.with_content([
  File "/home/dave/projects/structa/structa/analyzer.py", line 316, in <listcomp>
    self._merge(item)
  File "/home/dave/projects/structa/structa/analyzer.py", line 310, in _merge
    return path.with_content([
  File "/home/dave/projects/structa/structa/analyzer.py", line 311, in <listcomp>
    DictField(self._merge(field.key), self._merge(field.value))
  File "/home/dave/projects/structa/structa/analyzer.py", line 310, in _merge
    return path.with_content([
  File "/home/dave/projects/structa/structa/analyzer.py", line 311, in <listcomp>
    DictField(self._merge(field.key), self._merge(field.value))
  File "/home/dave/projects/structa/structa/analyzer.py", line 305, in _merge
    DictField(self._merge(keys), self._merge(sum(
  File "/home/dave/projects/structa/structa/types.py", line 301, in __add__
    result = super().__add__(other)
  File "/home/dave/projects/structa/structa/types.py", line 248, in __add__
    result.content = [a + b for a, b in self._zip(other)]
  File "/home/dave/projects/structa/structa/types.py", line 248, in <listcomp>
    result.content = [a + b for a, b in self._zip(other)]
  File "/home/dave/projects/structa/structa/types.py", line 337, in __add__
    self.value + other.value)
  File "/home/dave/projects/structa/structa/types.py", line 305, in __add__
    result.content = sorted(result.content, key=attrgetter('key'))
TypeError: '<' not supported between instances of 'Str' and 'Str'
@waveform80 waveform80 added the bug Something isn't working label Aug 21, 2021
@waveform80 waveform80 added this to the 1.0 milestone Aug 21, 2021
@waveform80 waveform80 self-assigned this Aug 21, 2021
@waveform80
Copy link
Owner Author

Fixed in 7ce9b1e

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