8000 TYP: Make temporary variables in pandas/__init__.py private by twoertwein · Pull Request #46698 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TYP: Make temporary variables in pandas/__init__.py private #46698

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 5 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
TYP: type/privatize public symbols
  • Loading branch information
twoertwein committed Apr 15, 2022
commit 26fad1b70cbda40da4ae59787cc0640c0646719d
26 changes: 13 additions & 13 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
__docformat__ = "restructuredtext"

# Let users know if they're missing any of our hard dependencies
hard_dependencies = ("numpy", "pytz", "dateutil")
missing_dependencies = []
_hard_dependencies = ("numpy", "pytz", "dateutil")
_missing_dependencies = []

for dependency in hard_dependencies:
for _dependency in _hard_dependencies:
try:
__import__(dependency)
except ImportError as e:
missing_dependencies.append(f"{dependency}: {e}")
__import__(_dependency)
except ImportError as _e:
_missing_dependencies.append(f"{_dependency}: {_e}")

if missing_dependencies:
if _missing_dependencies:
raise ImportError(
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
"Unable to import required dependencies:\n" + "\n".join(_missing_dependencies)
)
del hard_dependencies, dependency, missing_dependencies
del _hard_dependencies, _dependency, _missing_dependencies

# numpy compat
from pandas.compat import is_numpy_dev as _is_numpy_dev

try:
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
except ImportError as err: # pragma: no cover
module = err.name
except ImportError as _err: # pragma: no cover
_module = _err.name
raise ImportError(
f"C extension: {module} not built. If you want to import "
f"C extension: {_module} not built. If you want to import "
"pandas from the source directory, you may need to run "
"'python setup.py build_ext --force' to build the C extensions first."
) from err
) from _err
else:
del _tslib, _lib, _hashtable

Expand Down
15 changes: 10 additions & 5 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@
from typing import (
Any,
Callable,
Generic,
Iterable,
NamedTuple,
cast,
)
import warnings

from pandas._typing import F
from pandas._typing import (
F,
T,
)


class DeprecatedOption(NamedTuple):
Expand Down Expand Up @@ -247,16 +251,17 @@ def __dir__(self) -> Iterable[str]:
# of options, and option descriptions.


class CallableDynamicDoc:
def __init__(self, func, doc_tmpl) -> None:
class CallableDynamicDoc(Generic[T]):
def __init__(self, func: Callable[..., T], doc_tmpl: str) -> None:
self.__doc_tmpl__ = doc_tmpl
self.__func__ = func

def __call__(self, *args, **kwds):
def __call__(self, *args, **kwds) -> T:
return self.__func__(*args, **kwds)

# error: Signature of "__doc__" incompatible with supertype "object"
@property
def __doc__(self):
def __doc__(self) -> str: # type: ignore[override]
opts_desc = _describe_option("all", _print_desc=False)
opts_list = pp_options_list(list(_registered_options.keys()))
return self.__doc_tmpl__.format(opts_desc=opts_desc, opts_list=opts_list)
Expand Down
0