From 96b9861cfb33b9b4376939f31d989a416ec6190d Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 20 Jul 2021 21:27:44 +0200 Subject: [PATCH] Add a regression test for AttributeError for Subscript object Closes #4439 --- ChangeLog | 5 +++++ tests/functional/r/regression/regression_4439.py | 13 +++++++++++++ tests/functional/r/regression/regression_4439.txt | 1 + 3 files changed, 19 insertions(+) create mode 100644 tests/functional/r/regression/regression_4439.py create mode 100644 tests/functional/r/regression/regression_4439.txt diff --git a/ChangeLog b/ChangeLog index 8fbe87334a..b8fb495ea6 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 0000000000..966cc80067 --- /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 0000000000..1fe96738d4 --- /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