mirror of https://github.com/ansible/ansible.git
Drop Python 2.7 and Python 3.6 support (#81866)
* Drop Python 2.7 and Python 3.6 support * Remove obsolete _json_compatpull/81882/head
parent
c1343cc304
commit
b94ee1cefd
@ -1,16 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019 Ansible Project
|
||||
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import types
|
||||
import json
|
||||
|
||||
# Detect the python-json library which is incompatible
|
||||
try:
|
||||
if not isinstance(json.loads, types.FunctionType) or not isinstance(json.dumps, types.FunctionType):
|
||||
raise ImportError('json.loads or json.dumps were not found in the imported json library.')
|
||||
except AttributeError:
|
||||
raise ImportError('python-json was detected, which is incompatible.')
|
@ -1,9 +1,7 @@
|
||||
base image=quay.io/ansible/base-test-container:5.9.0 python=3.11,2.7,3.6,3.7,3.8,3.9,3.10,3.12
|
||||
default image=quay.io/ansible/default-test-container:9.2.0 python=3.11,2.7,3.6,3.7,3.8,3.9,3.10,3.12 context=collection
|
||||
default image=quay.io/ansible/ansible-core-test-container:9.2.0 python=3.11,2.7,3.6,3.7,3.8,3.9,3.10,3.12 context=ansible-core
|
||||
base image=quay.io/ansible/base-test-container:5.9.0 python=3.11,3.7,3.8,3.9,3.10,3.12
|
||||
default image=quay.io/ansible/default-test-container:9.2.0 python=3.11,3.7,3.8,3.9,3.10,3.12 context=collection
|
||||
default image=quay.io/ansible/ansible-core-test-container:9.2.0 python=3.11,3.7,3.8,3.9,3.10,3.12 context=ansible-core
|
||||
alpine3 image=quay.io/ansible/alpine3-test-container:6.3.0 python=3.11 cgroup=none audit=none
|
||||
centos7 image=quay.io/ansible/centos7-test-container:6.3.0 python=2.7 cgroup=v1-only
|
||||
fedora38 image=quay.io/ansible/fedora38-test-container:6.3.0 python=3.11
|
||||
opensuse15 image=quay.io/ansible/opensuse15-test-container:6.3.0 python=3.6
|
||||
ubuntu2004 image=quay.io/ansible/ubuntu2004-test-container:6.3.0 python=3.8
|
||||
ubuntu2204 image=quay.io/ansible/ubuntu2204-test-container:6.3.0 python=3.10
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"extensions": [
|
||||
".py"
|
||||
],
|
||||
"py2_compat": true,
|
||||
"output": "path-message"
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
"""Enforce proper usage of __future__ imports."""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||
with open(path, 'rb') as path_fd:
|
||||
lines = path_fd.read().splitlines()
|
||||
|
||||
missing = True
|
||||
if not lines:
|
||||
# Files are allowed to be empty of everything including boilerplate
|
||||
missing = False
|
||||
|
||||
for text in lines:
|
||||
if text in (b'from __future__ import (absolute_import, division, print_function)',
|
||||
b'from __future__ import absolute_import, division, print_function'):
|
||||
missing = False
|
||||
break
|
||||
|
||||
if missing:
|
||||
with open(path, encoding='utf-8') as file:
|
||||
contents = file.read()
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
node = ast.parse(contents)
|
||||
|
||||
# files consisting of only assignments have no need for future import boilerplate
|
||||
# the only exception would be division during assignment, but we'll overlook that for simplicity
|
||||
# the most likely case is that of a documentation only python file
|
||||
if all(isinstance(statement, ast.Assign) for statement in node.body):
|
||||
missing = False
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass # the compile sanity test will report this error
|
||||
|
||||
if missing:
|
||||
print('%s: missing: from __future__ import (absolute_import, division, print_function)' % path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"extensions": [
|
||||
".py"
|
||||
],
|
||||
"py2_compat": true,
|
||||
"output": "path-message"
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
"""Require __metaclass__ boilerplate for code that supports Python 2.x."""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||
with open(path, 'rb') as path_fd:
|
||||
lines = path_fd.read().splitlines()
|
||||
|
||||
missing = True
|
||||
if not lines:
|
||||
# Files are allowed to be empty of everything including boilerplate
|
||||
missing = False
|
||||
|
||||
for text in lines:
|
||||
if text == b'__metaclass__ = type':
|
||||
missing = False
|
||||
break
|
||||
|
||||
if missing:
|
||||
with open(path, encoding='utf-8') as file:
|
||||
contents = file.read()
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
node = ast.parse(contents)
|
||||
|
||||
# files consisting of only assignments have no need for metaclass boilerplate
|
||||
# the most likely case is that of a documentation only python file
|
||||
if all(isinstance(statement, ast.Assign) for statement in node.body):
|
||||
missing = False
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass # the compile sanity test will report this error
|
||||
|
||||
if missing:
|
||||
print('%s: missing: __metaclass__ = type' % path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue