Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

CortlandMorse
Copy link

@jbrockmendel jbrockmendel added the Code Style Code style, linting, code_checks label Dec 17, 2019
@@ -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"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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 "
Copy link
Member

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

@WillAyd
Copy link
Member

WillAyd commented Dec 18, 2019

Thanks for the PR! CI failure is unrelated a few comments on first glance

@bashtage
Copy link
Contributor

This is going to produce a lot of conflicts with #30285

Copy link
Contributor

@bashtage bashtage left a 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.
"""


Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

agreed

Copy link
Author

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 ")
Copy link
Member

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.

Copy link
Author

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}]")
Copy link
Member

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

Copy link
Author

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}]")
Copy link
Member

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"
)
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

same above

@datapythonista
Copy link
Member

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).

@jbrockmendel
Copy link
Member

agreed with @datapythonista. Will revisit after #30285. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants