Closed
Description
Bug description
Pylint displays the following error code:
Error message: 'Attempting to unpack a non-sequence'
Details:
[{
"resource": "/c:/[REDACTED]/main.py",
"owner": "python",
"code": "unpacking-non-sequence",
"severity": 8,
"message": "Attempting to unpack a non-sequence",
"source": "pylint",
"startLineNumber": 124,
"startColumn": 5,
"endLineNumber": 124,
"endColumn": 5
}]
When the following code snippet is used:
def check_user_can_add_friend(username):
# Get subscription level
subscription_level = user_get_subscription_level(username)
number_friend_requests = user_count_friend_requests(username)
number_friends = number_friend_requests + user_count_friends(username)
match subscription_level:
case "BASIC":
if number_friends < 5:
return True, " "
else:
return False, "'" + username + "' can only have a maximum of 5 friends"
case "GOLD":
if number_friends < 20:
return True, " "
else:
return False, "'" + username + "' can only have a maximum of 20 friends"
case _:
return True, " "
If the above match statement is changed to an if and elseif statement then the error reported by pylance for un-packing will go away
Configuration
No response
Command used
Automatically within VS Code via PyLance, the pylance team advised me to raise this with yourselves:
https://github.com/microsoft/pylance-release/issues/2060
Pylint output
Error message: 'Attempting to unpack a non-sequence'
Details:
[{
"resource": "/c:/[REDACTED]/main.py",
"owner": "python",
"code": "unpacking-non-sequence",
"severity": 8,
"message": "Attempting to unpack a non-sequence",
"source": "pylint",
"startLineNumber": 124,
"startColumn": 5,
"endLineNumber": 124,
"endColumn": 5
}]
Expected behavior
Pylance should not show any error for this line as it can be correctly unpacked.
Pylint version
pylint 2.11.1
astroid 2.8.4
Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
OS / Environment
Windows 10 Enterprise (10.0.18363 Build 18363)
Additional dependencies
No response