-
-
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
TYP/CI: Demonstrate possible integration of VirtusLab's type tests #45561
Conversation
Hello @twoertwein! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-01-23 18:06:54 UTC |
Thanks @twoertwein it may be worth getting the typing check to green for the POC. (pep less important) what's the proposal for dealing with "reportUnusedVariable". would we just disable that check on the test files? |
df[["col1", "col2"]] = [[1, 2], [3, 4]] | ||
df[s] = [5, 6] | ||
df[a] = [[1, 2], [3, 4]] | ||
df[select_df] = [1, 2, 3] |
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.
This does not work: ValueError: cannot assign mismatch length to masked array
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.
Yup. Investigating this as a possible regression from pandas version 1.3.2
.
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.
Type tests finding non-typing bugs :) If this worked in previous versions, feel free to open an issue!
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 not first time that this happened. See #40440 originally spotted by @joannasendorek.
I've opened up an issue: #45593. I'll circumvent this for now in my PR which is pending.
I now limit pyright to the same config as we use everywhere else, but I enable its general type error checking (the most important option). edit: |
@simonjayhawkins Type checks pass now (except one issue existing on main) and the CI is otherwise mostly green (except the one test mentioned above). |
|
||
rdf4: pd.DataFrame = pd.concat(list(map(lambda x: s2, ["some_value", 3])), axis=1) | ||
|
||
|
||
def test_types_json_normalize() -> None: | ||
data1: List[Dict[str, Any]] = [ | ||
{"id": 1, "name": {"first": "Coleen", "last": "Volk"}}, | ||
{"name": {"given": "Mose", "family": "Regner"}}, | ||
{"name": {"given": "More", "family": "Regner"}}, |
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.
to make codespell happy
@twoertwein So as more stubs are added we'll keep removing the Let me look at the the invalid test case, and then I'll open a PR of my own based on this one - based on your preference. I agree that it's probably realistically more straight-forward in terms of the copyright/license. |
I think that is the idea. Ideally, we want to achieve that with inline annotations (and pyi for cython/c). Knowing where we need ignores also helps us to prioritize annotating code.
Great! You could also create a PR where multiple people from the VirtusLab are involved, in case attribution is important. You are welcome to either copy&past my follow-up commit or apply it as a patch, which ever you prefer. |
@twoertwein Thanks for doing this. It seems that this would use the code from Virtus Labs to check our existing type stubs within the pandas code. Then when we brought over the |
Yes, this simply copies the test snippets from Virtus Labs (but not their pyi files). This PR tries to address only #45252 and not #45253.
I'm sorry, I don't understand what you mean. Merging some of the Microsoft pyi files for cython files (e.g., offesets.pyi #45331 and interval.pyi #44922) might help reduce the number of ignores. |
I was referring to #45253 . Following up on the discussion we had at the January developer meeting, @simonjayhawkins brought up that our current typing tests are meant to test the types of our internals, while if we create |
If we have two sets of type annotations (more complete public pyi files and the in-progress inline annotations), it would be great to test both! If pyi files take precedence over inline (I'm not sure about that), your idea should be easily possible (run mypy&pyright twice, but for the second time delete some of the pyi files). |
Yes, I agree with that.
From what I understand the |
One option could be to add only as many external pyi files to satisfy the public tests. I think type checkers don't mind a mix of pyi and inline (a.pyi but b.py has inline). Over time, we could then try to completely remove the external pyi files. |
Closing this PR in favor of #45594. |
Demonstrate the integration of positive type tests from https://github.com/VirtusLab/pandas-stubs for the public API (tests import
some private modules?).
This PR should NOT be merged and this PR probably violates licenses/copyrights. It is probably best if a member of the VirtusLab re-creates this PR. This PR is intended only to demonstrate how the snippets from VirtusLab could be integrated.
The typing errors would need to be ignored (and if pyright needs further ignores,
# pyright: <rulename> = false
at the top of a file). Pyright checks could also be skipped for now. There might be better ways to exclude/include files with pyright.xref #45252