Skip to content

fix #454: guard against None in PlotCollection.__getattr__ to prevent TypeError - #456

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursorstereopy-issue-automation-1234
Draft

fix #454: guard against None in PlotCollection.__getattr__ to prevent TypeError#456
cursor[bot] wants to merge 1 commit into
mainfrom
cursorstereopy-issue-automation-1234

Conversation

@cursor

@cursor cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Summary

When PlotBase.get_attribute_helper() returns None (e.g., due to partial import failures in stereo/plots/__init__.py preventing plot subclasses from being registered), the PlotCollection.__getattr__ method was wrapping None with the download decorator. This created a callable wrapper that, when invoked, tried to call None(*args, **kwargs), producing the confusing TypeError: 'NoneType' object is not callable error reported in #454.

Changes

  • stereo/plots/plot_collection.py: Added an explicit None check on the return value of get_attribute_helper() before the download decorator is applied. When the resolved function is None, a clear AttributeError is raised immediately instead of wrapping None.
  • tests/test_plot_collection_getattr.py: Added tests validating that:
    • The None guard exists in the source and comes before download(new_attr)
    • The fixed logic raises AttributeError for None while the buggy logic would wrap it
    • The download decorator wrapping None produces the reported TypeError

Verification

  • AST syntax check passed for all modified files
  • All 3 new tests pass
  • Minimal change — only the __getattr__ control flow was modified

Classification

  • Type: bug
  • Confidence: high
  • Severity: medium

Closes #454

Open in Web View Automation 

…otCollection.__getattr__

When PlotBase.get_attribute_helper() returns None (e.g. due to partial
import failures in stereo/plots/__init__.py), the code was wrapping None
with the download decorator. This created a callable wrapper that crashed
with TypeError: 'NoneType' object is not callable when invoked.

The fix checks for None immediately after get_attribute_helper() returns,
raising a clear AttributeError instead of silently wrapping None.

Co-authored-by: wanruiwen-genomics-cn <wanruiwen-genomics-cn@users.noreply.github.com>
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.

TypeError: 'NoneType' object is not callable

1 participant