22 lines
436 B
Plaintext
22 lines
436 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
|
|
|
|
----
|
|
def my_function():
|
|
my_int: int = "string" # Noncompliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
def my_function():
|
|
my_str: str = "string"
|
|
----
|
|
|