Over the last little while, I have worked to develop a tool to be used for parsing imports in python. This tool has had several different versions and specifications, but this week finally found its use. This week I decide to get into the belly of the beast, and begin hashing away at the improper imports in the keras, and tests directories.
Identifying The Problem
The purpose of the tool is to check for absolute and relative imports in a specified directory or file. Thanks to some intuition, my tool does exactly this! The results are a dictionary of filenames as keys, with the error(s) as values, which tells me the problem and on which line.
Absolute vs Relative
Anywhere a relative import can be used, an absolute can as well, just as with absolute and relative paths. This idea can be seen as follows:
from . import A1
from .SubA import A2
With everything set up, and my tool working, I began to pick away at dictionary full of errors, starting with the absolute imports. There were over 58 files with errors in them, all with at least 1 error. I began to go through the errors solving them one by one. Currently I have completed all import errors in the keras directory, changing relative imports to absolute, with only the tests directory to go.
Given how long the keras directory took, the tests directory will take even longer. The tests directory has less files, but more errors to be fixed. This gives me an opportunity to get my hands dirty, and touch a number of files in the repository.
Until next time…