Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite abspath(__file__) to __file__ in py39+ #580

Merged
merged 1 commit into from Dec 28, 2021

Conversation

MarcoGorelli
Copy link
Contributor

resolves #576

@MarcoGorelli MarcoGorelli force-pushed the abspathfile branch 2 times, most recently from 228e11e to e75a0bd Compare December 27, 2021 15:04
Copy link
Owner

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit ab02f4a into asottile:master Dec 28, 2021
@MarcoGorelli MarcoGorelli deleted the abspathfile branch December 28, 2021 09:24
@adamantike
Copy link

I will try to create a simple example and open a separate issue, but this change is breaking a script we are running with Python 3.9 and alembic.

We run alembic upgrade --sql head, while having a line like this in alembic/env.py:

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

That works, but after running pyupgrade, that line gets replaced with:

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

And the alembic command fails. Printing __file__ shows:

ipdb> __file__
'alembic/env.py'
ipdb> import sys; sys.version
'3.9.13 (main, Aug  2 2022, 11:20:39) \n[GCC 10.2.1 20210110]'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

py39+: abspath(__file__) -> __file__
3 participants