diff --git a/pandas/_libs/hashtable.pyi b/pandas/_libs/hashtable.pyi index 951703e04d5a3..c6319a1f24435 100644 --- a/pandas/_libs/hashtable.pyi +++ b/pandas/_libs/hashtable.pyi @@ -1,5 +1,4 @@ from typing import ( - Any, Hashable, Literal, ) diff --git a/pandas/io/clipboard/__init__.py b/pandas/io/clipboard/__init__.py index 947deb39ae064..0417529999890 100644 --- a/pandas/io/clipboard/__init__.py +++ b/pandas/io/clipboard/__init__.py @@ -116,7 +116,7 @@ def copy_osx_pbcopy(text): def paste_osx_pbcopy(): p = subprocess.Popen(["pbpaste", "r"], stdout=subprocess.PIPE, close_fds=True) - stdout, stderr = p.communicate() + stdout = p.communicate()[0] return stdout.decode(ENCODING) return copy_osx_pbcopy, paste_osx_pbcopy @@ -194,7 +194,7 @@ def paste_xclip(primary=False): stderr=subprocess.PIPE, close_fds=True, ) - stdout, stderr = p.communicate() + stdout = p.communicate()[0] # Intentionally ignore extraneous output on stderr when clipboard is empty return stdout.decode(ENCODING) @@ -222,7 +222,7 @@ def paste_xsel(primary=False): p = subprocess.Popen( ["xsel", selection_flag, "-o"], stdout=subprocess.PIPE, close_fds=True ) - stdout, stderr = p.communicate() + stdout = p.communicate()[0] return stdout.decode(ENCODING) return copy_xsel, paste_xsel @@ -250,7 +250,7 @@ def paste_klipper(): stdout=subprocess.PIPE, close_fds=True, ) - stdout, stderr = p.communicate() + stdout = p.communicate()[0] # Workaround for https://bugs.kde.org/show_bug.cgi?id=342874 # TODO: https://github.com/asweigart/pyperclip/issues/43 @@ -493,7 +493,7 @@ def paste_wsl(): stderr=subprocess.PIPE, close_fds=True, ) - stdout, stderr = p.communicate() + stdout = p.communicate()[0] # WSL appends "\r\n" to the contents. return stdout[:-2].decode(ENCODING) diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index d636838d21d0e..cfda2911db73f 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -876,7 +876,7 @@ def space_format(x, y): need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes))) str_columns = [ [" " + x if not self._get_formatter(i) and need_leadsp[x] else x] - for i, (col, x) in enumerate(zip(columns, fmt_columns)) + for i, x in enumerate(fmt_columns) ] # self.str_columns = str_columns return str_columns diff --git a/pandas/io/formats/xml.py b/pandas/io/formats/xml.py index f5ba8c6b53335..ea7d1dfa1645e 100644 --- a/pandas/io/formats/xml.py +++ b/pandas/io/formats/xml.py @@ -264,8 +264,6 @@ def build_elems(self) -> None: def write_output(self) -> str | None: xml_doc = self.build_tree() - out_str: str | None - if self.path_or_buffer is not None: with get_handle( self.path_or_buffer, diff --git a/pandas/io/html.py b/pandas/io/html.py index 2947b22f85d61..cbf10798a538a 100644 --- a/pandas/io/html.py +++ b/pandas/io/html.py @@ -632,7 +632,6 @@ def _build_xpath_expr(attrs) -> str: _re_namespace = {"re": "http://exslt.org/regular-expressions"} -_valid_schemes = "http", "file", "ftp" class _LxmlFrameParser(_HtmlFrameParser): diff --git a/pandas/io/xml.py b/pandas/io/xml.py index 8b0055a522e25..bc3436861f1a8 100644 --- a/pandas/io/xml.py +++ b/pandas/io/xml.py @@ -297,9 +297,7 @@ def _parse_nodes(self) -> list[dict[str, str | None]]: dicts = [{k: d[k] if k in d.keys() else None for k in keys} for d in dicts] if self.names: - dicts = [ - {nm: v for nm, (k, v) in zip(self.names, d.items())} for d in dicts - ] + dicts = [{nm: v for nm, v in zip(self.names, d.values())} for d in dicts] return dicts @@ -478,9 +476,7 @@ def _parse_nodes(self) -> list[dict[str, str | None]]: dicts = [{k: d[k] if k in d.keys() else None for k in keys} for d in dicts] if self.names: - dicts = [ - {nm: v for nm, (k, v) in zip(self.names, d.items())} for d in dicts - ] + dicts = [{nm: v for nm, v in zip(self.names, d.values())} for d in dicts] return dicts diff --git a/pandas/util/_depr_module.py b/pandas/util/_depr_module.py deleted file mode 100644 index 5694ca24aab57..0000000000000 --- a/pandas/util/_depr_module.py +++ /dev/null @@ -1,107 +0,0 @@ -""" -This module houses a utility class for mocking deprecated modules. -It is for internal use only and should not be used beyond this purpose. -""" - -import importlib -from typing import Iterable -import warnings - - -class _DeprecatedModule: - """ - Class for mocking deprecated modules. - - Parameters - ---------- - deprmod : name of module to be deprecated. - deprmodto : name of module as a replacement, optional. - If not given, the __module__ attribute will - be used when needed. - removals : objects or methods in module that will no longer be - accessible once module is removed. - moved : dict, optional - dictionary of function name -> new location for moved - objects - """ - - def __init__(self, deprmod, deprmodto=None, removals=None, moved=None): - self.deprmod = deprmod - self.deprmodto = deprmodto - self.removals = removals - if self.removals is not None: - self.removals = frozenset(self.removals) - self.moved = moved - - # For introspection purposes. - self.self_dir = frozenset(dir(type(self))) - - def __dir__(self) -> Iterable[str]: - deprmodule = self._import_deprmod() - return dir(deprmodule) - - def __repr__(self) -> str: - deprmodule = self._import_deprmod() - return repr(deprmodule) - - __str__ = __repr__ - - def __getattr__(self, name: str): - if name in self.self_dir: - return object.__getattribute__(self, name) - - try: - deprmodule = self._import_deprmod(self.deprmod) - except ImportError: - if self.deprmodto is None: - raise - - # a rename - deprmodule = self._import_deprmod(self.deprmodto) - - obj = getattr(deprmodule, name) - - if self.removals is not None and name in self.removals: - warnings.warn( - f"{self.deprmod}.{name} is deprecated and will be removed in " - "a future version.", - FutureWarning, - stacklevel=2, - ) - elif self.moved is not None and name in self.moved: - warnings.warn( - f"{self.deprmod} is deprecated and will be removed in " - f"a future version.\nYou can access {name} as {self.moved[name]}", - FutureWarning, - stacklevel=2, - ) - else: - deprmodto = self.deprmodto - if deprmodto is False: - warnings.warn( - f"{self.deprmod}.{name} is deprecated and will be removed in " - "a future version.", - FutureWarning, - stacklevel=2, - ) - else: - if deprmodto is None: - deprmodto = obj.__module__ - # The object is actually located in another module. - warnings.warn( - f"{self.deprmod}.{name} is deprecated. Please use " - f"{deprmodto}.{name} instead.", - FutureWarning, - stacklevel=2, - ) - - return obj - - def _import_deprmod(self, mod=None): - if mod is None: - mod = self.deprmod - - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=FutureWarning) - deprmodule = importlib.import_module(mod) - return deprmodule