From efbc55b85b4199681195eb5121d069a7ba8cd869 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Wed, 5 Feb 2020 14:18:31 +0000 Subject: [PATCH] TYP: remove type:ignore from pandas/io/common.py --- pandas/io/common.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index e506cc155d48d..c4772895afd1e 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -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, @@ -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. @@ -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