-
Notifications
You must be signed in to change notification settings - Fork 5
Description
When I created the tool directory, I've added imports in __init__py
, to allow a shorter path to import tools, i.e. from fab.tools import Compiler
instead of from fab.tools.compiler import Compiler
. We have used this extensively in PSyclone.
But, with the more thorough typing that Fab is using (we are only now starting to add this in PSyclone), we are getting more and more cyclic import problems, which need to be avoided using:
- imports not at top of the file
- using
if TYPE_CHECKING
We are noticing the same issues in PSyclone now that we are using more typing :)
@MatthewHambley has already done some work on importing with the longer paths in Fab. At the same time, I think it would be convenient for a user script to have shorter paths, and be independent of the actual location of files.
Question: would it be worth to investigate:
- Removing all imports in
__init__.py
directories, and change any imports in Fab to use the full path. - Add a new
api
directory, which just contains a__init__.py
script that imports all classes and functions that a user (typically) needs. We might not be able to really cover all cases (since we don't control what user might want to do), but I would hope that we can cover a majority of the typical use cases.
A user script would then use:
from fap.api import compile_fortran, find_source_files, link_exe
....
Before I try if this makes sense, I would love to get some feedback (@yaswant , @MatthewHambley , @jasonjunweilyu , @t00sa @Pierre-siddall )
Metadata
Metadata
Assignees
Labels
Type
Projects
Status