Skip to content

Commit

Permalink
{Pylint} Fix redundant-u-string-prefix (#30325)
Browse files Browse the repository at this point in the history
  • Loading branch information
atombrella authored Nov 28, 2024
1 parent e98a4a2 commit d2cd62b
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 68 deletions.
1 change: 0 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ disable=
use-dict-literal,
consider-using-dict-items,
consider-using-enumerate,
redundant-u-string-prefix,
# These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change
missing-timeout,
superfluous-parens,
Expand Down
24 changes: 12 additions & 12 deletions src/azure-cli/azure/cli/command_modules/keyvault/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def get_model(x):
template = CertificatePolicy(
key_properties=KeyProperties(
exportable=True,
key_type=u'RSA',
key_type='RSA',
key_size=2048,
reuse_key=True
),
secret_properties=SecretProperties(
content_type=u'application/x-pkcs12'
content_type='application/x-pkcs12'
),
x509_certificate_properties=X509CertificateProperties(
key_usage=[
Expand All @@ -112,7 +112,7 @@ def get_model(x):
KeyUsageType.key_agreement,
KeyUsageType.key_cert_sign
],
subject=u'CN=CLIGetDefaultPolicy',
subject='CN=CLIGetDefaultPolicy',
validity_in_months=12
),
lifetime_actions=[LifetimeAction(
Expand All @@ -124,7 +124,7 @@ def get_model(x):
)
)],
issuer_parameters=IssuerParameters(
name=u'Self',
name='Self',
),
attributes=CertificateAttributes(
enabled=True
Expand Down Expand Up @@ -159,12 +159,12 @@ def get_model(x):
template = CertificatePolicy(
key_properties=KeyProperties(
exportable=True,
key_type=u'(optional) RSA or RSA-HSM (default RSA)',
key_type='(optional) RSA or RSA-HSM (default RSA)',
key_size=2048,
reuse_key=True
),
secret_properties=SecretProperties(
content_type=u'application/x-pkcs12 or application/x-pem-file'
content_type='application/x-pkcs12 or application/x-pem-file'
),
x509_certificate_properties=X509CertificateProperties(
key_usage=[
Expand All @@ -176,12 +176,12 @@ def get_model(x):
KeyUsageType.key_cert_sign
],
subject_alternative_names=SubjectAlternativeNames(
emails=[u'hello@contoso.com'],
dns_names=[u'hr.contoso.com', u'm.contoso.com'],
emails=['hello@contoso.com'],
dns_names=['hr.contoso.com', 'm.contoso.com'],
upns=[]
),
subject=u'C=US, ST=WA, L=Redmond, O=Contoso, OU=Contoso HR, CN=www.contoso.com',
ekus=[u'1.3.6.1.5.5.7.3.1'],
subject='C=US, ST=WA, L=Redmond, O=Contoso, OU=Contoso HR, CN=www.contoso.com',
ekus=['1.3.6.1.5.5.7.3.1'],
validity_in_months=24
),
lifetime_actions=[LifetimeAction(
Expand All @@ -193,8 +193,8 @@ def get_model(x):
)
)],
issuer_parameters=IssuerParameters(
name=u'Unknown, Self, or {IssuerName}',
certificate_type=u'(optional) DigiCert, GlobalSign or WoSign'
name='Unknown, Self, or {IssuerName}',
certificate_type='(optional) DigiCert, GlobalSign or WoSign'
),
attributes=CertificateAttributes(
enabled=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,11 @@ def _generate_certificate(path, keyfile=None, password=None):
# Various details about who we are. For a self-signed certificate the
# Subject and issuer are always the same.
subject = issuer = x509.Name([
x509.NameAttribute(NameOID.COUNTRY_NAME, u'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, u'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, u'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, u"My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, u"mysite.com")])
x509.NameAttribute(NameOID.COUNTRY_NAME, 'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, 'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, 'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, "mysite.com")])

cert = x509.CertificateBuilder().subject_name(subject) \
.issuer_name(issuer) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,11 @@ def _generate_certificate(path, keyfile=None, password=None):
# Various details about who we are. For a self-signed certificate the
# Subject and issuer are always the same.
subject = issuer = x509.Name([
x509.NameAttribute(NameOID.COUNTRY_NAME, u'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, u'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, u'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, u"My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, u"mysite.com")])
x509.NameAttribute(NameOID.COUNTRY_NAME, 'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, 'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, 'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, "mysite.com")])

cert = x509.CertificateBuilder().subject_name(subject) \
.issuer_name(issuer) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2265,11 +2265,11 @@ def _generate_certificate(path, keyfile=None, password=None):
# Various details about who we are. For a self-signed certificate the
# Subject and issuer are always the same.
subject = issuer = x509.Name([
x509.NameAttribute(NameOID.COUNTRY_NAME, u'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, u'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, u'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, u"My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, u"mysite.com")])
x509.NameAttribute(NameOID.COUNTRY_NAME, 'US'),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, 'WA'),
x509.NameAttribute(NameOID.LOCALITY_NAME, 'Redmond'),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "My Company"),
x509.NameAttribute(NameOID.COMMON_NAME, "mysite.com")])

cert = x509.CertificateBuilder().subject_name(subject) \
.issuer_name(issuer) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
List,
)

try:
from urllib import quote # type: ignore
except ImportError:
from urllib.parse import quote
from urllib.parse import quote
import xml.etree.ElementTree as ET

import isodate # type: ignore
Expand Down Expand Up @@ -931,13 +928,6 @@ def serialize_unicode(cls, data):
except AttributeError:
pass

try:
if isinstance(data, unicode): # type: ignore
# Don't change it, JSON and XML ElementTree are totally able
# to serialize correctly u'' strings
return data
except NameError:
return str(data)
return str(data)

def serialize_iter(self, data, iter_type, div=None, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing.io import TextIO
from typing import TextIO


def serializedATN():
Expand Down Expand Up @@ -135,7 +132,7 @@ class AutoscaleConditionLexer(Lexer):
NEWLINE = 25
WORD = 26

channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]

modeNames = [ "DEFAULT_MODE" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing.io import TextIO
from typing import TextIO


def serializedATN():
Expand Down Expand Up @@ -167,7 +164,7 @@ class MetricAlertConditionLexer(Lexer):
NEWLINE = 29
WORD = 30

channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]

modeNames = [ "DEFAULT_MODE" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ class NetworkAppGatewayNoWaitScenarioTest(ScenarioTest):
def test_network_app_gateway_no_wait(self, resource_group):

self.kwargs.update({
'tags': {u'a': u'b', u'c': u'd'}
'tags': {'a': 'b', 'c': 'd'}
})

self.cmd('network application-gateway create -g {rg} -n ag1 --no-wait --connection-draining-timeout 180 --priority 1001', checks=self.is_empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def test_tag_scenario(self):
self.cmd('tag add-value -n {tag} --value test')
self.cmd('tag add-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test', u'test2']))
checks=self.check('[].values[].tagValue', ['test', 'test2']))
self.cmd('tag remove-value -n {tag} --value test')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test2']))
checks=self.check('[].values[].tagValue', ['test2']))
self.cmd('tag remove-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', []))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ def test_deployment_prompt_file_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_file_order = ["[u'secureParam', u'boolParam', u'enumParam', u'arrayParam', u'objectParam']",
"['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
param_file_order = ["['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
results = _prompt_for_parameters(missing_parameters, fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_file_order)

Expand All @@ -343,8 +342,7 @@ def test_deployment_prompt_alphabetical_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_alpha_order = ["[u'arrayParam', u'boolParam', u'enumParam', u'objectParam', u'secureParam']",
"['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
param_alpha_order = ["['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
results = _prompt_for_parameters(dict(missing_parameters), fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_alpha_order)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ def test_tag_scenario(self):
self.cmd('tag add-value -n {tag} --value test')
self.cmd('tag add-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test', u'test2']))
checks=self.check('[].values[].tagValue', ['test', 'test2']))
self.cmd('tag remove-value -n {tag} --value test')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test2']))
checks=self.check('[].values[].tagValue', ['test2']))
self.cmd('tag remove-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', []))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ def test_deployment_prompt_file_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_file_order = ["[u'secureParam', u'boolParam', u'enumParam', u'arrayParam', u'objectParam']",
"['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
param_file_order = ["['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
results = _prompt_for_parameters(missing_parameters, fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_file_order)

Expand All @@ -347,8 +346,7 @@ def test_deployment_prompt_alphabetical_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_alpha_order = ["[u'arrayParam', u'boolParam', u'enumParam', u'objectParam', u'secureParam']",
"['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
param_alpha_order = ["['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
results = _prompt_for_parameters(dict(missing_parameters), fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_alpha_order)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ def test_tag_scenario(self):
self.cmd('tag add-value -n {tag} --value test')
self.cmd('tag add-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test', u'test2']))
checks=self.check('[].values[].tagValue', ['test', 'test2']))
self.cmd('tag remove-value -n {tag} --value test')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', [u'test2']))
checks=self.check('[].values[].tagValue', ['test2']))
self.cmd('tag remove-value -n {tag} --value test2')
self.cmd('tag list --query "[?tagName == \'{tag}\']"',
checks=self.check('[].values[].tagValue', []))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def test_deployment_prompt_file_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_file_order = ["[u'secureParam', u'boolParam', u'enumParam', u'arrayParam', u'objectParam']",
"['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
param_file_order = ["['secureParam', 'boolParam', 'enumParam', 'arrayParam', 'objectParam']"]
results = _prompt_for_parameters(missing_parameters, fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_file_order)

Expand All @@ -406,8 +405,7 @@ def test_deployment_prompt_alphabetical_order(self):
result_parameters = _process_parameters(template, parameter_list)
missing_parameters = _find_missing_parameters(result_parameters, template)

param_alpha_order = ["[u'arrayParam', u'boolParam', u'enumParam', u'objectParam', u'secureParam']",
"['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
param_alpha_order = ["['arrayParam', 'boolParam', 'enumParam', 'objectParam', 'secureParam']"]
results = _prompt_for_parameters(dict(missing_parameters), fail_on_no_tty=False)
self.assertTrue(str(list(results.keys())) in param_alpha_order)

Expand Down

0 comments on commit d2cd62b

Please sign in to comment.