-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 FIX:
aiida/repository
typing (#4920)
There was a subtle bug in `_insert_file`, where in the else clause of the conditional `self.get_directory` was missing the parentheses to call the method. This didn't show up in the tests because the code path was actually not reachable since the conditional is always True. The original intention was to get the parent directory of the file to be created, and only create it if it wasn't already created. However, this behavior is anyway guaranteed by `create_directory` so this can be safely called in all instances and we can get rid of the entire conditional. In certain methods, such as `open`, an explicit assert had to be placed to check that the `File` instance returned by `get_file` had a `key` that is not `None`, or `mypy` would complain. The reason that this is an assert is because a `File` of type `FileType.FILE` always has `key` that is not `None`, as is guaranteed by its constructor and the `get_file` method will check that the path does correspond to a file and not a directory, in which case it would raise `IsADirectory`. However, `mypy` cannot introspect this polymorphism and so the explicit check is needed. Since this would constitute an internal coding error if the check fails, we use an assert. Finally, the design of the `put_object_from_filelike` method in the abstract class that performed the validation such that subclasses would not have to, also didn't please the `mypy` gods. So instead, the validation implementation of this method is moved to the protected method `_put_object_from_filelike` and the base class performs the validation and then calls this method.
- Loading branch information
1 parent
597a4d0
commit bff117a
Showing
12 changed files
with
80 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.