-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: Update typing for 3.10 #61453
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: Update typing for 3.10 #61453
Conversation
@@ -140,7 +140,7 @@ repos: | |||
pass_filenames: false | |||
types: [python] | |||
stages: [manual] | |||
- id: mypy | |||
- id: stubtest |
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.
docs indicated you could just say stubtest
, but that didn't work without this change. Now you can run mypy
and stubtest
separately as part of type checking
@@ -563,7 +563,6 @@ def set_nulls( | |||
if null_kind == ColumnNullType.USE_SENTINEL: | |||
null_pos = pd.Series(data) == sentinel_val | |||
elif null_kind in (ColumnNullType.USE_BITMASK, ColumnNullType.USE_BYTEMASK): | |||
assert validity, "Expected to have a validity buffer for the mask" |
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.
validity
cannot be None
because of the test in line 558
with tempfile.TemporaryDirectory() as td: | ||
allow = os.path.join(td, "test") | ||
with open(allow, "w+t") as allow: | ||
allow.write("\n".join(_ALLOWLIST)) | ||
allow.flush() |
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.
On Windows, creating a temporary file and leaving it open means it can't be opened by another function. The above solves that problem.
Thanks @Dr-Irv |
pyupgrade
so that typing is updated to python 3.10 - that modified files inpandas/_libs
pandas/_typing.py
to have the following:TypeAlias
to declare all typesType
to usebuiltins.type
Optional
Union
except for when it is used on a pandas typeAlso fixed some other typing issues as well as an issue with running
stubtest
locally.