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
f-string conversion with advanced string formatting & None #528
Comments
sadly I think this is unfixable -- there would need to be type analysis to properly know that "None" is buggy -- the only other option is disabling all alignment conversions arguably this is a bug in python itself, I see no reason that the padding formatters shouldn't work for I'm not sure what the best thing to do here is
>>> '{:8}'.format("a")
'a '
>>> '{:8}'.format(1)
' 1'
>>> '%8s' % ('a',)
' a'
>>> '%8s' % (1,)
' 1' an aside, please don't mention flynt -- the author has ripped me off in the past and has generally been an uncooperative and unethical open source maintainer |
I guess the only safe approach is skipping -- #529 implements that |
I was also wondering if this was a Python bug too, I had a quick look but didn't find anything on their tracker. I agree that unless a future version of Python changes this, disabling any conversion with an alignment is safest. |
we'll see where this goes: https://bugs.python.org/issue45165 |
Failing test case using pyupgrade 2.25.0:
The problem is while
f"{None}"
works, advanced string format arguments do not:Possible workaround:
This issue was found in biopython/biopython#3724
The text was updated successfully, but these errors were encountered: