rspec/rules/S2709/python/rule.adoc

48 lines
843 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Python interprets ``++False++`` as a "false" boolean value, and ``++True++`` as a "true" boolean value. Assigning them other values could lead to unexpected behaviors.
This rule raises an issue when "True" and "False", with any case, are used as identifiers.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
True = "red" # Noncompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
color = "red" # Noncompliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Rename this variable.
'''
== Comments And Links
(visible only on this page)
=== on 17 Mar 2015, 08:56:02 Elena Vilchik wrote:
\[~ann.campbell.2] AFAK:
1. "None" can't be used as identifier.
2. "True" has value, which is "true".
endif::env-github,rspecator-view[]