Add support for absolute imports
See original GitHub issueCurrently only relative imports are supported for local packages, however that is definitely not the pythonic way to do things. In Python absolute imports are preferred over relative imports.
Also few things are difficult by just using relative imports:
# file: constants.py
A = "a"
B = "b"
# file: main.py
from .constants import A, B # works fine
import .constants # Doesn't work!
By this behaviour, Python functions app forces from ... import ...
syntax which is not always preferred and many times against organization specific style guidelines.
Repro steps
Covered above.
Expected behavior
Absolute imports should be supported as per python guidelines.
Actual behavior
It fails!
Known workarounds
Use relative imports
Related information
On issue #81, relative imports are suggested.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Making Life Easier with Absolute Imports - React in Javascript ...
According to create-react-app Docs, We can use absolute imports in our react project by configuring a jsconfig.json / tsconfig.json (for ...
Read more >Why and How to Use Absolute Imports in React
Using absolute imports to better organize your React project is a great way. Relative imports are hard to follow and break during ...
Read more >Adding Support For Absolute Imports | halesworth.org
How to add support for absolute imports in your React apps. ... Add the following to your jsconfig.json or tsconfig.json at the root...
Read more >Absolute Import in React | create-react-app - BezKoder
In this tutorial, I will show you how to configure your React application to support 'Absolute Import' (Javascript and Typescript) with ...
Read more >Advanced Features: Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths. ... Next.js automatically supports the tsconfig.json and jsconfig.json "paths" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One key point that I want to make sure gets documented is if you’re going to require
__app__
as the top-level directory, then anyone who wants to run their Function code outside of the Function runtime (e.g. CI for unit tests) must keep their entire Function directory in an__app__
folder in order for those imports to resolve appropriately. IOW this will will essentially dictate the folder name that everyone’s Function-related files must be kept in if anyone chooses to use absolute imports.@maiqbal11 no problem! I’ve created another issue: #374