-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
STYLE: Specify bare exceptions in pandas/tests #23370
Conversation
Hello @alexander-ponomaroff! Thanks for updating the PR.
Comment last updated on November 13, 2018 at 04:43 Hours UTC |
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.
lgtm, thanks!
I think this is the last chunk of bare exceptions. Can you run |
When running: flake8 --select=E722 --config=none pandas/tests/ When running: flake8 --select=E722 --config=none Should I fix those also? |
Yes, that would be great. This will finish all them and we can avoid new bare excepts using the CI from now on with the changes I mentioned. |
@datapythonista I had some trouble with pandas/tests/indexing/common.py - line 217. Could not figure out which exceptions needed to go there. My previous commit looks like passed the first CI, so it's looking promising, although I have 4 different exceptions on line 217. I put the final exceptions in doc/source and removed E722 from the ignore lists. Hopefully it passes all the CI tests. If you have some advice about line 217 of pandas/tests/indexing/common.py, it would be much appreciated. That's the only one that gave me some trouble and I don't think all 4 of those exceptions are correct. I couldn't get pytest to run, so had to wait for CI to perform testing. |
Can you remove I don't have access to a computer at the moment, @jreback, can you check if the exceptions in |
@datapythonista Weird, I removed it from https://travis-ci.org/pandas-dev/pandas/jobs/447018587 I am unsure why I fail this check, it doesn't show any errors except this: Also, it looks like that line 217 of common.py is still not working properly as it fails one of the tests of Travis CI, so I will put Other than these two tests, everything else passes. |
can you rebase |
@alexander-ponomaroff the error in travis looks like a genuine error introduced in your changes, I think pymysql needs to be imported. Can you take a look and leave the CI green so we can merge. Thanks! |
@alexander-ponomaroff do you have time to fix the CI problem? |
Yes, I will work on this tonight. I was away from a computer on Friday and Saturday.
… On Nov 4, 2018, at 12:21 PM, Marc Garcia ***@***.***> wrote:
@alexander-ponomaroff do you have time to fix the CI problem?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@datapythonista My checks passed after updated pymysql. I had to resolve a merge conflict after, so hopefully nothing messes up and the checks pass again. |
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 rebase and fix the conflicts please? Thanks!
I think the linting |
pandas/conftest.py
Outdated
import numpy as np | ||
import pytest | ||
|
||
from pandas.compat import PY3 | ||
import pandas.util._test_decorators as td | ||
|
||
import hypothesis | ||
from hypothesis import strategies as st |
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.
Not very important, but I don't understand this change. The standard is to import Python stdlib first, third-party packages (like hypothesis) later, and the project code (pandas) last.
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.
isort did that, I ran it on the whole repository
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.
So whenever somebody else runs it and since pandas/conftest.py is not in setup.cfg, they should get this change also with isort. Unless something went wrong.
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 weird. Not so important as I said, but if you have time, I'd remove this file from the PR, as nothing really changed here more than the isort changes, which are unrelated. Or if you want to keep, may be we should remove this file from the excludes of isort (assuming it's there).
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.
@alimcmaster1 can you take a look here? May be I'm missing something?
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 the CI agrees with me:
ERROR: /home/travis/build/pandas-dev/pandas/pandas/conftest.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/tests/io/test_sql.py Imports are incorrectly sorted.
It's probably a bug in isort
when sorting the files, validation seems right.
Can you fix, so the CI is green and we can merge?
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.
Thanks @datapythonista will take a look at what is going on with isort and that file this evening.
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 reverted everything that isort did and added test_sql.py back to setup.cfg. I tried running isort a few times, but it just sorts everything the way it sorted the first time.
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.
Running isort conftest.py
ran OK for me on master. It should already be sorted fine as its not in the setup.cfg. What version of isort are you using? Im running 4.3.4
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.
@alimcmaster1 My version is 4.3.4 as well.
Codecov Report
@@ Coverage Diff @@
## master #23370 +/- ##
=======================================
Coverage 92.25% 92.25%
=======================================
Files 161 161
Lines 51237 51237
=======================================
Hits 47269 47269
Misses 3968 3968
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #23370 +/- ##
=========================================
Coverage ? 92.24%
=========================================
Files ? 161
Lines ? 51433
Branches ? 0
=========================================
Hits ? 47446
Misses ? 3987
Partials ? 0
Continue to review full report at Codecov.
|
lgtm, let's see if it finishes on green |
looks like still a linting error:
|
@datapythonista does this fully close #22872 . ? |
Yes, this is actually the last chunk of bare except fixes. We remove the ignore of the flake8 error here, so we start validating that no more are added in this PR. |
@datapythonista All checks pass 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.
LGTM - CC @datapythonista and @jreback to merge
Looks great. Thanks for the fixes @alexander-ponomaroff @jreback, can you take a look and merge if you're happy? |
lgtm. just merged master to be sure. let's merge on green. |
rebased. can merge on green. |
thanks @alexander-ponomaroff |
@jreback @datapythonista No problem guys :) |
…fixed * upstream/master: (46 commits) DEPS: bump xlrd min version to 1.0.0 (pandas-dev#23774) BUG: Don't warn if default conflicts with dialect (pandas-dev#23775) BUG: Fixing memory leaks in read_csv (pandas-dev#23072) TST: Extend datetime64 arith tests to array classes, fix several broken cases (pandas-dev#23771) STYLE: Specify bare exceptions in pandas/tests (pandas-dev#23370) ENH: between_time, at_time accept axis parameter (pandas-dev#21799) PERF: Use is_utc check to improve performance of dateutil UTC in DatetimeIndex methods (pandas-dev#23772) CLN: io/formats/html.py: refactor (pandas-dev#22726) API: Make Categorical.searchsorted returns a scalar when supplied a scalar (pandas-dev#23466) TST: Add test case for GH14080 for overflow exception (pandas-dev#23762) BUG: Don't extract header names if none specified (pandas-dev#23703) BUG: Index.str.partition not nan-safe (pandas-dev#23558) (pandas-dev#23618) DEPR: tz_convert in the Timestamp constructor (pandas-dev#23621) PERF: Datetime/Timestamp.normalize for timezone naive datetimes (pandas-dev#23634) TST: Use new arithmetic fixtures, parametrize many more tests (pandas-dev#23757) REF/TST: Add more pytest idiom to parsers tests (pandas-dev#23761) DOC: Add ignore-deprecate argument to validate_docstrings.py (pandas-dev#23650) ENH: update pandas-gbq to 0.8.0, adds credentials arg (pandas-dev#23662) DOC: Improve error message to show correct order (pandas-dev#23652) ENH: Improve error message for empty object array (pandas-dev#23718) ...
git diff upstream/master -u -- "*.py" | flake8 --diff
The empty
except
statements now capture specific exceptions.Following warnings are fixed: