Core Problem:
I've run into situations multiple times where pyc
files break my local application (especially unit tests).
For example I have a folder utils/
which contains a poorly named sqlalchemy.py
(which just contains utilities for sql alchemy). I add another file utilities/whatever.py
which contains
import sqlalchemy.orm.session
and that breaks because well...the python2 importer at least thinks "I'm going to look at the relative path first". So I rename or delete utilities/sqlalchemy.py
and everything works hunky dory.
Until my teammates pull down changes and everything breaks. Because while their copy no longer has utilities/sqlalchemy.py
, it still has the git ignored utilities/sqlalchemy.pyc
file
What I Want:
Is there a way to get the python importer to ignore pyc files? I would of course only want this to be active locally when running unit test, so I'm hoping for like an environment variable or a configuration for the python importer, but hoping other people have run into this problem enough that there's some sort of "quasi-official" solution.
Note that I specifically don't want to do something like find . -name '*.pyc' -delete
in a post-checkout git hook since our repo is large enough that this takes several minutes and would really slow us down every time someone switches branches.