Skip to content

TYP: _config/config.py && core/{apply,construction}.py #30734

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 12 commits into from
Jan 16, 2020
12 changes: 6 additions & 6 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ def register_option(
key: str,
defval: object,
doc: str = "",
validator: Optional[Callable] = None,
cb: Optional[Callable] = None,
validator=None,
cb: Optional[Callable[[str], None]] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to validator, restricting the return type to None may not be desirable.

) -> None:
"""
Register an option in the package-wide pandas config object
Expand Down Expand Up @@ -734,7 +734,7 @@ def config_prefix(prefix):
global register_option, get_option, set_option, reset_option

def wrap(func):
def inner(key: str, *args, **kwds) -> Callable:
def inner(key: str, *args, **kwds) -> Callable[[str, Any, Any], Any]:
pkey = f"{prefix}.{key}"
return func(pkey, *args, **kwds)

Expand All @@ -756,7 +756,7 @@ def inner(key: str, *args, **kwds) -> Callable:
# arg in register_option


def is_type_factory(_type) -> Callable:
def is_type_factory(_type) -> Callable[..., None]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the returned function accepts exactly one argument

Suggested change
def is_type_factory(_type) -> Callable[..., None]:
def is_type_factory(_type: Type[Any]) -> Callable[[Any], None]:

"""

Parameters
Expand All @@ -777,7 +777,7 @@ def inner(x) -> None:
return inner


def is_instance_factory(_type) -> Callable:
def is_instance_factory(_type) -> Callable[..., None]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the returned function accepts exactly one argument

Suggested change
def is_instance_factory(_type) -> Callable[..., None]:
def is_instance_factory(_type) -> Callable[[Any], None]:

"""

Parameters
Expand All @@ -804,7 +804,7 @@ def inner(x) -> None:
return inner


def is_one_of_factory(legal_values) -> Callable:
def is_one_of_factory(legal_values) -> Callable[..., None]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def is_one_of_factory(legal_values) -> Callable[..., None]:
def is_one_of_factory(legal_values) -> Callable[[Any] None]:


callables = [c for c in legal_values if callable(c)]
legal_values = [c for c in legal_values if not callable(c)]
Expand Down