-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix mypy errors in testcommon py #29179
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
Changes from 2 commits
b34fc3b
a266c69
4d27ef2
c208bbe
0e556c2
2cfc88f
7b8c744
5fbbe9e
5506b82
ad01c8b
2d2f220
009ffc4
3940401
b106ef3
429ed6e
ac4469c
1939942
6ce48d9
b036967
ac45185
6c93ef1
a8cbd11
1f20f63
d5f430a
78d3420
0f93b07
1846dc6
1f49aa8
08d66f3
140102b
c8dd72a
3c80277
1e12510
06ba9f5
4892735
f992870
c4f0b5c
4feb8ac
cf22fcb
217358f
46af140
bd64ab7
d63cfa2
d9750c1
3df6488
d449b73
19f76cd
4ff76bd
f9020a2
49bb2e1
2833cb4
219d18c
c594594
1707f2a
4dc532f
a0446b0
38b923a
5ce7b1a
052a64a
41933cc
22a8337
586a9e7
1e9a047
3fbb0bc
cc93fdc
1979625
dd5d1c5
091bb06
6983800
9a98680
0aa913e
b634636
4879491
bec7043
eda17f9
c56d68a
051e152
fbe52f8
96833c3
cfd0bb3
8d9005d
cb4130b
5ea715e
a05829b
4abe6d8
4d519f9
08cf353
f2c42dc
946781d
291afc3
a23a589
8f9769c
adfd4de
58aa92b
53cc892
846bf91
0d69e54
c1f19f2
c006074
6758c4d
8c143b6
9708036
84fe5d0
e92a6eb
ca180a6
d21b9b2
0dc0cc5
05f3b16
8d21fe0
a3eea24
d01d5bb
3f37553
3ba0b50
1fe031d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,11 +324,13 @@ def test_is_datetimelike(): | |
|
||
@pytest.mark.parametrize( | ||
"dtype", | ||
[pd.Series([1, 2])] | ||
+ ALL_INT_DTYPES | ||
+ to_numpy_dtypes(ALL_INT_DTYPES) | ||
+ ALL_EA_INT_DTYPES | ||
+ to_ea_dtypes(ALL_EA_INT_DTYPES), | ||
[ | ||
type(pd.Series([1, 2])), | ||
*ALL_INT_DTYPES, | ||
*to_numpy_dtypes(ALL_INT_DTYPES), | ||
*ALL_EA_INT_DTYPES, | ||
*to_ea_dtypes(ALL_EA_INT_DTYPES), | ||
], | ||
) | ||
def test_is_integer_dtype(dtype): | ||
assert com.is_integer_dtype(dtype) | ||
|
@@ -352,11 +354,13 @@ def test_is_not_integer_dtype(dtype): | |
|
||
@pytest.mark.parametrize( | ||
"dtype", | ||
[pd.Series([1, 2])] | ||
+ SIGNED_INT_DTYPES | ||
+ to_numpy_dtypes(SIGNED_INT_DTYPES) | ||
+ SIGNED_EA_INT_DTYPES | ||
+ to_ea_dtypes(SIGNED_EA_INT_DTYPES), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is mypy's complaint about this? I think the current idiom is more beginner-friendly than the args-expansion idiom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC the issue is that you can't really do list addition and have it type inference appropriately all in one pass, at least not from a static analysis perspective Instead of doing this could you also just initialize this a line up with the appropriate type comment and just pass that variable into the parametrization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd Just so I understand exactly what you're suggesting, are you talking about initializing the list of dtypes originially constructed by list addition through unpacking them into a list outside of the parametrizations, giving that list a type stub (presumably List[Dtype]), and then passing it into the paramaterization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No unpacking just defined this as a variable on the line above. signed_int_dtypes = [] # type: List[Union[pd.Series, Dtype]] And then just use that as the argument here. Side note - I'm assuming the type above works but can't remember what the mypy complaint was and what it should be just glancing at it. Might need to tweak depending on what you see |
||
[ | ||
type(pd.Series([1, 2])), | ||
*SIGNED_INT_DTYPES, | ||
*to_numpy_dtypes(SIGNED_INT_DTYPES), | ||
*SIGNED_EA_INT_DTYPES, | ||
*to_ea_dtypes(SIGNED_EA_INT_DTYPES), | ||
], | ||
) | ||
def test_is_signed_integer_dtype(dtype): | ||
assert com.is_integer_dtype(dtype) | ||
|
@@ -384,11 +388,13 @@ def test_is_not_signed_integer_dtype(dtype): | |
|
||
@pytest.mark.parametrize( | ||
"dtype", | ||
[pd.Series([1, 2], dtype=np.uint32)] | ||
+ UNSIGNED_INT_DTYPES | ||
+ to_numpy_dtypes(UNSIGNED_INT_DTYPES) | ||
+ UNSIGNED_EA_INT_DTYPES | ||
+ to_ea_dtypes(UNSIGNED_EA_INT_DTYPES), | ||
[ | ||
type(pd.Series([1, 2], dtype=np.uint32)), | ||
*UNSIGNED_INT_DTYPES, | ||
*to_numpy_dtypes(UNSIGNED_INT_DTYPES), | ||
*UNSIGNED_EA_INT_DTYPES, | ||
*to_ea_dtypes(UNSIGNED_EA_INT_DTYPES), | ||
], | ||
) | ||
def test_is_unsigned_integer_dtype(dtype): | ||
assert com.is_unsigned_integer_dtype(dtype) | ||
|
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.
Is this change to
type
intentional?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. If I understand the list correctly then a Series is a data type that should be accounted for in these tests, right?
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 can see where the naming is confusing but you should keep that the same -
is_integer_dtype
works on types and arraysThere 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.
Alright, I reverted that change.