Skip to content

numpy comparison-with-callable / no-member confusion #2784

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

Closed

Comments

@belm0
Copy link
Contributor

belm0 commented Mar 4, 2019

appears to be a recent regression

e.g.:

if numpy.random.random() < 0.5:
   pass
W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)

and

result = numpy.logical_and(...)
result.fill_value = 0
avg = numpy.mean(result.filled())
E1101: Function 'any' has no 'filled' member (no-member)

pylint --version output

pylint 2.3.1
astroid 2.2.2
Python 3.7.1 (default, Nov  6 2018, 18:45:35)
[Clang 10.0.0 (clang-1000.11.45.5)]

numpy 1.16.2

@belm0
Copy link
Contributor Author

belm0 commented Mar 4, 2019

This and #2694 lead me to believe that pylint would greately benefit from a continuous build having tests for simple code using numpy.

@PCManticore
Copy link
Contributor

Thanks for the report, this is fixed in astroid's master. While having some simple tests with numpy on pylint's side would help, I'm not sure who can do that given that I don't use numpy personally.

@belm0
Copy link
Contributor Author

belm0 commented Mar 4, 2019

Thank you. When would the Astroid fix make it into a release?

A project I'm working on has been blocked from upgrading pylint for a while due to the successive regressions with numpy.

PCManticore added a commit to pylint-dev/astroid that referenced this issue Mar 4, 2019
…ransform

Turns out that this was conflicting with the `any` builtin, while the original
intention was to return a value that cannot be inferred, until we have support
for types.

This should fix a couple of false positives on pylint's side where the return
value of numpy functions was considered to be itself a function.

Close pylint-dev/pylint#2784
@PCManticore
Copy link
Contributor

Just released astroid 2.2.3 with this fix. Sorry to hear that, do you have by any chance a list of regressions that caused you to be blocked? Would be great to open some issues for them if we don't have them already opened.

@belm0
Copy link
Contributor Author

belm0 commented Mar 5, 2019

Thank you for making another release.

I just had some concern that the release might take a while as for #2694.

clrpackages pushed a commit to clearlinux-pkgs/astroid that referenced this issue Mar 6, 2019
….2.3

What's New in astroid 2.2.3?
============================
Release Date: 2019-03-03

* Replace `any` with `uninferable` when returning values from `numpy` transform

  Turns out that this was conflicting with the `any` builtin, while the original
  intention was to return a value that cannot be inferred, until we have support
  for types.

  This should fix a couple of false positives on pylint's side where the return
  value of numpy functions was considered to be itself a function.

  Close pylint-dev/pylint#2784
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment