-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 E1130 invalid-unary-operand-type for Numpy array #2436
False positive E1130 invalid-unary-operand-type for Numpy array #2436
Comments
Thanks for creating an issue, can confirm the bug! |
This also triggers on scalar types like |
Bug is still there.
Obviously, this is a bug. There is no tuple at all. (Maybe this is the wrong ticket for my issue? I’m not sure.) |
@cdeil in fact there are two problems:
Currently I have found a solution for both problems. I'm trying to make it the more general as possible. |
…ed single and double quotes. Azeem Bande-Ali (1): Docs: Fixing transformation example to be functional (#640) Benjamin Elven (1): Added 2 more missing _ssl constants (#648) Bianca Power (1): Fix typo in description for brain_attrs (#638) Claudiu Popa (48): Add reversed() to Enum classes Use a string for the name of the enum instead of grabbing it as a variable Added special support for `enum.IntFlag` Pin typed_ast so a new release won't break the pylint's pragmas Fix a bug where an Attribute used as a base class was triggering a crash Add missing _ssl constant. Close pylint-dev/pylint#2629 ``typing`` types have the `__args__` property. Close pylint-dev/pylint#2419 Make sure the test does not crash if the directory already exists Revert path copying in InferenceContext() Prevent crashing when processing ``enums`` with mixed single and double quotes. Move infer_name_module() in pylint and remove it from here Remove test that does not work actually work consistently on all Python versions Disable the pylint job until we fix the clone inference bugs Revert "Disable the pylint job until we fix the clone inference bugs" Add brain tips for `http.client`. Close pylint-dev/pylint#2687 Revert "Remove the restore_path() method" Add a registry for builtin exception models. Close pylint-dev/pylint#1432 Disable test on Python 3.4 Change the filter to use equal Use a different prefix for the object model methods Added more builtin exceptions attributes. Close #580 Remove StopIteration handling which should not leak at all from inference Replace a couple of returns with explicit InferenceError exceptions Make sure that Attribute.infer has a protection against StopIterations Add a method to the manager to retrieve the builtins module Remove the restriction that "old style classes" cannot have a MRO. Remove inadvertent test which still does not have a fix Adjust the pull request template a little bit Make the astroid bootstrapping take care of builtins such as Generator Prepare a dev release Fix a recursion error caused by inferring the ``slice`` builtin. Bump typed_ast to 1.2.0 ``brain_numpy`` returns an undefined type for ``numpy`` methods to avoid ``assignment-from-no-retur Remove inadvertent returns from class bodies Fix a crash in the ``enum`` brain tip caused by non-assign members in class definitions. Support non-const nodes as values of Enum attributes. Add a proper ``strerror`` inference to the ``OSError`` exceptions. Fix a crash with ``typing.NamedTuple`` and empty fields. Close pylint-dev/pylint#2745 Update to typed-ast 1.3 and drop the Python 3.7 restriction Install typed ast 1.3 for Python 3.7 and earlier versions for Python 3.6 Do a new dev release Use the same versions in tox as in __pkginfo__ Use the right pytest methods for setup and teardown Don't clear the manager caching any longer Remove merge marker Prepare 2.2.0 Disable test that does not make sense on versions older than Python 3.6 When picking the parse function, make sure to parse with the right minor version Nick Drozd (1): Cut generator flags Peter Talley (1): Add new Popen kwarg 'text' in Python 3.7 Tomas Gavenciak (2): Remove else after return/raise Extend detection of classes defined with attr hippo91 (11): Just breakpoint to debug and mark the origin of the problem Revert "Just breakpoint to debug and mark the origin of the problem" Refactoring chained comparison (#636) Avoid statement deletion in the _filter_stmts method of the LookupMixin class for PartialFunction Adding support for unary operators for numpy ndarray and numbers. Adding hook to filter results of infer_call_result from list and tuples for function array and linspace Refactoring to code DRY Add a unittest checking that the call to numpy.array function is not inferred as a list or a tuple Refactors and generalizes unittests dealing with tuple or list inference of numpy function calls Add of ChangeLog entry Format according to Black Add support of unary operators to numpy types. What's New in astroid 2.2.0? ============================ Release Date: 2019-02-27 * Fix a bug concerning inference of calls to numpy function that should not return Tuple or List instances. Close pylint-dev/pylint#2436 * ``typed_ast`` gets installed for Python 3.7, meaning type comments can now work on 3.7. * Fix a bug concerning inference of unary operators on numpy types. Close pylint-dev/pylint#2436 (first part) (NEWS truncated at 15 lines)
Pylint emits a false positive E1130 invalid-unary-operand-type error for Numpy arrays:
Actually, in this case, it emits two:
This is not just for np.array, I get a similar false positive for np.atleast_1d, which also returns Numpy arrays. But np.array is super common in scientific Python projects.
This issue was already mentioned in #1472 and #1497 , but @PCManticore you suggested to split out a new issue with a simple test case that doesn't involve flow control in #1472 (comment) , so there you have it.
:-)
Thanks for all your work on pylint, it's a huge help!
The text was updated successfully, but these errors were encountered: