od: Robust path handling without type errors#669
Open
acolomb wants to merge 7 commits into
Open
Conversation
Static type checking cannot see the relationship between the opened_here local variable and the type of object passed as dest parameter to export_od(). Switch to storing another reference to the opened file-like object instead of a boolean to avoid a [union-attr] error.
Utilize the standard library's os.path.splitext() function to find the file name suffix and treat it case-insensitively.
Utilize the standard library's os.path.splitext() function to find the file name suffix (case-insensitive). Fix a [union-attr] static type check error using an empty string as fallback for the file name on file-like objects. The annotated TextIO type does provide it, but mypy cannot infer that connection between with the "read" method being available. Failing with the ValueError in case the attribute is missing is still better than letting out an AttributeError.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the union-attr errors squelched in #651 properly. In the process, extend
import_od()to gracefully handle some edge cases around missing file names and non-strpaths in thesourceargument.Extend unit tests around import and export functions. Note that these are still a bit convoluted because the EDS import is tested through the generic, format-agnostic OD API. This is still much easier than splitting tests between generic and format-specific though. If ever someone adds unit tests covering the EPF import, that might need some refactoring.