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

Bug pylint 2436 #643

Merged
merged 20 commits into from
Feb 24, 2019
Merged

Bug pylint 2436 #643

merged 20 commits into from
Feb 24, 2019

Conversation

hippo91
Copy link
Contributor

@hippo91 hippo91 commented Feb 9, 2019

Steps

  • [Ok ] For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • [Ok] Write a good description on what the PR does.

Description

This PR solve the bug reported as pylint-dev/pylint#2436.
In fact two problems were present.
The first one was a lack of unary operators definition for some numeric types in brain_numpy. Thus the inference of such operators failed and a message invalid-unary-operand-type was emitted.

The second one was a wrong inference of call to some numpy functions. A List or Tupleinstance was present in the inference generator. It has been corrected by adding some transformations in the brain_numpy module. Such transformation creates a closure in which the call to classical inference method is made and then filtered to remove undesirable types.

Type of Changes

Type
🐛 Bug fix

Related Issue

Close pylint-dev/pylint#2436

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hippo91 The first one with the missing methods makes sense. Can you split that up into its own separate PR? I am not sure about the first one though, as you mentioned in the comment from the original Pylint issue, the type you get depends on what argument you pass into a function. As such, it is entirely possible to get back a list or a tuple depending on the value that went into the function call. I don't think we should be doing anything here, in terms of modelling the types that those functions return, it would still be an Union[tuple, list, recarray, ...].

@hippo91
Copy link
Contributor Author

hippo91 commented Feb 14, 2019

@PCManticore, no pb i'll do a PR just for the first point.
For the second however i'wonder how it will be possible to suppress spurious message such as E1130: bad operand type for unary -: list (invalid-unary-operand-type) without filtering List or Tuple from inference results.
Moreover, from the numpy documentation, i understand, but i'm maybe wrong, that those function (array and linspace) return ndarray and not another type.

@hippo91
Copy link
Contributor Author

hippo91 commented Feb 15, 2019

@PCManticore , the PR for the first part is available under #645.

@PCManticore
Copy link
Contributor

@hippo91 Gotcha, that makes sense. I approved the PR, let's fix the conflicts and merge it.

@hippo91
Copy link
Contributor Author

hippo91 commented Feb 24, 2019

@PCManticore i fixed the conflicts. Only two unit tests are failing but they are identical to the ones that failed in previous commits. I merged the branch.

@hippo91 hippo91 merged commit 67f7daa into pylint-dev:master Feb 24, 2019
@hippo91 hippo91 deleted the bug_pylint_2436 branch June 20, 2020 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive E1130 invalid-unary-operand-type for Numpy array
2 participants