Skip to content

ENH: Add typing tests according to the issue 45252 #45594

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

Closed
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
66e4aed
Add typing tests according to the issue 45252.
zkrolikowski-vl Jan 24, 2022
54773e5
README, isort, skip_if_no
zkrolikowski-vl Jan 25, 2022
5bedab9
Configured isort for black profile
zkrolikowski-vl Jan 25, 2022
a58cd25
Configured isort for black profile
zkrolikowski-vl Jan 26, 2022
d2b55ab
Copyright notice, tempfile
zkrolikowski-vl Jan 26, 2022
479b6bf
Remove redundant profile configuration
zkrolikowski-vl Jan 26, 2022
feb94b9
Missing matplotlib. Isort again
zkrolikowski-vl Jan 27, 2022
4d1eefd
Isort
zkrolikowski-vl Jan 27, 2022
fc35975
Add typing tests according to the issue 45252.
zkrolikowski-vl Jan 24, 2022
8d17f21
README, isort, skip_if_no
zkrolikowski-vl Jan 25, 2022
1c32250
Configured isort for black profile
zkrolikowski-vl Jan 25, 2022
47ae975
Configured isort for black profile
zkrolikowski-vl Jan 26, 2022
16d21e5
Copyright notice, tempfile
zkrolikowski-vl Jan 26, 2022
e382af0
Remove redundant profile configuration
zkrolikowski-vl Jan 26, 2022
ff2d31b
Missing matplotlib. Isort again
zkrolikowski-vl Jan 27, 2022
70902cc
Isort
zkrolikowski-vl Jan 27, 2022
0d2b8f9
Windows error for tempfile
zkrolikowski-vl Jan 28, 2022
c0cc7d2
Isort
zkrolikowski-vl Jan 28, 2022
b1e0cef
Fix
zkrolikowski-vl Jan 28, 2022
16918a1
Isort
zkrolikowski-vl Jan 28, 2022
98b13d4
Merge branch 'master' into enhancement/45252_typing_tests
zkrolikowski-vl Jan 28, 2022
bd002eb
Removed use of tempfile
zkrolikowski-vl Feb 1, 2022
6d965ee
Isort
zkrolikowski-vl Feb 1, 2022
2ab9bfd
Remove deprecated usage. Type temporary paths
zkrolikowski-vl Feb 3, 2022
4ec409f
Isort
zkrolikowski-vl Feb 3, 2022
412c1dd
Merge branch 'master' into enhancement/45252_typing_tests
zkrolikowski-vl Feb 3, 2022
8897541
Fixing CI issues
zkrolikowski-vl Feb 4, 2022
d1b134f
Fixed experimental data manager issues
zkrolikowski-vl Feb 9, 2022
b1a40ea
Merge branch 'main' into enhancement/45252_typing_tests
zkrolikowski-vl Feb 15, 2022
8f0c217
Fixed invalid values return type for series
zkrolikowski-vl Feb 18, 2022
20115ab
Merge branch 'main' into enhancement/45252_typing_tests
zkrolikowski-vl Feb 18, 2022
4c36baf
Merge branch 'main' into enhancement/45252_typing_tests
zkrolikowski-vl Feb 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSES/STUBS_LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Virtus Lab sp. z o.o. (Ltd.)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions pandas/tests/typing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Purpose of those tests

The tests contained in the `valid` directory are snippets that when
process through a type checker ensure that type annotations and type
stubs from this repository conform to common pandas API use-patterns.

## Running the tests

Tests can be run in following ways:

`pyright pandas/tests/typing`

`mypy pandas/tests/typing`

They'll also be automatically detected and executed by pytest. This
is to ensure that the test code itself is valid.

## Developing the tests

Some tests contain type checker ignore-instructions along with an
error that's supposed to be thrown.

# error: No overload variant of "to_datetime" matches argument type "DataFrame"
pd.to_datetime(df) # type: ignore[call-overload]

All such constructs are placed because of the missing/invalid API
type information. When the API signature becomes valid again type
checker will ask you to remove `type: ignore`. Please remove the
above comment as well.

When adding new tests please use the above solution as well.

## Origins and attribution

The tests come from the [pandas-stubs](https://github.com/VirtusLab/pandas-stubs)
repository originally released under the MIT license.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoyer You seem to often reply to license compatibility questions :)

Is it okay to integrate this MIT-licened code into pandas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pandas is happy to reuse MIT licensed code (e.g., see existing examples in https://github.com/pandas-dev/pandas/tree/main/LICENSES), but you absolutely need to preserve original copyright notices. The general rule (not sure if pandas is 100% strict about it, but it's a good practice) is to keep the original copyright notice as a top level comment inside each file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoyer Should I include any open source contributors, who added their code since the library was originally created, in the copyright notice?

Empty file added pandas/tests/typing/__init__.py
Empty file.
Empty file.
Loading