Fix issue with logic around type of object returned by smart_open#26
Conversation
This fixes an issue where the return type of smart_open can vary in different environments. There was a check in place that was made under the assumption the return type would be consistent with what I was seeing in my development environment at time of coding; however in another instance I found this open returned an unexpected type for an open file. This change avoids having type checking interefere with runtime logic by assigning the open for file to `Any`, which skips further type checking.
|
Hey @lossyrob is there a reason related to mypy or something that we can't just use the open within the context? ie |
|
@bitner yeah, smart_open.open describes a return type, but it's with open(file, "rb") as f: # type:ignore
async with DB(dsn) as conn:
await load_iterator(f, table, conn, method)but then the type information around f is not ignored moving forward in the code, and other "type:ignore" tags might be needed. Assigning the return value to |
|
uggh. annoying, but makes sense. |
This fixes an issue introduced in #18 with the usage of
isinstanceto check the return type ofsmart_open.open.There was a check in place that was made under the assumption the return type would be consistent with what I was seeing in my development environment at time of coding; however in another instance I found this open returned an unexpected type for an
open file.
This change avoids having type checking interfere with runtime logic by assigning the open for file to
Any, which skips further type checking.