rspec/rules/S2856/python/rule.adoc

40 lines
1.0 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Importing a feature from the ``++__future__++`` module turns on that feature from a future version of Python in your module. The purpose is to allow you to gradually transition to the new features or incompatible changes in future language versions, rather than having to make the entire jump at once.
Because such changes must be applied to the entirety of a module to work, putting such imports anywhere but in the beginning of the module doesn't make sense. It would mean applying those restrictions to only part of your code. Because that would lead to inconsistencies and massive confusion, it's not allowed.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
name = "John"
from __future__ import division # Noncompliant
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
from __future__ import division
name = "John"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]