[Numpy-discussion] mypy false positives

2022-01-07 Thread Vincent Schut

Hi all,

I've got a question about numpy typing. We have our own internal 
codebase that heavily depends on numpy, and we're trying to get the 
number of mypy errors down. Many of the remaining mypy errors are 
actually numpy false positives. I hoped that with the numpy 1.22.0 
release these would be fixed, as there ought to be many typing 
improvements in that version, but apparently they're not? I'm asking 
here to check if this is just still a work in progress and we should be 
patient, or if there's something wrong on our side...?



Some typical false positives are:

"finfo[float32]" has no attribute "tiny"
Module has no attribute "count_nonzero"
Module has no attribute "rot90"
Module has no attribute "asfortranarray"
Module has no attribute "isfinite"
Module has no attribute "any"
Module has no attribute "histogram"; maybe "histogramdd"?
Module has no attribute "bitwise_or"
Module has no attribute "bitwise_and"
Module has no attribute "indices"
Module has no attribute "pad"

versions:
python 3.8.10; numpy 1.22.0; mypy 0.930

--



Vincent Schut

Remote Sensing Software Engineer

+31 302272679 ~ Maliebaan 22 | 3581CP | Utrecht | Netherlands

Linkedin ~
satelligence.com 

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: mypy false positives

2022-01-07 Thread bas van beek
Hi Vincent,

Could it be that you're overriding numpy's type annotations with those from an 
external stub-only package?
The functions that you mentioned have been annotated as being in the main 
namespace ever since the 1.20 release;
the error message for `finfo` in particular makes me suspicious.

For reference:
```
finfo_obj = np.finfo(np.float64)
reveal_type(finfo_obj.tiny)  # Revealed type is 
"numpy.floating*[numpy.typing._64Bit*]"
reveal_type(finfo_obj.foo)  # "finfo[floating[_64Bit]]" has no attribute "foo"
```

Regards,
Bas van Beek

From: Vincent Schut 
Sent: 07 January 2022 15:38
To: numpy-discussion@python.org 
Subject: [Numpy-discussion] mypy false positives

Hi all,

I've got a question about numpy typing. We have our own internal
codebase that heavily depends on numpy, and we're trying to get the
number of mypy errors down. Many of the remaining mypy errors are
actually numpy false positives. I hoped that with the numpy 1.22.0
release these would be fixed, as there ought to be many typing
improvements in that version, but apparently they're not? I'm asking
here to check if this is just still a work in progress and we should be
patient, or if there's something wrong on our side...?


Some typical false positives are:

"finfo[float32]" has no attribute "tiny"
Module has no attribute "count_nonzero"
Module has no attribute "rot90"
Module has no attribute "asfortranarray"
Module has no attribute "isfinite"
Module has no attribute "any"
Module has no attribute "histogram"; maybe "histogramdd"?
Module has no attribute "bitwise_or"
Module has no attribute "bitwise_and"
Module has no attribute "indices"
Module has no attribute "pad"

versions:
python 3.8.10; numpy 1.22.0; mypy 0.930

--



Vincent Schut

Remote Sensing Software Engineer

+31 302272679 ~ Maliebaan 22 | 3581CP | Utrecht | Netherlands

Linkedin ~
satelligence.com 

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: bas.vanb...@hotmail.com
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: mypy false positives

2022-01-07 Thread Vincent Schut

Hi Bas,

thank you! I checked and indeed: I was surprised to see the outdated 
"data-science-types" package installed. I removed it and the amount of 
mypy errors decreased dramatically. I'm so glad I asked, I already spent 
way too much time at googling ;-)


Thanks again for the fast and accurate reply!
Vincent.

On 1/7/22 15:58, bas van beek wrote:

Hi Vincent,

Could it be that you're overriding numpy's type annotations with those 
from an external stub-only package?
The functions that you mentioned have been annotated as being in the 
main namespace ever since the 1.20 release;

the error message for `finfo` in particular makes me suspicious.

For reference:
```
finfo_obj = np.finfo(np.float64)
reveal_type(finfo_obj.tiny)# Revealed type is 
"numpy.floating*[numpy.typing._64Bit*]"

reveal_type(finfo_obj.foo)# "finfo[floating[_64Bit]]" has no attribute "foo"
```

Regards,
Bas van Beek

*From:* Vincent Schut 
*Sent:* 07 January 2022 15:38
*To:* numpy-discussion@python.org 
*Subject:* [Numpy-discussion] mypy false positives
Hi all,

I've got a question about numpy typing. We have our own internal
codebase that heavily depends on numpy, and we're trying to get the
number of mypy errors down. Many of the remaining mypy errors are
actually numpy false positives. I hoped that with the numpy 1.22.0
release these would be fixed, as there ought to be many typing
improvements in that version, but apparently they're not? I'm asking
here to check if this is just still a work in progress and we should be
patient, or if there's something wrong on our side...?


Some typical false positives are:

"finfo[float32]" has no attribute "tiny"
Module has no attribute "count_nonzero"
Module has no attribute "rot90"
Module has no attribute "asfortranarray"
Module has no attribute "isfinite"
Module has no attribute "any"
Module has no attribute "histogram"; maybe "histogramdd"?
Module has no attribute "bitwise_or"
Module has no attribute "bitwise_and"
Module has no attribute "indices"
Module has no attribute "pad"

versions:
python 3.8.10; numpy 1.22.0; mypy 0.930

--



Vincent Schut

Remote Sensing Software Engineer

+31 302272679 ~ Maliebaan 22 | 3581CP | Utrecht | Netherlands

Linkedin >~
satelligence.com 
>


___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ 


Member address: bas.vanb...@hotmail.com

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: sc...@satelligence.com


--



Vincent Schut

Remote Sensing Software Engineer

+31 302272679 ~ Maliebaan 22 | 3581CP | Utrecht | Netherlands

Linkedin ~
satelligence.com 

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com