rspec/rules/S5890/python/rule.adoc
2022-02-04 16:28:24 +00:00

41 lines
750 B
Plaintext

Type hints can be used to communicate the intended type of a given variable. These are not enforced at runtime and not respecting them might not necessarily lead to runtime errors.
It is however confusing and could lead to maintainability issues.
== Noncompliant Code Example
[source,python]
----
def my_function():
my_int: int = "string" # Noncompliant
----
== Compliant Solution
[source,python]
----
def my_function():
my_str: str = "string"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]