diff options
author | Damien Baty <damien@damienbaty.com> | 2021-01-18 12:36:56 +0100 |
---|---|---|
committer | Damien Baty <damien@damienbaty.com> | 2021-01-18 13:06:05 +0100 |
commit | 294623e1f1c4a83c193e6eb8c61cf1cb7233b8b9 (patch) | |
tree | ca2138916a5ebb754937312ef852cff9a63ecbfc /tests/unittest_brain.py | |
parent | c9fd1934e9c49d9052f64439fc7ea82026bce00f (diff) | |
download | astroid-git-294623e1f1c4a83c193e6eb8c61cf1cb7233b8b9.tar.gz |
brain: Add `__class_getitem__` to `subprocess.Popen` starting from Python 3.9
This is necessary for pylint to detect that `subprocess.Popen` is
subscriptable, starting from Python 3.9 (see PyCQA/pylint#4034).
$ python3.9
>>> import subprocess
>>> subprocess.Popen.__class_getitem__
<bound method GenericAlias of <class 'subprocess.Popen'>>
Diffstat (limited to 'tests/unittest_brain.py')
-rw-r--r-- | tests/unittest_brain.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index 7bb1f70f..4717ab76 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -1292,6 +1292,13 @@ class SubprocessTest(unittest.TestCase): assert isinstance(inferred, astroid.Const) assert isinstance(inferred.value, (str, bytes)) + @test_utils.require_version("3.9") + def test_popen_does_not_have_class_getitem(self): + code = """import subprocess; subprocess.Popen""" + node = astroid.extract_node(code) + inferred = next(node.infer()) + assert "__class_getitem__" in inferred + class TestIsinstanceInference: """Test isinstance builtin inference""" |