rspec/rules/S6465/python/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

24 lines
560 B
Plaintext

== Why is this an issue?
Unpacking lets developers assign values of an iterable simultaneously to different targets in a single assignment.
However, for this assignment to work, the iterable should have the same number of elements as there are targets in the target list.
If this is not respected, a `ValueError` will be produced at runtime.
=== Noncompliant code example
[source,python]
----
def foo(param):
ls = [1, 2, 3]
x, y = ls # Noncompliant
----
=== Compliant solution
[source,python]
----
def foo(param):
ls = [1, 2, 3]
x, y, z = ls
----