summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-07-20 21:27:44 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-07-21 09:21:45 +0200
commitcafe3b439bcb1a8e286ed39dbdfaa6cf046c67c9 (patch)
tree27079fcf2672c7de8b594b349dac346bffb3c80e
parentfc73e70828488152d970a71847928fe1c568e4e3 (diff)
downloadpylint-git-cafe3b439bcb1a8e286ed39dbdfaa6cf046c67c9.tar.gz
Add a regression test for AttributeError for Subscript object
Closes #4439
-rw-r--r--ChangeLog5
-rw-r--r--tests/functional/r/regression/regression_4439.py13
-rw-r--r--tests/functional/r/regression/regression_4439.txt1
3 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fbe87334..b8fb495ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,11 @@ Release date: TBA
..
Put bug fixes that should not wait for a new minor version here
+* Fix a crash when there would be a 'TypeError object does not support
+ item assignment' in the code we parse.
+
+ Closes #4439
+
* Fix crash if a callable returning a context manager was assigned to a list or dict item
Closes #4732
diff --git a/tests/functional/r/regression/regression_4439.py b/tests/functional/r/regression/regression_4439.py
new file mode 100644
index 000000000..966cc8006
--- /dev/null
+++ b/tests/functional/r/regression/regression_4439.py
@@ -0,0 +1,13 @@
+"""AttributeError: 'Subscript' object has no attribute 'name' """
+# pylint: disable=missing-docstring
+
+from typing import Optional
+
+from attr import attrib, attrs
+
+
+@attrs()
+class User:
+ name: str = attrib()
+ age: int = attrib()
+ occupation = Optional[str] = attrib(default=None) # [unsupported-assignment-operation]
diff --git a/tests/functional/r/regression/regression_4439.txt b/tests/functional/r/regression/regression_4439.txt
new file mode 100644
index 000000000..1fe96738d
--- /dev/null
+++ b/tests/functional/r/regression/regression_4439.txt
@@ -0,0 +1 @@
+unsupported-assignment-operation:13:17:User:'Optional' does not support item assignment:HIGH