Skip to content

Commit cd0c38c

Browse files
TYP: pandas/core/arrays/string_.py (#31386)
1 parent 78217e0 commit cd0c38c

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

pandas/core/arrays/string_.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import operator
2-
from typing import Type
2+
from typing import TYPE_CHECKING, Type, Union
33

44
import numpy as np
55

@@ -17,6 +17,9 @@
1717
from pandas.core.construction import extract_array
1818
from pandas.core.missing import isna
1919

20+
if TYPE_CHECKING:
21+
import pyarrow # noqa: F401
22+
2023

2124
@register_extension_dtype
2225
class StringDtype(ExtensionDtype):
@@ -53,19 +56,30 @@ class StringDtype(ExtensionDtype):
5356
na_value = libmissing.NA
5457

5558
@property
56-
def type(self) -> Type:
59+
def type(self) -> Type[str]:
5760
return str
5861

5962
@classmethod
60-
def construct_array_type(cls) -> "Type[StringArray]":
63+
def construct_array_type(cls) -> Type["StringArray"]:
64+
"""
65+
Return the array type associated with this dtype.
66+
67+
Returns
68+
-------
69+
type
70+
"""
6171
return StringArray
6272

6373
def __repr__(self) -> str:
6474
return "StringDtype"
6575

66-
def __from_arrow__(self, array):
67-
"""Construct StringArray from passed pyarrow Array/ChunkedArray"""
68-
import pyarrow
76+
def __from_arrow__(
77+
self, array: Union["pyarrow.Array", "pyarrow.ChunkedArray"]
78+
) -> "StringArray":
79+
"""
80+
Construct StringArray from pyarrow Array/ChunkedArray.
81+
"""
82+
import pyarrow # noqa: F811
6983

7084
if isinstance(array, pyarrow.Array):
7185
chunks = [array]

0 commit comments

Comments
 (0)