You could remove those __future__
imports without impacting functionality, but removing them is not necessary and stops compatibility with earlier python versions.
Moreover, as @deceze alludes to in his comment, other imports may be different. For example, from __future__ import annotations
is only enabled in Python <= 4.0 via the import, so adding/removing that line would impact the functionality:
Since this change breaks compatibility, the new behavior needs to be
enabled on a per-module basis in Python 3.7 using a __future__
import:
from __future__ import annotations
It will become the default in Python 4.0.
As @jmd_dk points out, you can actually find this information in the __future__
module. I wrote a short script to extract it:
import __future__
import ast
import sys
print('Python version:', sys.version_info)
sys_t = sys.version_info[:3]
s = '__future__ import {} {} for you; the version: {} vs. your version: {}'
for name in __future__.all_feature_names:
optional, mandatory, _ = ast.literal_eval(str(getattr(__future__, name)).lstrip('_Featur'))
optional, mandatory = optional[:3], mandatory[:3]
print('\nName: {}'.format(name))
tmp = [None, None, optional, sys_t]
if optional <= sys_t:
tmp[:2] = 'is', 'included'
else:
tmp[:2] = 'not', 'included'
print(s.format(*tmp))
tmp[2] = mandatory
if mandatory <= sys_t:
tmp[:2] = 'is', 'fixed'
else:
tmp[:2] = 'not', 'fixed'
print(s.format(*tmp))
On my system this outputs:
Python version: sys.version_info(major=3, minor=7, micro=1, releaselevel='final', serial=0)
Name: nested_scopes
__future__ import is included for you; the version: (2, 1, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (2, 2, 0) vs. your version: (3, 7, 1)
Name: generators
__future__ import is included for you; the version: (2, 2, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (2, 3, 0) vs. your version: (3, 7, 1)
Name: division
__future__ import is included for you; the version: (2, 2, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (3, 0, 0) vs. your version: (3, 7, 1)
Name: absolute_import
__future__ import is included for you; the version: (2, 5, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (3, 0, 0) vs. your version: (3, 7, 1)
Name: with_statement
__future__ import is included for you; the version: (2, 5, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (2, 6, 0) vs. your version: (3, 7, 1)
Name: print_function
__future__ import is included for you; the version: (2, 6, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (3, 0, 0) vs. your version: (3, 7, 1)
Name: unicode_literals
__future__ import is included for you; the version: (2, 6, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (3, 0, 0) vs. your version: (3, 7, 1)
Name: barry_as_FLUFL
__future__ import is included for you; the version: (3, 1, 0) vs. your version: (3, 7, 1)
__future__ import not fixed for you; the version: (3, 9, 0) vs. your version: (3, 7, 1)
Name: generator_stop
__future__ import is included for you; the version: (3, 5, 0) vs. your version: (3, 7, 1)
__future__ import is fixed for you; the version: (3, 7, 0) vs. your version: (3, 7, 1)
Name: annotations
__future__ import is included for you; the version: (3, 7, 0) vs. your version: (3, 7, 1)
__future__ import not fixed for you; the version: (4, 0, 0) vs. your version: (3, 7, 1)
When Python >= 3.8 introduces __future__
imports (there are none yet as I write this), removing these and running on Python 3.7 obviously would impact the functionality.