I am starting the Careless Development series where I post a little issue that started as a problem solving and ended up being an oversight issue. Utter disappointment! It took me some time to inspect Pycharm inside and out, so here it is.
I should say that the bigger the project, the more it happens. But enough of self-justification.
So I needed to test a script that uses Django, so in Pycharm manage.py console I ran this command:
shell < proj/extras/text.py
Of course, it contained numerous prints to test results…
At some point, I was satisfied with the results and I decided to import it somewhere in my project’s apps’ models. I didn’t use it right away, so I didn’t remember importing it at all.
Of course. I didn’t remove prints…
Eventually, the reason why ‘Pycharm insisted on running the script‘ was that before running a command Django runs everything Django-related the project contains, including imports…
Though, you can use Ctrl + Shift + O to remove unused imports, but it can bring you more trouble than help.