Pylint: False positive: too-many-function-args for numpy

Created on 21 Jul 2018  路  12Comments  路  Source: PyCQA/pylint

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)]

bug

Most helpful comment

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

All 12 comments

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)

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 :/

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

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 !

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

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

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

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

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

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'                             

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ethanchewy picture ethanchewy  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments

thanatos picture thanatos  路  3Comments

TBoshoven picture TBoshoven  路  3Comments

PCManticore picture PCManticore  路  3Comments