-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CI/TYP: run stubtest * avoid try/except * hard fail on the CI * Timedelta.__new__(unit: str|None = ...) * add *args to hashtable.*Vector.__init__
- Loading branch information
1 parent
6e1a040
commit f98696a
Showing
7 changed files
with
125 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import os | ||
from pathlib import Path | ||
import sys | ||
import tempfile | ||
import warnings | ||
|
||
from mypy import stubtest | ||
|
||
import pandas as pd | ||
|
||
# fail early if pandas is not installed | ||
if "dev" not in getattr(pd, "__version__", ""): | ||
# fail on the CI, soft fail during local development | ||
warnings.warn("You need to install the development version of pandas") | ||
if pd.compat.is_ci_environment(): | ||
sys.exit(1) | ||
else: | ||
sys.exit(0) | ||
|
||
|
||
_ALLOWLIST = [ # should be empty | ||
# TODO (child classes implement these methods) | ||
"pandas._libs.hashtable.HashTable.__contains__", | ||
"pandas._libs.hashtable.HashTable.__len__", | ||
"pandas._libs.hashtable.HashTable.factorize", | ||
"pandas._libs.hashtable.HashTable.get_item", | ||
"pandas._libs.hashtable.HashTable.get_labels", | ||
"pandas._libs.hashtable.HashTable.get_state", | ||
"pandas._libs.hashtable.HashTable.lookup", | ||
"pandas._libs.hashtable.HashTable.map_locations", | ||
"pandas._libs.hashtable.HashTable.set_item", | ||
"pandas._libs.hashtable.HashTable.sizeof", | ||
"pandas._libs.hashtable.HashTable.unique", | ||
# stubtest might be too sensitive | ||
"pandas._libs.lib.NoDefault", | ||
"pandas._libs.lib._NoDefault.no_default", | ||
# internal type alias (should probably be private) | ||
"pandas._libs.lib.ndarray_obj_2d", | ||
# workaround for mypy (cache_readonly = property) | ||
"pandas._libs.properties.cache_readonly.__get__", | ||
"pandas._libs.properties.cache_readonly.deleter", | ||
"pandas._libs.properties.cache_readonly.getter", | ||
"pandas._libs.properties.cache_readonly.setter", | ||
# TODO (child classes implement these methods) | ||
"pandas._libs.sparse.SparseIndex.__init__", | ||
"pandas._libs.sparse.SparseIndex.equals", | ||
"pandas._libs.sparse.SparseIndex.indices", | ||
"pandas._libs.sparse.SparseIndex.intersect", | ||
"pandas._libs.sparse.SparseIndex.lookup", | ||
"pandas._libs.sparse.SparseIndex.lookup_array", | ||
"pandas._libs.sparse.SparseIndex.make_union", | ||
"pandas._libs.sparse.SparseIndex.nbytes", | ||
"pandas._libs.sparse.SparseIndex.ngaps", | ||
"pandas._libs.sparse.SparseIndex.to_block_index", | ||
"pandas._libs.sparse.SparseIndex.to_int_index", | ||
# TODO (decorator changes argument names) | ||
"pandas._libs.tslibs.offsets.BaseOffset._apply_array", | ||
"pandas._libs.tslibs.offsets.BusinessHour.rollback", | ||
"pandas._libs.tslibs.offsets.BusinessHour.rollforward ", | ||
# type alias | ||
"pandas._libs.tslibs.timedeltas.UnitChoices", | ||
] | ||
|
||
if __name__ == "__main__": | ||
# find pyi files | ||
root = Path.cwd() | ||
pyi_modules = [ | ||
str(pyi.relative_to(root).with_suffix("")).replace(os.sep, ".") | ||
for pyi in root.glob("pandas/**/*.pyi") | ||
] | ||
|
||
# create allowlist | ||
with tempfile.NamedTemporaryFile(mode="w+t") as allow: | ||
allow.write("\n".join(_ALLOWLIST)) | ||
allow.flush() | ||
|
||
args = pyi_modules + [ | ||
"--ignore-missing-stub", | ||
"--concise", | ||
"--mypy-config-file", | ||
"pyproject.toml", | ||
"--allowlist", | ||
allow.name, | ||
] | ||
sys.exit(stubtest.test_stubs(stubtest.parse_options(args))) |