Skip to content

ERR: Fix missing space in warning message #39159

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

Conversation

MicaelJarniac
Copy link
Contributor

@MicaelJarniac MicaelJarniac commented Jan 13, 2021

@MicaelJarniac MicaelJarniac marked this pull request as ready for review January 14, 2021 01:59
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @MicaelJarniac for the PR.

We normally check error messages in the tests so we would normally expect that changing a message would also require a change in the tests.

so it maybe that there are no tests that hit this or the message is only partially checked. so further investigation welcome.

@@ -1991,7 +1991,7 @@ def _concatenate_chunks(list chunks):
if warning_columns:
warning_names = ','.join(warning_columns)
warning_message = " ".join([
Copy link
Member

Choose a reason for hiding this comment

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

does removing the join here work instead and just use fstring literal concatenation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't see why that wouldn't work. Technically, the join wasn't even being used anyways, because the strings were getting concatenated inside of the list, so yeah, "officially" removing the join and manually adding the space between the strings sounds perfectly fine I think.
I'll poke around to see how other similar warnings are created, though, because keeping it consistent between them might be a valid reason as to whether or not to have the join.

@simonjayhawkins simonjayhawkins added the Error Reporting Incorrect or improved errors from pandas label Jan 14, 2021
@simonjayhawkins simonjayhawkins changed the title DOC: Fix missing space ERR: Fix missing space in warning message Jan 14, 2021
@MicaelJarniac
Copy link
Contributor Author

Thanks @MicaelJarniac for the PR.

We normally check error messages in the tests so we would normally expect that changing a message would also require a change in the tests.

so it maybe that there are no tests that hit this or the message is only partially checked. so further investigation welcome.

I'll try locating the tests related to this specific message (if any), and fix (or add) them.

And I'll also try to think of a way for catching similar issues in future tests, but I don't think it'd be easy, as simply saying "fail if no space after period" would catch this one, but would probably have about a thousand false-positives in other messages, because in Python syntax it's perfectly valid to have some.Thing. A test for catching issues similar to this one might end up being overkill.

@MicaelJarniac MicaelJarniac marked this pull request as draft January 14, 2021 13:14
@simonjayhawkins
Copy link
Member

so it maybe that there are no tests that hit this or the message is only partially checked. so further investigation welcome.

it appears that test_warn_if_chunks_have_mismatched_type[c_low] hits this. so can modify that test to also check message.

@simonjayhawkins simonjayhawkins added this to the 1.3 milestone Jan 14, 2021
@simonjayhawkins simonjayhawkins added Warnings Warnings that appear or should be added to pandas and removed Error Reporting Incorrect or improved errors from pandas labels Jan 14, 2021
pytest pandas/tests/io/parser/common/test_chunksize.py::test_warn_if_chunks_have_mismatched_type
@MicaelJarniac
Copy link
Contributor Author

151214 passed, 5674 skipped, 925 xfailed, 4 xpassed, 1 warning in 1126.89s (0:18:46)

@MicaelJarniac MicaelJarniac marked this pull request as ready for review February 8, 2021 21:11
if record:
assert (
str(record[0].message)
== "Columns (0) have mixed types. Specify dtype option on import or "
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The string is quite long, so it doesn't look particularly pretty in here, but I think it's okay-ish.

Copy link
Member

Choose a reason for hiding this comment

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

usually we split this into two lines

expected = "Columns (0) ..."
assert str(record[0].message) == expected

@jbrockmendel
Copy link
Member

@MicaelJarniac can you merge master and we'll try to get this in

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

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

LGTM

@MicaelJarniac MicaelJarniac marked this pull request as draft March 22, 2021 17:13
@jreback jreback modified the milestones: 1.3, No action May 26, 2021
@jreback
Copy link
Contributor

jreback commented May 26, 2021

closing as stale. @MicaelJarniac if you'd like to rebase and fix this up pls ping.

@jreback jreback closed this May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minor typo on warnings
4 participants