Skip to content

Conversation

bswck
Copy link

@bswck bswck commented Jun 23, 2024

Getting an import error while trying to from foo import bar does not mean specifically that bar could not be imported from foo.

It might mean a bunch of things:

  • foo wasn't found
  • bar wasn't found in foo (the assumed case and probably the reason that the traceback is hidden as of now)
  • an inner import in foo's code raised an unrelated import error

In the last case, we never get to know what inner import causes the import failure.
Thus, let's always show the import error traceback.

I didn't make an additional --tb/--show-traceback switch (similar to the one mypy has) because I see it as an overkill for a package that ends with -dev.
In this PR I also cleaned some leftovers that probably should instead be picked up by linters in CI; a good reason for another PR.

@bswck
Copy link
Author

bswck commented Jun 23, 2024

In the PR, I allowed myself to remove the ExecImportError class as well as its and SyntaxError's exception handling in the exec_import callee.
That code is unreachable.

@bswck bswck closed this by deleting the head repository Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant