-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use relative imports when importing other modules in the same directory
We were using absolute imports under the assumption that the /scripts directory is in the path. This worked in normal use because every one of our Python scripts either were in the /scripts directory, or added the /scripts directory to the module search path in order to reference mbedtls_dev. However, this broke things like ``` python3 -m unittest scripts/mbedtls_dev/psa_storage.py ``` Fix this by using relative imports. Relative imports are only supposed to be used inside a package (Python doesn't complain, but Pylint does). So make /scripts/mbedtls_dev a proper package by creating __init__.py. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
- Loading branch information
1 parent
ca980c0
commit 239765a
Showing
5 changed files
with
8 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This file needs to exist to make mbedtls_dev a package. | ||
# Among other things, this allows modules in this directory to make | ||
# relative impotrs. |
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