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

[python] On is-not-context error, show type #3583

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

johnkerl
Copy link
Member

@johnkerl johnkerl commented Jan 17, 2025

Issue and/or context: Found while working on #3581 / #3582.

In a debug script, due to a copy/paste error, I had

context = tiledbsoma.SOMATileDBContext(tiledb_config={
    "key1": "value1",
    "key2": "value2",
}),

Note the trailing comma, which I did not see. (In the copy-from text, this had been in an argument list where comma is needed. In the paste-to text, I was assigning it to a variable, where comma is not needed.)

Then, running a repro, I got

  File "/Users/kerl/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/options/_soma_tiledb_context.py", line 377, in _validate_soma_tiledb_context
    raise TypeError(f"context is not a SOMATileDBContext")
TypeError: context is not a SOMATileDBContext

This baffled me for a while since I was clearly setting context to be a tiledbsoma.SOMATileDBContext.

Only on debugging and inserting a print of type(context) did I see my error.

We need to automate that helpfulness here.

Changes:

Now it prints:

  File "/Users/kerl/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/options/_soma_tiledb_context.py", line 377, in _validate_soma_tiledb_context
    raise TypeError(f"context is not a SOMATileDBContext: got {type(context)}")
TypeError: context is not a SOMATileDBContext: got <class 'tuple'>

Notes for Reviewer:

@johnkerl johnkerl changed the title [python] On is-not-context, show type [python] On is-not-context error, show type Jan 17, 2025
@johnkerl johnkerl merged commit ea540fc into main Jan 17, 2025
10 checks passed
@johnkerl johnkerl deleted the kerl/what-is-it-if-not-ctx branch January 17, 2025 16:10
github-actions bot pushed a commit that referenced this pull request Jan 17, 2025
johnkerl added a commit that referenced this pull request Jan 17, 2025
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.32%. Comparing base (77471b6) to head (148b954).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3583      +/-   ##
==========================================
+ Coverage   86.27%   86.32%   +0.04%     
==========================================
  Files          55       55              
  Lines        6375     6375              
==========================================
+ Hits         5500     5503       +3     
+ Misses        875      872       -3     
Flag Coverage Δ
python 86.32% <0.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
python_api 86.32% <0.00%> (+0.04%) ⬆️
libtiledbsoma ∅ <ø> (∅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants