File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1010from collections import defaultdict , deque
1111from functools import partial
1212from inspect import getfullargspec
13- from io import StringIO , TextIOWrapper
13+ from io import StringIO
1414from itertools import groupby
1515from pathlib import Path
1616from typing import TYPE_CHECKING , Literal , cast
@@ -344,13 +344,6 @@ def __init__(
344344 if isinstance (filename , (str | Path )):
345345 with zopen (filename , mode = "rt" , encoding = "utf-8" , errors = "replace" ) as f :
346346 cif_string : str = cast ("str" , f .read ())
347- elif isinstance (filename , TextIOWrapper ):
348- warnings .warn (
349- "Initializing CifParser from TextIOWrapper is deprecated, use str or Path instead." ,
350- DeprecationWarning ,
351- stacklevel = 2 ,
352- )
353- cif_string = filename .read ()
354347 elif isinstance (filename , StringIO ):
355348 warnings .warn (
356349 "Initializing CifParser from StringIO is deprecated, use `from_str()` instead." ,
Original file line number Diff line number Diff line change @@ -170,6 +170,16 @@ def test_cif_parser(self):
170170 for struct in parser .parse_structures ():
171171 assert struct .formula == "V4 O6"
172172
173+ # Test init from StringIO
174+ with open (f"{ TEST_FILES_DIR } /cif/V2O3.cif" , encoding = "utf-8" ) as f :
175+ cif_text = f .read ()
176+
177+ with pytest .warns (DeprecationWarning , match = "Initializing CifParser from StringIO" ):
178+ parser = CifParser (StringIO (cif_text ))
179+
180+ for struct in parser .parse_structures ():
181+ assert struct .formula == "V4 O6"
182+
173183 # Test init from TextIOWrapper
174184 with (
175185 pytest .warns (DeprecationWarning , match = "Initializing CifParser from TextIOWrapper" ),
You can’t perform that action at this time.
0 commit comments