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

add literal eval fallback widget #31

Merged
merged 5 commits into from
Jul 14, 2020

Conversation

tlambert03
Copy link
Member

closes #29 by adding a LiteralEvalEdit that is used when type inference fails. As this uses literal_eval instead of eval, this is a "safe" fix, but will miss a lot of edge cases.

@@ -326,14 +326,20 @@ class instance using setattr(self, self.WIDGET_ATTR.format(name), widget).
try:
WidgetType = type2widget(arg_type)
except TypeError:
funcname = getattr(self.func, "__name__", repr(self.func))
Copy link
Member Author

Choose a reason for hiding this comment

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

not directly related to this PR ... but I found that partial functions weren't working since they don't have a __name__ or __annotation__ attribute.

@codecov
Copy link

codecov bot commented Jul 13, 2020

Codecov Report

Merging #31 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #31      +/-   ##
==========================================
+ Coverage   95.76%   95.82%   +0.05%     
==========================================
  Files          13       14       +1     
  Lines         921      934      +13     
==========================================
+ Hits          882      895      +13     
  Misses         39       39              
Impacted Files Coverage Δ
magicgui/_qt/__init__.py 100.00% <100.00%> (ø)
magicgui/_qt/widgets/__init__.py 100.00% <100.00%> (ø)
magicgui/_qt/widgets/eval_lineedit.py 100.00% <100.00%> (ø)
magicgui/_tests/test_ qt.py 98.97% <100.00%> (+0.04%) ⬆️
magicgui/_tests/test_magicgui.py 92.18% <100.00%> (ø)
magicgui/core.py 98.81% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 880a6c0...1acac1d. Read the comment docs.

@tlambert03 tlambert03 merged commit db4c816 into pyapp-kit:master Jul 14, 2020
@tlambert03 tlambert03 deleted the literal-eval-fallback branch July 14, 2020 01:59
Copy link
Contributor

@jni jni left a comment

Choose a reason for hiding this comment

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

Looking good! =)

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.

Use eval'd text box as fallback when type inference fails
2 participants