Remove extraneous list casting

This commit is contained in:
Travis Ralston 2018-07-10 16:52:17 -06:00
parent 9e0fafbcd4
commit ebc7db12fb
9 changed files with 27 additions and 27 deletions

View file

@ -24,7 +24,7 @@ class AccessKeyStore(object):
self.accessed_set = set()
def keys(self):
return list(self.data.keys())
return self.data.keys()
def add(self, key, unit_dict):
self.data[key] = unit_dict

View file

@ -54,7 +54,7 @@ class Sections(object):
)
elif isinstance(section, dict):
self.log(" Generated multiple sections:")
for (k, v) in list(section.items()):
for (k, v) in section.items():
if not isinstance(k, str) or not isinstance(v, str):
raise Exception(
("Method %s returned multiple sections as a dict but " +

View file

@ -169,7 +169,7 @@ def main(input_module, files=None, out_dir=None, verbose=False, substitutions={}
# print out valid section keys if no file supplied
if not files:
print("\nValid template variables:")
for key in list(sections.keys()):
for key in sections.keys():
sec_text = "" if (len(sections[key]) > 75) else (
"(Value: '%s')" % sections[key]
)
@ -211,7 +211,7 @@ def process_file(env, sections, filename, output_filename):
# Do these substitutions outside of the ordinary templating system because
# we want them to apply to things like the underlying swagger used to
# generate the templates, not just the top-level sections.
for old, new in list(substitutions.items()):
for old, new in substitutions.items():
output = output.replace(old, new)
with open(output_filename, "wb") as f:

View file

@ -86,7 +86,7 @@ class MatrixSections(Sections):
# the key is the section name and the value is the value of the section
def render_group_http_apis(self):
# map all swagger_apis to the form $GROUP_http_api
swagger_groups = list(self.units.get("swagger_apis").keys())
swagger_groups = self.units.get("swagger_apis").keys()
renders = {}
for group in swagger_groups:
sortFnOrPathList = None
@ -134,7 +134,7 @@ class MatrixSections(Sections):
"m.room.message#m.file"
]
other_msgtypes = [
k for k in list(schemas.keys()) if k.startswith("m.room.message#") and
k for k in schemas.keys() if k.startswith("m.room.message#") and
k not in msgtype_order
]
for event_name in (msgtype_order + other_msgtypes):

View file

@ -35,7 +35,7 @@ from functools import reduce
from six.moves.urllib.parse import urlencode
matrix_doc_dir=reduce(lambda acc,_: os.path.dirname(acc),
list(range(1, 5)), os.path.abspath(__file__))
range(1, 5), os.path.abspath(__file__))
HTTP_APIS = {
os.path.join(matrix_doc_dir, "api/application-service"): "as",
@ -126,7 +126,7 @@ def resolve_references(path, schema):
else:
result = OrderedDict()
for key, value in list(schema.items()):
for key, value in schema.items():
result[key] = resolve_references(path, value)
return result
elif isinstance(schema, list):
@ -211,7 +211,7 @@ def get_json_schema_object_fields(obj, enforce_title=False):
props = obj.get("patternProperties")
if props:
# try to replace horrible regex key names with pretty x-pattern ones
for key_name in list(props.keys()):
for key_name in props.keys():
pretty_key = props[key_name].get("x-pattern")
if pretty_key:
props[pretty_key] = props[key_name]
@ -382,7 +382,7 @@ def get_example_for_schema(schema):
if 'properties' not in schema:
raise Exception('"object" property has neither properties nor example')
res = OrderedDict()
for prop_name, prop in list(schema['properties'].items()):
for prop_name, prop in schema['properties'].items():
logger.debug("Parsing property %r" % prop_name)
prop_example = get_example_for_schema(prop)
res[prop_name] = prop_example
@ -558,7 +558,7 @@ class MatrixUnits(Units):
)
if "headers" in good_response:
headers = TypeTable()
for (header_name, header) in list(good_response["headers"].items()):
for (header_name, header) in good_response["headers"].items():
headers.add_row(
TypeTableRow(key=header_name, title=header["type"],
desc=header["description"]),
@ -617,7 +617,7 @@ class MatrixUnits(Units):
def load_swagger_apis(self):
apis = {}
for path, suffix in list(HTTP_APIS.items()):
for path, suffix in HTTP_APIS.items():
for filename in os.listdir(path):
if not filename.endswith(".yaml"):
continue