Skip to content

Fixed len(ListNode) on empty nodes bug#23

Merged
amniskin merged 1 commit into
masterfrom
bugfix
Oct 4, 2025
Merged

Fixed len(ListNode) on empty nodes bug#23
amniskin merged 1 commit into
masterfrom
bugfix

Conversation

@amniskin
Copy link
Copy Markdown
Contributor

@amniskin amniskin commented Oct 4, 2025

It would raise an error before, and now it doesn't.
added a parameterization to the tests to check.

@amniskin amniskin requested a review from Copilot October 4, 2025 08:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where calling len() on empty ListNode instances would raise an error instead of returning the correct length. The fix also includes refactoring of existing tests into a more comprehensive parameterized test structure.

  • Simplified the __len__ method in CollectionNode to always return the length from node info
  • Moved the get method from CollectionNode to DictNode where it belongs
  • Renamed import_ method to load with enhanced functionality for loading specific nodes from other DAGs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/daggerml/core.py Fixed __len__ method bug, moved get method to DictNode, renamed and enhanced import_ to load
tests/test_core.py Added comprehensive parameterized tests and reorganized existing test methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/daggerml/core.py
If default is not given, it defaults to None, so that this method never raises a KeyError.
"""
return make_node(self.dag, self.dag.dml.get(self, key, default, name=name, doc=doc))
return self._info["length"]
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix removes the conditional check for self._info["length"] but doesn't handle the case where the length might be None or missing. This could cause a KeyError or return None unexpectedly when len() is called on nodes that don't have length information.

Copilot uses AI. Check for mistakes.
@amniskin amniskin merged commit 6b0d759 into master Oct 4, 2025
14 checks passed
@amniskin amniskin deleted the bugfix branch October 4, 2025 08:55
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 this pull request may close these issues.

2 participants