comparison mercurial/pycompat.py @ 44452:9d2b2df2c2ba

cleanup: run pyupgrade on our source tree to clean up varying things Built with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**' | xargs pyupgrade --keep-percent-format --keep-extraneous-parens and then blackened. pyupgrade comes from https://github.com/asottile/pyupgrade with a patch to let me preserve extraneous parens (which we use for marking strings that shouldn't be translated), and lets us clean up a bunch of idioms that have cruftily accumulated over the years. # skip-blame no-op automated code cleanups Differential Revision: https://phab.mercurial-scm.org/D8255
author Augie Fackler <augie@google.com>
date Fri, 06 Mar 2020 13:27:41 -0500
parents 66af68d4c751
children 00e0c5c06ed5
comparison
equal deleted inserted replaced
44449:ff72bd52d56a 44452:9d2b2df2c2ba
332 """ 332 """
333 Converts the keys of a python dictonary to str i.e. unicodes so that 333 Converts the keys of a python dictonary to str i.e. unicodes so that
334 they can be passed as keyword arguments as dictonaries with bytes keys 334 they can be passed as keyword arguments as dictonaries with bytes keys
335 can't be passed as keyword arguments to functions on Python 3. 335 can't be passed as keyword arguments to functions on Python 3.
336 """ 336 """
337 dic = dict((k.decode('latin-1'), v) for k, v in dic.items()) 337 dic = {k.decode('latin-1'): v for k, v in dic.items()}
338 return dic 338 return dic
339 339
340 def byteskwargs(dic): 340 def byteskwargs(dic):
341 """ 341 """
342 Converts keys of python dictonaries to bytes as they were converted to 342 Converts keys of python dictonaries to bytes as they were converted to
343 str to pass that dictonary as a keyword argument on Python 3. 343 str to pass that dictonary as a keyword argument on Python 3.
344 """ 344 """
345 dic = dict((k.encode('latin-1'), v) for k, v in dic.items()) 345 dic = {k.encode('latin-1'): v for k, v in dic.items()}
346 return dic 346 return dic
347 347
348 # TODO: handle shlex.shlex(). 348 # TODO: handle shlex.shlex().
349 def shlexsplit(s, comments=False, posix=True): 349 def shlexsplit(s, comments=False, posix=True):
350 """ 350 """