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

False positive: too-many-function-args for numpy #2326

Closed
jwkvam opened this issue Jul 20, 2018 · 16 comments · Fixed by pylint-dev/astroid#664
Closed

False positive: too-many-function-args for numpy #2326

jwkvam opened this issue Jul 20, 2018 · 16 comments · Fixed by pylint-dev/astroid#664
Assignees
Labels

Comments

@jwkvam
Copy link
Contributor

jwkvam commented Jul 20, 2018

Steps to reproduce

test.py

import numpy as np
x = np.fromfile('hello.npy')
x.reshape((1, 5))

https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.reshape.html#numpy.ndarray.reshape

pylint test.py
test.py:3:6: E1121: Too many positional arguments for method call (too-many-function-args)

Current behavior

too-many-function-args

Expected behavior

No error

pylint --version output

pylint 2.0.0
astroid 2.0.1
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:44:09)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]

@PCManticore
Copy link
Contributor

Hi @jwkvam

What version of numpy do you have? Locally using the same pylint and Python version, I'm not getting the error, getting instead:

************* Module a
a.py:1:0: C0111: Missing module docstring (missing-docstring)
a.py:2:0: C0103: Constant name "x" doesn't conform to UPPER_CASE naming style (invalid-name)

@PCManticore PCManticore added the Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine label Jul 23, 2018
@jwkvam
Copy link
Contributor Author

jwkvam commented Jul 23, 2018

After some further debugging it seems this is only triggered with:

extension-pkg-whitelist=numpy

in my pylintrc. I've tried this with numpy 1.14.5 and 1.15.0. I forget why I whitelisted numpy in the first place, it was likely years ago. I don't know if this is still a bug :/

@PCManticore PCManticore added Bug 🪲 and removed Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine labels Jul 26, 2018
@PCManticore
Copy link
Contributor

Thanks, now I can also reproduce it with extension-pkg-whitelist.

@NotSqrt
Copy link

NotSqrt commented Jul 31, 2018

Hi,

Same kind of behaviour with :

import numpy as np
np.timedelta64(10, 'ms')

I also have extension-pkg-whitelist=numpy in my pylintrc, due to all the no-member errors that pylint generated at the time for numpy (I haven't checked if these errors are still there).

Thanks !

@PCManticore PCManticore changed the title False positive: too-many-function-args False positive: too-many-function-args for numpy Aug 8, 2018
@chrisjbillington
Copy link

For me I get E1121: Too many positional arguments for constructor call (too-many-function-args) for date = np.datetime64("2018-01-14", "D") even with an empty .pylintrc. Versions are:

$ pylint --version
pylint 2.2.2
astroid 2.1.0
Python 3.7.2 (default, Jan 10 2019, 23:51:51) 
[GCC 8.2.1 20181127]

and numpy 1.15.4

@Pluckerpluck
Copy link

I can confirm that using:

one_day = np.timedelta64(1, 'D')

results in E1121: Too many positional arguments for constructor call (too-many-function-args)

I have no .pylintrc and have the following versions:

pylint 2.2.2
astroid 2.1.0
Python 3.6.6
numpy 1.15.4

@polosatik
Copy link

Same here: np.timedelta64(1, 'D)
pylint 2.2.2
astroid 2.1.0
Python 3.6.1
numpy 1.15.1

It might be something similar to what causes PyCharm to misinterpret skeletons for numpy.
https://youtrack.jetbrains.com/issue/PY-23521

@krispharper
Copy link

I'm also seeing this issue with np.timedelta64(1, "D") and

astroid   2.2.2
numpy     1.15.1
pylint    2.3.0
python    3.6.8

@hippo91 hippo91 self-assigned this Apr 7, 2019
@Mazata
Copy link

Mazata commented Apr 9, 2019

Same problem for me with np.timedelta64(1,'D'): "too many positional arguments"

astroid 2.2.5
numpy 1.16.2
pylint 2.3.1
python 3.7.2

@waiyip-aquabyte
Copy link

waiyip-aquabyte commented Apr 9, 2020

I still see this in

pylint
astroid 2.3.3
Python 3.7.3 (default, Dec 29 2019, 20:14:33)
[GCC 9.2.1 20191130]

>>> numpy.version.version
 '1.18.2'                             

@EdmundsEcho
Copy link

This is a helpful tool. Thank you.

FYI - I'm getting this error with the following versions:

pylint 2.5.3
astroid 2.4.2
Python 3.7.3 (default, Jun  2 2020, 13:01:47)
[Clang 11.0.3 (clang-1103.0.32.59)]

numpy: 1.15.0

- E

@hippo91
Copy link
Contributor

hippo91 commented Jun 27, 2020

@EdmundsEcho @waiyip-aquabyte i'm unable to reproduce the bug with an astroid version >= 2.3.3.

@SagaraBattousai
Copy link

I'm also having this issue with numpy reshape (I think its because I am reshaping to add dimension so I'll use np.newaxis for now but it looks messier for this particular line of code.

Using :
pylint==2.8.3
numpy==1.18.5

and getting: E1121: Too many positional arguments for method call (too-many-function-args) as a response.

@ntraut
Copy link

ntraut commented Nov 30, 2022

We can get the error with:

x = np.zeros(12)
x.reshape(3, 2, 2)

It is because pylint doesn't understand that we can pass each element of the shape parameter as a separated argument, as stated in the documentation.

@Pierre-Sassoulas
Copy link
Member

@ntraut could you open a new bug issue please ? This one is unlikely to get any attention because it's closed.

@ntraut
Copy link

ntraut commented Dec 1, 2022

@ntraut could you open a new bug issue please ? This one is unlikely to get any attention because it's closed.

i created the new issue #7883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.