-
-
Notifications
You must be signed in to change notification settings - Fork 144
Fix pd.read_excel #33
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
Conversation
@hauntsaninja Can you add a test for this? See |
Sorry, was away from laptop. I can add a test, but rather than effectively recreating a large part of pandas test suite, you may wish to consider using a tool like stubtest for basic consistency checks (#11 (comment)) |
@@ -1012,6 +1016,12 @@ def test_frame_getitem_isin() -> None: | |||
assert_type(df[df.index.isin([1, 3, 5])], "pd.DataFrame") | |||
|
|||
|
|||
def test_read_excel() -> None: |
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 add a pytest.skip()
here, as this will fail with pytest
, since foo
doesn't exist.
Also add a comment referring to the Github issue, e.g. # GH 33
I've run |
Thanks, fixed! stubtest has the option of using an allowlist, which can let you introduce it in CI today, and fix the backlog of errors over time. Let me know if you need help setting it up! |
Thanks for letting me know and your offer of help. The challenge is that we don't know what to put on the allowlist. I'm hoping to fix all the issues this weekend. |
Thanks @hauntsaninja |
@hauntsaninja I tried stubtest, and can't get it to do what I'd like it to do. If I install Any suggestions on how to handle this use case would be welcome. |
Sorry for the slow reply, I'm on vacation, so only checking my laptop intermittently. @Dr-Irv stubtest requires mypy to run correctly on the stubs before it actually performs its checks. This is what it means when it says "error: not checking stubs due to mypy build errors"
So it looks to me like there are two issues with the stubs that need to be fixed before stubtest can actually run. First, mypy needs to be able to resolve the reference to matplotlib. This is easiest done by having pandas-stubs declare a dependency on a package that provides stubs for matplotlib. I'm not actually aware of such a package — has the Pylance team published their matplotlib stubs on PyPI? Second, it seems like there's some minor issue in Once these two issues are resolved, stubtest will be able to run more completely and will likely have a lot more to say. |
It's "published" on https://github.com/microsoft/python-type-stubs , but I know those stubs are incomplete. And With
We use
Would it be possible for |
Got it, in that case you can use However, I don't really recommend reusing your mypy config like this, since it won't be reflective of what your users will be doing. That is, your users won't have matplotlib stubs unless you make them a dependency, so in practice users' type checkers will resolve all of those to |
Example output, in case it's useful to you: https://paste.ee/p/KObbQ |
@hauntsaninja Does stubtest also work well when there are only very few pyi files? The pandas code itself has a few pyi files for cython code. It would be great to use stubtest to ensure that all public functions declared in pyi match the cython implementation. |
On mypy master, it should. There was a bug I fixed recently where stubtest would not check submodules that did not have corresponding pyi files. This was fixed in python/mypy#13030 (should be released soon as part of mypy 0.970). In general, if you wish to avoid errors about things that are missing from the stub and only wish to check consistency with the things that are there, stubtest supports an |
@twoertwein Looks like running stubtest against the main pandas repo finds a bunch of things, e.g. see pandas-dev/pandas#47756 , pandas-dev/pandas#47758 (there are more errors as well) |
@Dr-Irv I opened a PR to use stubtest on the pyi files within pandas pandas-dev/pandas#47817 Obviosuly, stubtest will report many errors when comparing pandas-stubs with pandas. But as @hauntsaninja pointed out, stubtest can generate an allow/ignore list. As a starting point, we could have an unfortunately enormously long ignore list to at least prevent adding new stubs that are not compatible with the implementation (or at least be aware of it and add an exception to the list). Over time we can then work on making this list smaller. I think it will never be empty but we can definitely make it smaller :) This will especially be helpful for the cleaning efforts in #149 and #128. |
Sorry for the stupid question @hauntsaninja How does stubtest need to be called on pandas or pandas-stubs:
|
After running |
Thanks, I think I forgot to install the stubs! |
No description provided.