Skip to content

chore: remove dead code and add util tests#11832

Open
adrioui wants to merge 3 commits intoibis-project:mainfrom
adrioui:chore/cleanup-and-util-tests
Open

chore: remove dead code and add util tests#11832
adrioui wants to merge 3 commits intoibis-project:mainfrom
adrioui:chore/cleanup-and-util-tests

Conversation

@adrioui
Copy link
Contributor

@adrioui adrioui commented Jan 11, 2026

Description of changes

  • Remove dead code in visualize.py for output_type.__name__ fallback (was marked as TODO for removal)
  • Add comprehensive tests for promote_list and promote_tuple utility functions (resolves TODO in test file)

@github-actions github-actions bot added the tests Issues or PRs related to tests label Jan 11, 2026
"val",
[
pytest.param([1, 2, 3], id="list"),
pytest.param({"a": 1}, id="dict"),
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this entire test:

  • the dict case isn't being used
  • we don't want to guarantee identity stability only equality stability

Copy link
Contributor

@NickCrews NickCrews Jan 13, 2026

Choose a reason for hiding this comment

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

well, I guess we can add to the contract that identity is preserved.

but still, we don't need the paramaterization. just simplify to

def test_promote_list_identity():
    val = [1,2,3]
    assert promote_list(val) is val

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should guarantee identity. Why do we need to restrict ourselves here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I'm fine not testing for identity preservation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. I removed both identity tests. The suite now checks behavior without relying on pointer equality.

pytest.param((1, 2, 3), id="tuple"),
],
)
def test_promote_tuple_identity(val):
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify to

def test_promote_tuple_identity():
    val = (1,2,3)
    assert promote_tuple(val) is val

Copy link
Contributor

Choose a reason for hiding this comment

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

Per Philips follow up comment in the other thread, actually please let's remove this test for indentity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I removed the identity test based on Philip's follow-up.

return node.output_type.__name__
except (AttributeError, NotImplementedError):
return "\u2205" # empty set character
return "\u2205" # empty set character
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the impact of this change?

Copy link
Member

Choose a reason for hiding this comment

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

@adrioui Any thoughts here? Doesn't this change break cases where the previous code was hit (as indicated by the comment)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should not break those cases. The old assert crashed on non-Join nodes. Now it falls back to the empty set character. This only makes it more robust.

@adrioui
Copy link
Contributor Author

adrioui commented Jan 14, 2026

Thanks for the review feedback! I've addressed all comments:

Test Simplifications (commits c94cbc7)

Simplified both identity tests per your suggestions:

test_promote_list_identity - Removed parameterization and dead code (the dict case was never actually tested due to the if isinstance(val, list) guard):

def test_promote_list_identity():
    """Test that lists are returned as-is (same object)."""
    val = [1, 2, 3]
    assert promote_list(val) is val

test_promote_tuple_identity - Removed unnecessary single-item parameterization:

def test_promote_tuple_identity():
    """Test that tuples are returned as-is (same object)."""
    val = (1, 2, 3)
    assert promote_tuple(val) is val

Impact Explanation for visualize.py Dead Code Removal

The output_type property was removed from all ops.Node classes in July 2022 (commit d2a3919). Since then, accessing node.output_type always raises AttributeError, making this code path unreachable.

The removed code and the remaining code produce identical behavior - returning "∅" for nodes without dtype or schema. Currently, the only node reaching this fallback is ops.JoinLink.

The existing test test_custom_expr_with_not_implemented_type in ibis/expr/tests/test_visualize.py verifies this fallback behavior continues to work correctly.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

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

Needs a bit of work.

def test_promote_list_identity():
"""Test that lists are returned as-is (same object)."""
val = [1, 2, 3]
assert promote_list(val) is val
Copy link
Member

Choose a reason for hiding this comment

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

This is overly restrictive. Why do we need to guarantee that the input is pointer-equivalent? We only care that the output is a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I removed the identity requirement. The tests now check semantic equivalence, which is what callers should depend on.

def test_promote_tuple_identity():
"""Test that tuples are returned as-is (same object)."""
val = (1, 2, 3)
assert promote_tuple(val) is val
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above. Just add it to the parameters of test_promote_tuple. We don't care nor should we care if the objects are identical (only equal).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. I dropped the identity test instead of plumbing it through test_promote_tuple.

return node.output_type.__name__
except (AttributeError, NotImplementedError):
return "\u2205" # empty set character
return "\u2205" # empty set character
Copy link
Member

Choose a reason for hiding this comment

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

@adrioui Any thoughts here? Doesn't this change break cases where the previous code was hit (as indicated by the comment)?

@github-actions github-actions bot added the docs Documentation related issues or PRs label Jan 26, 2026
@adrioui adrioui force-pushed the chore/cleanup-and-util-tests branch 3 times, most recently from 33a6386 to c94cbc7 Compare January 26, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation related issues or PRs tests Issues or PRs related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants