Upgrade black version (#424) (#446)

[backport/2.3] Upgrade black version (#424)

Depends-On: ansible/ansible-zuul-jobs#1515
Upgrade black version
SUMMARY
Move off of beta version of black and pin to current calendar year
version.
The only manual changes here are to tox.ini. Everything else is from running the new version of black.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
Reviewed-by: Abhijeet Kasurde 
(cherry picked from commit 7c71436)
This commit is contained in:
Mike Graves
2022-04-29 13:47:08 -04:00
committed by GitHub
parent 346808ec4b
commit 68d45af767
15 changed files with 105 additions and 59 deletions

View File

@@ -240,12 +240,12 @@ class Connection(ConnectionBase):
# Translate verify_ssl to skip_verify_ssl, and output as string
skip_verify_ssl = not self.get_option(key)
local_cmd.append(
u"{0}={1}".format(
"{0}={1}".format(
self.connection_options[key], str(skip_verify_ssl).lower()
)
)
censored_local_cmd.append(
u"{0}={1}".format(
"{0}={1}".format(
self.connection_options[key], str(skip_verify_ssl).lower()
)
)
@@ -262,12 +262,12 @@ class Connection(ConnectionBase):
else:
censored_local_cmd += [cmd_arg, self.get_option(key)]
extra_args_name = u"{0}_extra_args".format(self.transport)
extra_args_name = "{0}_extra_args".format(self.transport)
if self.get_option(extra_args_name):
local_cmd += self.get_option(extra_args_name).split(" ")
censored_local_cmd += self.get_option(extra_args_name).split(" ")
pod = self.get_option(u"{0}_pod".format(self.transport))
pod = self.get_option("{0}_pod".format(self.transport))
if not pod:
pod = self._play_context.remote_addr
# -i is needed to keep stdin open which allows pipelining to work
@@ -275,7 +275,7 @@ class Connection(ConnectionBase):
censored_local_cmd += ["exec", "-i", pod]
# if the pod has more than one container, then container is required
container_arg_name = u"{0}_container".format(self.transport)
container_arg_name = "{0}_container".format(self.transport)
if self.get_option(container_arg_name):
local_cmd += ["-c", self.get_option(container_arg_name)]
censored_local_cmd += ["-c", self.get_option(container_arg_name)]
@@ -290,7 +290,7 @@ class Connection(ConnectionBase):
super(Connection, self)._connect()
if not self._connected:
display.vvv(
u"ESTABLISH {0} CONNECTION".format(self.transport),
"ESTABLISH {0} CONNECTION".format(self.transport),
host=self._play_context.remote_addr,
)
self._connected = True

View File

@@ -385,9 +385,11 @@ def check_pod(k8s_ansible_mixin, module):
def _fail(exc):
arg = {}
if hasattr(exc, "body"):
msg = "Namespace={0} Kind=Pod Name={1}: Failed requested object: {2}".format(
msg = (
"Namespace={0} Kind=Pod Name={1}: Failed requested object: {2}".format(
namespace, name, exc.body
)
)
else:
msg = to_native(exc)
for attr in ["status", "reason"]:

View File

@@ -123,9 +123,15 @@ def main():
state=dict(
type="str", default="present", choices=["present", "absent", "latest"]
),
plugin_path=dict(type="str",),
plugin_name=dict(type="str",),
plugin_version=dict(type="str",),
plugin_path=dict(
type="str",
),
plugin_name=dict(
type="str",
),
plugin_version=dict(
type="str",
),
# Helm options
context=dict(
type="str",

View File

@@ -81,7 +81,9 @@ def main():
module = AnsibleModule(
argument_spec=dict(
binary_path=dict(type="path"),
plugin_name=dict(type="str",),
plugin_name=dict(
type="str",
),
# Helm options
context=dict(
type="str",

View File

@@ -227,7 +227,10 @@ def execute_module(module, k8s_ansible_mixin):
def main():
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True,)
module = AnsibleModule(
argument_spec=argspec(),
supports_check_mode=True,
)
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
K8sAnsibleMixin,
get_api_client,

View File

@@ -164,7 +164,8 @@ SCALE_ARG_SPEC = {
def execute_module(
module, k8s_ansible_mixin,
module,
k8s_ansible_mixin,
):
k8s_ansible_mixin.set_resource_definitions(module)

View File

@@ -301,7 +301,10 @@ class K8sTaintAnsible:
def main():
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True,)
module = AnsibleModule(
argument_spec=argspec(),
supports_check_mode=True,
)
k8s_taint = K8sTaintAnsible(module)
k8s_taint.execute_module()

View File

@@ -62,7 +62,8 @@ from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
binary_path=dict(type="path"), version=dict(type="str", default="3.7.0"),
binary_path=dict(type="path"),
version=dict(type="str", default="3.7.0"),
),
)

View File

@@ -324,27 +324,27 @@ tests = [
# str type and everything else was mostly unicode type (don't ask me how)
dict(
last_applied={
u"kind": u"ConfigMap",
u"data": {u"one": "1", "three": "3", "two": "2"},
u"apiVersion": u"v1",
u"metadata": {u"namespace": u"apply", u"name": u"apply-configmap"},
"kind": "ConfigMap",
"data": {"one": "1", "three": "3", "two": "2"},
"apiVersion": "v1",
"metadata": {"namespace": "apply", "name": "apply-configmap"},
},
actual={
u"kind": u"ConfigMap",
u"data": {u"one": "1", "three": "3", "two": "2"},
u"apiVersion": u"v1",
u"metadata": {
u"namespace": u"apply",
u"name": u"apply-configmap",
u"resourceVersion": "1714994",
u"creationTimestamp": u"2019-08-17T05:08:05Z",
u"annotations": {},
u"selfLink": u"/api/v1/namespaces/apply/configmaps/apply-configmap",
u"uid": u"fed45fb0-c0ac-11e9-9d95-025000000001",
"kind": "ConfigMap",
"data": {"one": "1", "three": "3", "two": "2"},
"apiVersion": "v1",
"metadata": {
"namespace": "apply",
"name": "apply-configmap",
"resourceVersion": "1714994",
"creationTimestamp": "2019-08-17T05:08:05Z",
"annotations": {},
"selfLink": "/api/v1/namespaces/apply/configmaps/apply-configmap",
"uid": "fed45fb0-c0ac-11e9-9d95-025000000001",
},
},
desired={
"kind": u"ConfigMap",
"kind": "ConfigMap",
"data": {"one": "1", "three": "3", "two": "2"},
"apiVersion": "v1",
"metadata": {"namespace": "apply", "name": "apply-configmap"},
@@ -355,7 +355,7 @@ tests = [
# then apply the Deployment again. Should un-scale the Deployment
dict(
last_applied={
"kind": u"Deployment",
"kind": "Deployment",
"spec": {
"replicas": 1,
"template": {
@@ -372,10 +372,10 @@ tests = [
}
},
},
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
"metadata": {"namespace": "apply", "name": "apply-deployment"},
},
actual={
"kind": u"Deployment",
"kind": "Deployment",
"spec": {
"replicas": 0,
"template": {
@@ -392,10 +392,10 @@ tests = [
}
},
},
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
"metadata": {"namespace": "apply", "name": "apply-deployment"},
},
desired={
"kind": u"Deployment",
"kind": "Deployment",
"spec": {
"replicas": 1,
"template": {
@@ -409,7 +409,7 @@ tests = [
}
},
},
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
"metadata": {"namespace": "apply", "name": "apply-deployment"},
},
expected={
"spec": {

View File

@@ -26,25 +26,49 @@ from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
tests = [
dict(
resource=dict(kind="ConfigMap", name="", data=dict(),),
resource=dict(
kind="ConfigMap",
name="",
data=dict(),
),
expected=b'{"data":{},"kind":"ConfigMap","name":""}',
),
dict(
resource=dict(kind="ConfigMap", name="", data=dict(one=""),),
resource=dict(
kind="ConfigMap",
name="",
data=dict(one=""),
),
expected=b'{"data":{"one":""},"kind":"ConfigMap","name":""}',
),
dict(
resource=dict(
kind="ConfigMap", name="", data=dict(two="2", one="", three="3",),
kind="ConfigMap",
name="",
data=dict(
two="2",
one="",
three="3",
),
),
expected=b'{"data":{"one":"","three":"3","two":"2"},"kind":"ConfigMap","name":""}',
),
dict(
resource=dict(kind="Secret", type="my-type", name="", data=dict(),),
resource=dict(
kind="Secret",
type="my-type",
name="",
data=dict(),
),
expected=b'{"data":{},"kind":"Secret","name":"","type":"my-type"}',
),
dict(
resource=dict(kind="Secret", type="my-type", name="", data=dict(one=""),),
resource=dict(
kind="Secret",
type="my-type",
name="",
data=dict(one=""),
),
expected=b'{"data":{"one":""},"kind":"Secret","name":"","type":"my-type"}',
),
dict(
@@ -52,7 +76,11 @@ tests = [
kind="Secret",
type="my-type",
name="",
data=dict(two="Mg==", one="", three="Mw==",),
data=dict(
two="Mg==",
one="",
three="Mw==",
),
),
expected=b'{"data":{"one":"","three":"Mw==","two":"Mg=="},"kind":"Secret","name":"","type":"my-type"}',
),

View File

@@ -21,7 +21,7 @@ commands = collection_prep_add_docs -p .
[testenv:black]
deps =
black==19.10b0
black >= 22.0, < 23.0
commands =
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
@@ -30,7 +30,7 @@ commands =
deps =
yamllint
flake8
black==19.10b0
{[testenv:black]deps}
commands =
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests