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

Cannot infer from numbers ABCs #1636

Closed
AstraLuma opened this issue Oct 11, 2018 · 4 comments
Closed

Cannot infer from numbers ABCs #1636

AstraLuma opened this issue Oct 11, 2018 · 4 comments
Labels
enhancement it's not broken, but we want it to be better

Comments

@AstraLuma
Copy link

Trying to use infer when the annotation is from the numbers module ABCs fails, saying:

TypeError: Can't instantiate abstract class Real with abstract methods __abs__, __add__, __ceil__, __eq__, __float__, __floor__, __floordiv__, __le__, __lt__, __mod__, __mul__, __neg__, __pos__, __pow__, __radd__, __rfloordiv__, __rmod__, __rmul__, __round__, __rpow__, __rtruediv__, __truediv__, __trunc__

The behavior I expected is that it would just plug in a float.

@Zac-HD
Copy link
Member

Zac-HD commented Oct 11, 2018

What's happening here: the type Real is not (yet) in our type-to-strategy lookup, so after checking for some other metadata such as type annotations Hypothesis tries just calling it - which fails, because it's an abstract class.

Fortunately, we can just add some entries to the lookup! We even have a comment # Pull requests with more types welcome!, which would make a great first pull request 😄

@Zac-HD Zac-HD added enhancement it's not broken, but we want it to be better good first issue labels Oct 11, 2018
@Prsna23
Copy link

Prsna23 commented Oct 18, 2018

I would like to work on this issue. Can you please elaborate a little more on this?

@Zac-HD
Copy link
Member

Zac-HD commented Oct 18, 2018

Hi Prasana - unfortunately if the problem is not clear from reading the docs on numbers.Real and hypothesis.strategies.from_type and the solution obvious from reading the code linked above, this is probably not a good issue for you 😕

@SuperStormer
Copy link
Contributor

I'm working on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement it's not broken, but we want it to be better
Projects
None yet
Development

No branches or pull requests

4 participants