question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace absolute imports with relative imports

See original GitHub issue

I’d like to use 2.0 in a project of mine, but I rely on some packages that don’t yet support it, so my intent is to temporarily bundle prompt_toolkit as a subpackage until these issues clear themselves up. When trying to do this, I discovered many absolute imports that could/should be rewritten as package-relative, e.g. in application.py.

Would you be willing to accept a PR that replaces the absolute imports of prompt_toolkit.x with relative imports? I’d stick to the library code and wouldn’t touch examples/tests/etc.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
natezbcommented, Jul 31, 2018

While I’d argue that using relative imports is the “correct” thing to do, I agree with you that it seems other large, well-established projects are getting along fine with absolute imports.

I also agree that adding docs/scripts concerning vendoring would be valuable, as I can’t imagine I’m the only person who will run into this issue with the 1.0/2.0 split.

When I get the chance I can play around with that one-liner and let you know what tweaks need to be made, if any.

0reactions
alejandrogallocommented, Feb 15, 2019

I’m glad I found this, since I intend to do the same with my project, I too intend to do it this way by replacing all from ... with my package namespace. I hope in the future this is not broken too much @jonathanslenders , if you could have in mind people like us when you further develop that’d be great! Thanks for your great lib!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute vs Relative Imports in Python
A relative import specifies the resource to be imported relative to the current location—that is, the location where the import statement is. There...
Read more >
Absolute and Relative Imports in Python - GeeksforGeeks
Absolute import involves a full path i.e., from the project's root folder to the desired module. An absolute import state that the resource...
Read more >
Get rid of relative import path hell by adding absolute imports ...
We're gonna make a minor change in tsconfig.json . Under the paths property, add another path definition indicate src folder: ... "paths": ...
Read more >
How Pros Get Rid of Relative Imports - DEV Community ‍ ‍
The easiest way to get rid of the long imports is to add baseUrl in the jsconfig.json (add jsconfig.json at the root level...
Read more >
Automatically Fixing Relative Imports with ESLint - Jeff Chen
Absolute imports were the answer—I needed to both set up TypeScript to support them and transform all of the project's relative imports into ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found