summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-11-21 19:45:17 +0100
committerGitHub <noreply@github.com>2021-11-21 19:45:17 +0100
commit079805b0f9d0324d1731595c0c6f8f36e5a999f4 (patch)
tree4f5075bb5fb9bddac8697cc900b51ca651996baf
parent3455dc2bf9c436e6961fe74f04d03eb08e4bdb99 (diff)
downloadpylint-git-079805b0f9d0324d1731595c0c6f8f36e5a999f4.tar.gz
Upgrade astroid to 2.9.0 (#5355)
* Upgrade astroid to 2.9.0 * Fix slice index col_offset
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/typecheck.py12
-rw-r--r--requirements_test_min.txt2
-rw-r--r--setup.cfg2
-rw-r--r--tests/functional/d/deprecated/dataclass_typecheck.txt2
-rw-r--r--tests/functional/i/invalid/s/invalid_slice_index.txt10
6 files changed, 18 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 221065a72..b682defa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,10 @@ Release date: TBA
..
Put new features here and also in 'doc/whatsnew/2.12.rst'
+* Upgrade astroid to 2.9.0
+
+ Closes #4982
+
* Fix ``install graphiz`` message which isn't needed for puml output format.
* Fix ``simplify-boolean-expression`` when condition can be inferred as False.
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index e2af03e55..80926624f 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -1584,9 +1584,9 @@ accessed. Python regular expressions are accepted.",
# index to check if the object being sliced can support them
return self._check_invalid_sequence_index(node.parent)
- def _check_invalid_slice_index(self, node):
+ def _check_invalid_slice_index(self, node: nodes.Slice) -> None:
# Check the type of each part of the slice
- invalid_slices = 0
+ invalid_slices_nodes: List[nodes.NodeNG] = []
for index in (node.lower, node.upper, node.step):
if index is None:
continue
@@ -1610,9 +1610,9 @@ accessed. Python regular expressions are accepted.",
return
except astroid.NotFoundError:
pass
- invalid_slices += 1
+ invalid_slices_nodes.append(index)
- if not invalid_slices:
+ if not invalid_slices_nodes:
return
# Anything else is an error, unless the object that is indexed
@@ -1635,8 +1635,8 @@ accessed. Python regular expressions are accepted.",
if not isinstance(inferred, known_objects):
# Might be an instance that knows how to handle this slice object
return
- for _ in range(invalid_slices):
- self.add_message("invalid-slice-index", node=node)
+ for snode in invalid_slices_nodes:
+ self.add_message("invalid-slice-index", node=snode)
@check_messages("not-context-manager")
def visit_with(self, node: nodes.With) -> None:
diff --git a/requirements_test_min.txt b/requirements_test_min.txt
index b8c642a6a..d309c8607 100644
--- a/requirements_test_min.txt
+++ b/requirements_test_min.txt
@@ -1,5 +1,5 @@
-e .
# astroid dependency is also defined in setup.cfg
-astroid==2.8.5 # Pinned to a specific version for tests
+astroid==2.9.0 # Pinned to a specific version for tests
pytest~=6.2
pytest-benchmark~=3.4
diff --git a/setup.cfg b/setup.cfg
index c19718df0..18f7da882 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -44,7 +44,7 @@ project_urls =
packages = find:
install_requires =
platformdirs>=2.2.0
- astroid>=2.8.5,<2.9 # (You should also upgrade requirements_test_min.txt)
+ astroid>=2.9.0,<2.10 # (You should also upgrade requirements_test_min.txt)
isort>=4.2.5,<6
mccabe>=0.6,<0.7
toml>=0.9.2
diff --git a/tests/functional/d/deprecated/dataclass_typecheck.txt b/tests/functional/d/deprecated/dataclass_typecheck.txt
index 529f4aab9..e64b1fa80 100644
--- a/tests/functional/d/deprecated/dataclass_typecheck.txt
+++ b/tests/functional/d/deprecated/dataclass_typecheck.txt
@@ -1,5 +1,5 @@
invalid-sequence-index:32:6::Sequence index is not an int, slice, or instance with __index__:HIGH
-invalid-slice-index:36:0::Slice index is not an int, None, or instance with __index__:HIGH
+invalid-slice-index:36:10::Slice index is not an int, None, or instance with __index__:HIGH
not-callable:39:0::obj.attr1 is not callable:HIGH
invalid-unary-operand-type:44:6::"bad operand type for unary -: str":HIGH
unsupported-membership-test:51:11::Value 'obj.attr1' doesn't support membership test:HIGH
diff --git a/tests/functional/i/invalid/s/invalid_slice_index.txt b/tests/functional/i/invalid/s/invalid_slice_index.txt
index e715138b4..84a862414 100644
--- a/tests/functional/i/invalid/s/invalid_slice_index.txt
+++ b/tests/functional/i/invalid/s/invalid_slice_index.txt
@@ -1,5 +1,5 @@
-invalid-slice-index:10:0:function1:Slice index is not an int, None, or instance with __index__
-invalid-slice-index:10:0:function1:Slice index is not an int, None, or instance with __index__
-invalid-slice-index:14:0:function2:Slice index is not an int, None, or instance with __index__
-invalid-slice-index:14:0:function2:Slice index is not an int, None, or instance with __index__
-invalid-slice-index:23:0:function3:Slice index is not an int, None, or instance with __index__
+invalid-slice-index:10:20:function1:Slice index is not an int, None, or instance with __index__:HIGH
+invalid-slice-index:10:23:function1:Slice index is not an int, None, or instance with __index__:HIGH
+invalid-slice-index:14:20:function2:Slice index is not an int, None, or instance with __index__:HIGH
+invalid-slice-index:14:24:function2:Slice index is not an int, None, or instance with __index__:HIGH
+invalid-slice-index:23:20:function3:Slice index is not an int, None, or instance with __index__:HIGH