-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
ENH: Bring over Microsoft typing stubs as starting point for typing public API #45253
Comments
As discussed on the meeting, we have conducted tests of
is identified as wrong with:
In There are also some errors connected to missing valid overload variant of stubs, such as:
Some other example of proper call not being covered:
I attach the full testing report. |
@joannasendorek Thanks for doing these tests. Some comments:
def test_sort_values():
s = pd.Series([4, 2, 1, 3])
res: pd.Series = s.sort_values(0) which failed in the tests with
That would be a big change to pandas. As best as I can tell, the way that Can you see what the test results are if you use |
Sorry just trying to follow along as an observer, but regarding the generic question:
AFAICT the regular ndarray class is, in fact declared as generic in latest numpy’s stubs? |
Yes, you are right. I was looking at |
@joannasendorek Can you indicate from your tests which I'm wondering if we should do your tests that you did with your tests and the MS type stubs, but using the options for |
@Dr-Irv sure, sorry for late reply. I used the exact configuration from pandas-stubs repo, you might check it here: https://github.com/VirtusLab/pandas-stubs/blob/master/mypy.ini - used for checking the stubs themselves and https://github.com/VirtusLab/pandas-stubs/blob/master/mypy_env.ini - used for checking snippets using MS stubs. |
@joannasendorek The first two classes of errors you mentioned (partial annotations and generic classes without a concrete specifier) are both suppressed in pandas's mypy config (
Probably needs to be done file by file as 1) there might be many conflicts (see for example #43744: Microsoft stubs for _libs) or 2) some of the 3rd party stubs are very partial (for example offsets.pyi and interval.pyi in VirtusLab's stubs). |
Can you try the MS stubs with the settings we use in the pandas project (found in |
I attach the results of running described above mypy tests with the pandas settings. As a quick summary number of errors dropped from 160 to 119. |
Thanks @joannasendorek ! I think the question now is whether we get these cleaned up as part of moving the stubs over from Microsoft to pandas, OR we get them cleaned up as part of the Microsoft project, and then move them over. I created an issue over there microsoft/python-type-stubs#125 to see what they have to say. |
It looks like I should just be able to open these tests in VS Code with Pylance and see any issues. I am doing that and I don't see the very first issue, but I'm also using latest stubs from the repo and it looks like you have made some changes, Irv. So I will look at the things that are still being squiggled. Of course, that means I am assuming that these test snippets should be clean and free of warnings; is that a correct assumption? |
Have created the https://github.com/pandas-dev/pandas-stubs project from MS stubs. |
From discussion on pandas typing meeting on January 7, 2022 (notes at https://docs.google.com/document/d/1tGbTiYORHiSPgVMXawiweGJlBw5dOkVJLY-licoBmBU/)
Follow up to discussion here: #28142 (comment)
Goal is to copy over the pandas stubs created by Microsoft that are shipped with Visual Studio Code:
https://github.com/microsoft/python-type-stubs/tree/main/pandas
Unclear whether this should be done a file at a time, or all at once. Need to resolve conflicts between the pandas source and those stubs. Possible to publish partial stubs by indicating they are partial within a
py.typed
file.@gramster (main author of the Microsoft stubs)may be willing to help (nudge, nudge)
Ideally, the testing framework for the stubs should be created first. See #45252
The text was updated successfully, but these errors were encountered: