You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiline statements not upgraded for f-strings (Py 3.6+) #178
Sorry I assumed this would be an open issue and didn't see it. Given that this is the third repeat of the issue maybe some less timid option might be handy? It's easy enough for users to fix line length post facto with automated tools.
@asottile - this package is generally way beyond my level, but I had a look anyway and did spot the nicely labeled timid restrictions. A couple of them look relevant, in particular the bit about not making an f-string longer. But no joy, commenting out the break did not help, and the print statements show for my example code that these clauses are never being reached:
diff --git a/pyupgrade.py b/pyupgrade.py
index dd5f23c..5120bd6 100644
--- a/pyupgrade.py+++ b/pyupgrade.py@@ -1636,7 +1636,8 @@ def _fix_py3_plus(contents_text): # type: (str) -> str
while tokens[j].src != node.attr:
# timid: if we see a parenthesis here, skip it
if tokens[j].src == ')':
- return+ print('Not timid!!')+ # return
j += 1
tokens[i:j + 1] = [new_token]
@@ -1812,7 +1813,8 @@ class FindSimpleFormats(ast.NodeVisitor):
candidate, _, _ = name.partition('.')
# timid: could make the f-string longer
if candidate and candidate in seen:
- break+ print('Not timid!')+ # break
# timid: bracketed
elif '[' in name:
break
parenthesized strings that are then .format(...)ed
repeated names in format strings
The first two need some new code written for them (similar to the stuff that's happening for the py27 format strings, basically a state machine to collect all the separate STRING tokens that are implicit-joined). I ~eventually want something like this in tokenize-rt (since there's currently code for this both here and in future-fstrings that does the same parsing).
The second should (?) have been covered by the second part of the patch
Activity
asottile commentedon Jul 5, 2019
Please search the issue tracker next time! #55 #49
taldcroft commentedon Jul 5, 2019
Sorry I assumed this would be an open issue and didn't see it. Given that this is the third repeat of the issue maybe some less timid option might be handy? It's easy enough for users to fix line length post facto with automated tools.
asottile commentedon Jul 5, 2019
PRs welcome :)
taldcroft commentedon Jul 5, 2019
@asottile - this package is generally way beyond my level, but I had a look anyway and did spot the nicely labeled
timidrestrictions. A couple of them look relevant, in particular the bit about not making an f-string longer. But no joy, commenting out the break did not help, and the print statements show for my example code that these clauses are never being reached:Any hints?
pyupgradeis an awesome package, so it would be nice if it could go the full distance for the hundreds of files that need fixing in astropy.asottile commentedon Jul 5, 2019
there's a few things that aren't yet handled:
.format(...)edThe first two need some new code written for them (similar to the stuff that's happening for the py27 format strings, basically a state machine to collect all the separate
STRINGtokens that are implicit-joined). I ~eventually want something like this intokenize-rt(since there's currently code for this both here and infuture-fstringsthat does the same parsing).The second should (?) have been covered by the second part of the patch