-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fixings fstrings in pandas/io/stata.py & pandas/io/sql.py #30310
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
Conversation
@@ -1599,14 +1588,11 @@ def execute(self, *args, **kwargs): | |||
self.con.rollback() | |||
except Exception as inner_exc: # pragma: no cover | |||
ex = DatabaseError( | |||
"Execution failed on sql: {sql}\n{exc}\nunable " | |||
"to rollback".format(sql=args[0], exc=exc) | |||
f"Execution failed on sql: {args[0]}\n{exc}\nunable " "to rollback" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"Execution failed on sql: {args[0]}\n{exc}\nunable " "to rollback" | |
f"Execution failed on sql: {args[0]}\n{exc}\nunable to rollback" |
"Stata ({float64_max})".format( | ||
col=col, val=value, float64_max=float64_max | ||
) | ||
f"Column {col} has a maximum value " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of this might conflict with #30285
Thanks for the PR! CI failure is unrelated a few comments on first glance |
This is going to produce a lot of conflicts with #30285 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of the changes are not improvements.
Stata data file created has not lost information due to duplicate labels. | ||
""" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of moving this very long warning to be inline just to make it an f-string. f-strings should not be dogmatically used when they produce worse code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, I'll change it in my next commit
"The type of {column} is not a " | ||
"SQLAlchemy type ".format(column=col) | ||
) | ||
raise ValueError(f"The type of {col} is not a " "SQLAlchemy type ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there is an extra space after "type", and black formatting split this into two strings that should be manually re-joined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll join it in my next commit, thanks for the feedback
) | ||
) | ||
errjoin = ", ".join(str(x) for x in typlist) | ||
raise ValueError("cannot convert stata types " f"[{errjoin}]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to un-split string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, thanks Ill fix it
) | ||
) | ||
errjoin = ", ".join(str(x) for x in typlist) | ||
raise ValueError("cannot convert stata dtypes " f"[{errjoin}]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to unsplit string
"`StataReader` to separately read the values and the" | ||
"\nvalue_labels.\n\nThe repeated labels are:\n" | ||
f"{repeats}\n" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these newlines can be removed. Only keep the ones that separate paragraphs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above
While the changes here look cool, I think we should close this PR, and leave the changes here to #30285 (and a follow up of if needed). |
agreed with @datapythonista. Will revisit after #30285. Closing. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff