Skip to content

TYP: remove type:ignore from pandas/io/common.py #31700

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

Merged
Merged
Changes from all commits
Commits
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: 19 additions & 2 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
import mmap
import os
import pathlib
from typing import IO, Any, AnyStr, Dict, List, Mapping, Optional, Tuple, Union
from typing import (
IO,
TYPE_CHECKING,
Any,
AnyStr,
Dict,
List,
Mapping,
Optional,
Tuple,
Type,
Union,
)
from urllib.parse import ( # noqa
urlencode,
urljoin,
Expand Down Expand Up @@ -37,6 +49,10 @@
_VALID_URLS.discard("")


if TYPE_CHECKING:
from io import IOBase # noqa: F401


def is_url(url) -> bool:
"""
Check to see if a URL has a valid protocol.
Expand Down Expand Up @@ -356,12 +372,13 @@ def get_handle(
handles : list of file-like objects
A list of file-like object that were opened in this function.
"""
need_text_wrapping: Tuple[Type["IOBase"], ...]
try:
from s3fs import S3File

need_text_wrapping = (BufferedIOBase, RawIOBase, S3File)
except ImportError:
need_text_wrapping = (BufferedIOBase, RawIOBase) # type: ignore
need_text_wrapping = (BufferedIOBase, RawIOBase)

handles: List[IO] = list()
f = path_or_buf
Expand Down