sloria / konch

Configures your Python shell.
https://konch.readthedocs.io/
MIT License
406 stars 18 forks source link

Update to use importlib. #102

Closed brl0 closed 5 years ago

sloria commented 5 years ago

Is there a reason you didn't use this approach from the docs: https://docs.python.org/3.7/library/importlib.html#importing-a-source-file-directly ?

brl0 commented 5 years ago

I didn't look too much further after finding a solution that worked. I thought that the approach I used was a bit closer to a drop in replacement and would therefore require the least overall code changes. But again, I did not spend a lot of time once I found a workable solution, so there may very well be better solutions available.

brl0 commented 5 years ago

The recipe in the linked docs assumes a .py extension, which is why it doesn't work as-is. Found this answer, which is needed to make the recipe work correctly in this particular case. Also had to add an assert to make MyPy happy.

sloria commented 5 years ago

The solution was actually simpler. See https://github.com/sloria/konch/pull/109 . Thanks for your initial work on this.