-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: Rename CParserError to ParserError #14479
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
API: Rename CParserError to ParserError #14479
Conversation
cb53574
to
19f626a
Compare
Current coverage is 85.29% (diff: 66.66%)@@ master #14479 diff @@
==========================================
Files 140 140
Lines 50706 50709 +3
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43247 43250 +3
Misses 7459 7459
Partials 0 0
|
I think we should keep the old name as an alias (or at least deprecate it) |
agreed this needs a deprecation. |
19f626a
to
7d3ddd3
Compare
07ef63d
to
c7d00f1
Compare
can you also run the tests and be sure that we are not generating this in the full test run (I mean the deprecation warning). |
@jreback : I can run them locally again, but I'm pretty sure the answer is no. 😄 |
I would maybe go for a DeprecationWarning here in this case instead of FutureWarning, as this will be typically not used in interactive user code, but rather in library code (other option is to just keep it as alias) |
@jorisvandenbossche : I'd rather deprecate since we would like to rename, though I don't quite see the necessity in making this one issue a @jreback : Ran the tests locally and got no warnings about |
c7d00f1
to
ed1fa3e
Compare
We did already rename it, my question was just whether to deprecate the old name or keep it as an alias, irregardless of the rename
This will typically be used in library code. People using such a library will see the FutureWarning, but cannot do anything about it (the warning will only go away once the library was updated), which is annoying. With a deprecation warning you only see it on direct use. |
I fail to comprehend what you mean by that. |
8cbafe4
to
3d2619e
Compare
Putting |
3d2619e
to
0f4e4aa
Compare
@jreback , @jorisvandenbossche : Travis is now happy again. Ready to merge if there is nothing else. |
By default, a DeprecationWarning is not visible, a FutureWarning is. Therefore, we mostly use FutureWarnings for deprecations in pandas, as most things (eg changing keyword) are things all users need to be aware of. However, in this case most users will not directly use CParserError, but rather use a third party library that uses it (this is an assumption of me, not sure if this is correct). In such a case, a DeprecationWarning can be friendlier to users, as they otherwise see FutureWarnings about CParserError being deprecated that they have no control over, as it is used in the library they used. For that reason, we also used DeprecationWarning for the |
Can you also add a test for the deprecated CParserError ? |
0f4e4aa
to
1f5e769
Compare
@jorisvandenbossche : Ah, okay. Done. Let's see what Travis has to say now. |
1f5e769
to
542f398
Compare
@jorisvandenbossche , @jreback : I changed the warning to be |
with tm.assert_produces_warning(DeprecationWarning, | ||
check_stacklevel=False): | ||
with tm.assertRaises(common.ParserError): | ||
raise common.CParserError() |
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.
A common usage will also be:
from pandas.io.common import CParserError
try:
....
except CParserError:
....
but I don't think this will currently warn for such use cases?
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.
And some usages I found seem to also import this from pandas.parser
, so maybe we should keep it there as well (so not only in io.common
).
https://github.com/glue-viz/glue/blob/e9742059112d00e562fc3123703678d66fad1996/glue/core/data_factories/pandas.py#L60
https://github.com/sawadyrr5/pyjsf/blob/cf1e8643afb65912237483eac5a2735df5a8a8a6/pyjsf/data/download.py
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.
@jorisvandenbossche: Actually, I get an error if you do that:
try:
...
except CParserError:
...
TypeError: catching classes that do not inherit from BaseException is not allowed
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.
That's probably because of the decorator usage? (as it works for master)
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.
- Yes, it is because of the decorator usage. So at least that prevents
try-except
. - Well I would sure hope it works on
master
!
Getting some weird segfaults that seem unrelated to this PR (also in my other one)...disabling testing for the time being. |
d83c8df
to
8d7f1b5
Compare
@jorisvandenbossche , @jreback : No more segfaulting, and everything looks green. Ready to merge if there are no concerns. |
I would first like to get agreement on the status of CParserError: do we regard it as an alias (which means for me keeping it), or as deprecated and with the intention to remove it? I asked SO if it possible to deprecate an Exception (http://stackoverflow.com/questions/40545005/is-it-possible-to-deprecate-an-exception-class/40546615#40546615), but there did not really appear a nice solution |
3b7bee6
to
41cc041
Compare
@jorisvandenbossche : The intention is to remove |
from io.common import CParserError, DtypeWarning, EmptyDataError | ||
# XXX: It's annoying that we have to import both CParserError | ||
# and ParserError. Unfortunately, backwards compatibility is | ||
# the higher calling right now. |
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.
Can you keep this a bit more 'dry' and simply say "import CParserError as alias of ParserError for backward compatibility"
you can maybe also put the one import of CParserError on a separate line to make this more clear
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.
Sounds good. Done.
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.
Can you also add a test for the alias? (you had one before I think)
@@ -41,6 +41,7 @@ Backwards incompatible API changes | |||
.. _whatsnew_0200.api: | |||
|
|||
|
|||
- ``CParserError`` has been aliased to ``ParserError`` in ``pd.read_csv`` and will be removed in the future (:issue:`12665`) |
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.
Maybe say "renamed to" ? For me that sounds stronger that I have to change my code if I use it
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.
Sounds good. Done.
Partially resolves pandas-devgh-12665. We will remove CParserError in the future.
41cc041
to
912668e
Compare
@jorisvandenbossche : Added a slightly different alias test, but yes, done. |
@gfyoung Thanks! (just added the same test for pd.parser.CParserError) |
Title is self-explanatory. Partially resolves #12665.