Skip to content

fix: bind magic factories as method descriptors - #738

Open
JosephDemarest wants to merge 1 commit into
pyapp-kit:mainfrom
JosephDemarest:fix/magic-factory-descriptor
Open

fix: bind magic factories as method descriptors#738
JosephDemarest wants to merge 1 commit into
pyapp-kit:mainfrom
JosephDemarest:fix/magic-factory-descriptor

Conversation

@JosephDemarest

Copy link
Copy Markdown

Summary

  • bind the decorated function when a MagicFactory is accessed through an instance
  • preserve class-level access, factory options, widget_init, and the originating type map
  • cover independent instance binding and ensure a temporary bound factory does not retain its instance

Fixes #733

Tests

  • Python 3.12.9: python -m pytest -q (330 passed, 51 skipped, 13 xfailed)
  • Python 3.14.6: python -m pytest tests/test_factory.py -q (12 passed)
  • pre-commit run --all-files
  • mypy src/magicgui/type_map/_magicgui.py

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.34%. Comparing base (2f08fb3) to head (9fb93ea).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #738      +/-   ##
==========================================
+ Coverage   89.32%   89.34%   +0.01%     
==========================================
  Files          40       40              
  Lines        4835     4843       +8     
==========================================
+ Hits         4319     4327       +8     
  Misses        516      516              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

@magic_factory doesn't work as a method descriptor properly

1 participant