Skip to content

TYP: annotation of __init__ return type (PEP 484) (misc modules) #46280

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 3 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
single_doc=None,
verbosity=0,
warnings_are_errors=False,
):
) -> None:
self.num_jobs = num_jobs
self.include_api = include_api
self.whatsnew = whatsnew
Expand Down
6 changes: 3 additions & 3 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_default_val(pat: str):
class DictWrapper:
"""provide attribute-style access to a nested dict"""

def __init__(self, d: dict[str, Any], prefix: str = ""):
def __init__(self, d: dict[str, Any], prefix: str = "") -> None:
object.__setattr__(self, "d", d)
object.__setattr__(self, "prefix", prefix)

Expand Down Expand Up @@ -248,7 +248,7 @@ def __dir__(self) -> Iterable[str]:


class CallableDynamicDoc:
def __init__(self, func, doc_tmpl):
def __init__(self, func, doc_tmpl) -> None:
self.__doc_tmpl__ = doc_tmpl
self.__func__ = func

Expand Down Expand Up @@ -422,7 +422,7 @@ class option_context(ContextDecorator):
... pass
"""

def __init__(self, *args):
def __init__(self, *args) -> None:
if len(args) % 2 != 0 or len(args) < 2:
raise ValueError(
"Need to invoke as option_context(pat, val, [(pat, val), ...])."
Expand Down
2 changes: 1 addition & 1 deletion pandas/_testing/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class RNGContext:
np.random.randn()
"""

def __init__(self, seed):
def __init__(self, seed) -> None:
self.seed = seed

def __enter__(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
fname=None,
method: str | None = None,
max_fname_arg_count=None,
):
) -> None:
self.fname = fname
self.method = method
self.defaults = defaults
Expand Down
6 changes: 3 additions & 3 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def dict_subclass():
"""

class TestSubDict(dict):
def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
dict.__init__(self, *args, **kwargs)

return TestSubDict
Expand All @@ -460,7 +460,7 @@ def non_dict_mapping_subclass():
"""

class TestNonDictMapping(abc.Mapping):
def __init__(self, underlying_dict):
def __init__(self, underlying_dict) -> None:
self._data = underlying_dict

def __getitem__(self, key):
Expand Down Expand Up @@ -1709,7 +1709,7 @@ class TestMemoryFS(MemoryFileSystem):
protocol = "testmem"
test = [None]

def __init__(self, **kwargs):
def __init__(self, **kwargs) -> None:
self.test[0] = kwargs.pop("test", None)
super().__init__(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class AbstractMethodError(NotImplementedError):
while keeping compatibility with Python 2 and Python 3.
"""

def __init__(self, class_instance, methodtype="method"):
def __init__(self, class_instance, methodtype="method") -> None:
types = {"method", "classmethod", "staticmethod", "property"}
if methodtype not in types:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class _FrequencyInferer:
Not sure if I can avoid the state machine here
"""

def __init__(self, index, warn: bool = True):
def __init__(self, index, warn: bool = True) -> None:
self.index = index
self.i8values = index.asi8

Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __init__(
start_date=None,
end_date=None,
days_of_week=None,
):
) -> None:
"""
Parameters
----------
Expand Down Expand Up @@ -393,7 +393,7 @@ class AbstractHolidayCalendar(metaclass=HolidayCalendarMetaClass):
end_date = Timestamp(datetime(2200, 12, 31))
_cache = None

def __init__(self, name=None, rules=None):
def __init__(self, name=None, rules=None) -> None:
"""
Initializes holiday object with a given set a rules. Normally
classes just have the rules defined within them.
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def get_api_items(api_doc_fd):


class PandasDocstring(Validator):
def __init__(self, func_name: str, doc_obj=None):
def __init__(self, func_name: str, doc_obj=None) -> None:
self.func_name = func_name
if doc_obj is None:
doc_obj = get_doc_object(Validator._load_obj(func_name))
Expand Down