Trying to annotate a file in my function there is the following issue with my pep8-checker (flake8):
def my_function(myfile: file): pass
gives
'undefined name file
' .
Fair enough - there is no such function in python3 anymore. The only possibility to check for variable is a file-like object is IOBase
from io package.
In my case it would mean that I would need to import IOBase from io package just to get a proper annotation.
from io import IOBase
def my_function(myfile: IOBase):
pass
Is there another way to proper anotate an argument of file-type properly?
You are using or running the wrong version of flake. The code above works perfectly with flake8-2.5.0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.