Skip to content

Commit dcc370b

Browse files
phoflpmhatre1
authored andcommitted
Remove close from StataReader (pandas-dev#57371)
1 parent 49e958e commit dcc370b

File tree

3 files changed

+1
-33
lines changed

3 files changed

+1
-33
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Removal of prior version deprecations/changes
115115
- Removed ``Series.__int__`` and ``Series.__float__``. Call ``int(Series.iloc[0])`` or ``float(Series.iloc[0])`` instead. (:issue:`51131`)
116116
- Removed ``Series.ravel`` (:issue:`56053`)
117117
- Removed ``Series.view`` (:issue:`56054`)
118+
- Removed ``StataReader.close`` (:issue:`49228`)
118119
- Removed ``axis`` argument from :meth:`DataFrame.groupby`, :meth:`Series.groupby`, :meth:`DataFrame.rolling`, :meth:`Series.rolling`, :meth:`DataFrame.resample`, and :meth:`Series.resample` (:issue:`51203`)
119120
- Removed ``axis`` argument from all groupby operations (:issue:`50405`)
120121
- Removed ``pandas.api.types.is_interval`` and ``pandas.api.types.is_period``, use ``isinstance(obj, pd.Interval)`` and ``isinstance(obj, pd.Period)`` instead (:issue:`55264`)

pandas/io/stata.py

-18
Original file line numberDiff line numberDiff line change
@@ -1181,24 +1181,6 @@ def __exit__(
11811181
if self._close_file:
11821182
self._close_file()
11831183

1184-
def close(self) -> None:
1185-
"""Close the handle if its open.
1186-
1187-
.. deprecated: 2.0.0
1188-
1189-
The close method is not part of the public API.
1190-
The only supported way to use StataReader is to use it as a context manager.
1191-
"""
1192-
warnings.warn(
1193-
"The StataReader.close() method is not part of the public API and "
1194-
"will be removed in a future version without notice. "
1195-
"Using StataReader as a context manager is the only supported method.",
1196-
FutureWarning,
1197-
stacklevel=find_stack_level(),
1198-
)
1199-
if self._close_file:
1200-
self._close_file()
1201-
12021184
def _set_encoding(self) -> None:
12031185
"""
12041186
Set string encoding which depends on file version

pandas/tests/io/test_stata.py

-15
Original file line numberDiff line numberDiff line change
@@ -2001,21 +2001,6 @@ def test_direct_read(datapath, monkeypatch):
20012001
assert reader._path_or_buf is bio
20022002

20032003

2004-
def test_statareader_warns_when_used_without_context(datapath):
2005-
file_path = datapath("io", "data", "stata", "stata-compat-118.dta")
2006-
with tm.assert_produces_warning(
2007-
ResourceWarning,
2008-
match="without using a context manager",
2009-
):
2010-
sr = StataReader(file_path)
2011-
sr.read()
2012-
with tm.assert_produces_warning(
2013-
FutureWarning,
2014-
match="is not part of the public API",
2015-
):
2016-
sr.close()
2017-
2018-
20192004
@pytest.mark.parametrize("version", [114, 117, 118, 119, None])
20202005
@pytest.mark.parametrize("use_dict", [True, False])
20212006
@pytest.mark.parametrize("infer", [True, False])

0 commit comments

Comments
 (0)