summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2017-11-11 12:56:30 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2017-11-11 12:56:30 +0100
commit434f7feb490479fc2000d3214126622b6eb41d97 (patch)
treed92f417706b9d4318fa069603e325814756541c5
parentbe694f811f7df89c4fcc672ef09c0e1fc499cf23 (diff)
downloadastroid-git-434f7feb490479fc2000d3214126622b6eb41d97.tar.gz
Remove file_stream since it was slated for removal for 1.6
-rw-r--r--ChangeLog4
-rw-r--r--astroid/scoped_nodes.py28
-rw-r--r--astroid/tests/unittest_scoped_nodes.py27
3 files changed, 11 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ce538e9..e2a2d4eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@ Change log for the astroid package (used to be astng)
=====================================================
--
+ * file_stream was removed, since it was deprecated for three releases
+
+ Instead one should use the .stream() method.
+
* Vast improvements to numpy support
* Add brain tips for curses
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 677cc7e1..6f203751 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -415,21 +415,6 @@ class Module(LocalsDictNodeNG):
return stream
return None
- @property
- def file_stream(self):
- """Get a stream to the underlying file or bytes.
-
- .. deprecated:: 1.5
-
- :type: file or io.BytesIO or None
- """
- warnings.warn("file_stream property is deprecated and "
- "it is slated for removal in astroid 1.6."
- "Use the new method 'stream' instead.",
- PendingDeprecationWarning,
- stacklevel=2)
- return self._get_stream()
-
def stream(self):
"""Get a stream to the underlying file or bytes.
@@ -439,19 +424,6 @@ class Module(LocalsDictNodeNG):
"""
return self._get_stream()
- def close(self):
- """Close the underlying file streams.
-
- .. deprecated:: 1.5
- """
- warnings.warn("close method is deprecated and it is "
- "slated for removal in astroid 1.6, along "
- "with 'file_stream' property. "
- "Its behaviour is replaced by managing each "
- "file stream returned by the 'stream' method.",
- PendingDeprecationWarning,
- stacklevel=2)
-
def block_range(self, lineno):
"""Get a range from where this node starts to where this node ends.
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index bc255303..55258301 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -220,35 +220,22 @@ class ModuleNodeTest(ModuleLoader, unittest.TestCase):
def test_file_stream_in_memory(self):
data = '''irrelevant_variable is irrelevant'''
astroid = builder.parse(data, 'in_memory')
- with warnings.catch_warnings(record=True):
- self.assertEqual(astroid.file_stream.read().decode(), data)
+ with astroid.stream() as stream:
+ self.assertEqual(stream.read().decode(), data)
def test_file_stream_physical(self):
path = resources.find('data/all.py')
astroid = builder.AstroidBuilder().file_build(path, 'all')
with open(path, 'rb') as file_io:
- with warnings.catch_warnings(record=True):
- self.assertEqual(astroid.file_stream.read(), file_io.read())
+ with astroid.stream() as stream:
+ self.assertEqual(stream.read(), file_io.read())
def test_file_stream_api(self):
path = resources.find('data/all.py')
astroid = builder.AstroidBuilder().file_build(path, 'all')
- if __pkginfo__.numversion >= (1, 6):
- # file_stream is slated for removal in astroid 1.6.
- with self.assertRaises(AttributeError):
- # pylint: disable=pointless-statement
- astroid.file_stream
- else:
- # Until astroid 1.6, Module.file_stream will emit
- # PendingDeprecationWarning in 1.4, DeprecationWarning
- # in 1.5 and finally it will be removed in 1.6, leaving
- # only Module.stream as the recommended way to retrieve
- # its file stream.
- with warnings.catch_warnings(record=True) as cm:
- with test_utils.enable_warning(PendingDeprecationWarning):
- self.assertIsNot(astroid.file_stream, astroid.file_stream)
- self.assertGreater(len(cm), 1)
- self.assertEqual(cm[0].category, PendingDeprecationWarning)
+ with self.assertRaises(AttributeError):
+ # pylint: disable=pointless-statement
+ astroid.file_stream
def test_stream_api(self):
path = resources.find('data/all.py')