A simple program in PyCharm 2024.2.3.(Community Edition)
import pickle
fruits = ['apples', 'oranges', 'banana']
with open('myData.pkl', 'wb') as f:
pickle.dump(fruits, f)
PyCharm gives me a warning:
Expected type 'SupportsWrite[bytes]', got 'BinaryIO' instead
The program runs correctly, but how do I get rid of this warning?
Python tutorials say that this simple usage of pickle should work.
The warning is erroneous. You can suppress it as follows:
import pickle
fruits = ['apples', 'oranges', 'banana']
with open('myData.pkl', 'wb') as f:
# noinspection PyTypeChecker
pickle.dump(fruits, f)
Note:
This is specific to PyCharm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With