-
-
Notifications
You must be signed in to change notification settings - Fork 19k
TYP: Make mypy 0.800 compatible #39407
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,7 @@ def stringify_path( | |
return cast(FileOrBuffer[AnyStr], filepath_or_buffer) | ||
|
||
# Only @runtime_checkable protocols can be used with instance and class checks | ||
|
||
if isinstance(filepath_or_buffer, os.PathLike): # type: ignore[misc] | ||
if isinstance(filepath_or_buffer, os.PathLike): | ||
filepath_or_buffer = filepath_or_buffer.__fspath__() | ||
return _expand_user(filepath_or_buffer) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2491,9 +2491,9 @@ def write_file(self) -> None: | |
self.handles.close() | ||
# Only @runtime_checkable protocols can be used with instance and class | ||
|
||
# checks | ||
if isinstance( | ||
self._fname, (str, os.PathLike) # type: ignore[misc] | ||
) and os.path.isfile(self._fname): | ||
if isinstance(self._fname, (str, os.PathLike)) and os.path.isfile( | ||
self._fname | ||
): | ||
try: | ||
os.unlink(self._fname) | ||
except OSError: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ class BoxPlot(LinePlot): | |
|
||
_valid_return_types = (None, "axes", "dict", "both") | ||
# namedtuple to hold results | ||
BP = namedtuple("Boxplot", ["ax", "lines"]) | ||
BP = namedtuple("BP", ["ax", "lines"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OT we could use data classes here |
||
|
||
def __init__(self, data, return_type="axes", **kwargs): | ||
# Do not call LinePlot.__init__ which may fill nan | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||
from io import BytesIO, StringIO | ||||||
import os | ||||||
import platform | ||||||
from typing import Union | ||||||
from urllib.error import URLError | ||||||
|
||||||
import pytest | ||||||
|
@@ -330,8 +331,9 @@ def test_read_csv_file_handle(all_parsers, io_class, encoding): | |||||
parser = all_parsers | ||||||
expected = DataFrame({"a": [1], "b": [2]}) | ||||||
|
||||||
content = "a,b\n1,2" | ||||||
content: Union[str, bytes] = "a,b\n1,2" | ||||||
|
content: Union[str, bytes] = "a,b\n1,2" | |
content: str | bytes = "a,b\n1,2" |
😁
we have
[mypy-pandas.tests.*]
check_untyped_defs=False
so not sure why mypy is checking this function anyway.
OTOH could refactor...
content = "a,b\n1,2"
handle = io_class(content.encode("utf-8") if io_class == BytesIO else content)
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.
Hm the refactor is better. Thx.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -79,7 +79,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: | |||||||||
{dedent(doc)}""" | ||||||||||
) | ||||||||||
|
||||||||||
return wrapper | ||||||||||
return wrapper # type: ignore[return-value] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the error message as a comment to help future readers and contributors looking to help with #37715
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||
|
||||||||||
|
||||||||||
def deprecate_kwarg( | ||||||||||
|
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.
i think ok to pin >=
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.
we have been pinning to exact version up to now.
we pin to avoid ci surprises. also since we use
warn_unused_ignores = True
, mypy will only be green with the specified version.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.
Thx, pinned again