FakeFileWrapper: How handle isinstance(ffw, io.BaseIO)?
#896
-
|
Out there in the world packages and functions exist that checking the type of an object to find out if iti s a file-like object or a path/pathname. When I do
Now the question is how to handle that? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Good question - currently this is not possible. From the documentation:
This came up before (hence the note in the limitations), and so far I have no solution for this. |
Beta Was this translation helpful? Give feedback.
-
|
I'm moving this to discussions. I once already attempted to refactor the code accordingly, but got nowhere, so it is unlikely that this behavior will be changed any time soon. |
Beta Was this translation helpful? Give feedback.
-
|
Note that I have recently changed the behavior, so that |
Beta Was this translation helpful? Give feedback.
Note that I have recently changed the behavior, so that
FakeFileWrappernow derives fromio.BufferedIOBaseorio.TextIOBase(it forwards all calls to the fake wrapper anyway). The way I had tried to refactor this before was too complicated - the current implementation basically just fakes the inheritance, so thatisinstance(file_object, io.BaseIO)will now returnTrue.