diff --git a/.venv/Lib/site-packages/_plotly_utils/basevalidators.py b/.venv/Lib/site-packages/_plotly_utils/basevalidators.py index 4685ed72..76104054 100644 --- a/.venv/Lib/site-packages/_plotly_utils/basevalidators.py +++ b/.venv/Lib/site-packages/_plotly_utils/basevalidators.py @@ -18,10 +18,7 @@ # back-port of fullmatch from Py3.4+ def fullmatch(regex, string, flags=0): """Emulate python-3.4 re.fullmatch().""" - if "pattern" in dir(regex): - regex_string = regex.pattern - else: - regex_string = regex + regex_string = regex.pattern if "pattern" in dir(regex) else regex return re.match("(?:" + regex_string + r")\Z", string, flags=flags) @@ -181,10 +178,7 @@ def is_homogeneous_array(v): if np: v_numpy = np.array(v) # v is essentially a scalar and so shouldn't count as an array - if v_numpy.shape == (): - return False - else: - return True + return v_numpy.shape != () return False @@ -788,9 +782,8 @@ def validate_coerce(self, v): self.raise_invalid_val(v) # Check min/max - if self.has_min_max: - if not (self.min_val <= v <= self.max_val): - self.raise_invalid_val(v) + if self.has_min_max and not (self.min_val <= v <= self.max_val): + self.raise_invalid_val(v) return v @@ -918,9 +911,8 @@ def validate_coerce(self, v): self.raise_invalid_val(v) # Check min/max - if self.has_min_max: - if not (self.min_val <= v <= self.max_val): - self.raise_invalid_val(v) + if self.has_min_max and not (self.min_val <= v <= self.max_val): + self.raise_invalid_val(v) return v @@ -1073,18 +1065,18 @@ def validate_coerce(self, v): v = to_scalar_or_list(v) else: - if self.strict: - if not isinstance(v, string_types): - self.raise_invalid_val(v) - else: - if isinstance(v, string_types): - pass - elif isinstance(v, (int, float)): - # Convert value to a string - v = str(v) - else: - self.raise_invalid_val(v) - + if ( + self.strict + and not isinstance(v, string_types) + or not isinstance(v, string_types) + and not isinstance(v, (int, float)) + ): + self.raise_invalid_val(v) + elif self.strict: + pass + elif not isinstance(v, string_types): + # Convert value to a string + v = str(v) if self.no_blank and len(v) == 0: self.raise_invalid_val(v) @@ -1555,7 +1547,7 @@ def description(self): ) ) - desc = """\ + return """\ The '{plotly_name}' property is a colorscale and may be specified as: - A list of colors that will be spaced evenly to create the colorscale. @@ -1572,8 +1564,6 @@ def description(self): plotly_name=self.plotly_name, colorscales_str=colorscales_str ) - return desc - def validate_coerce(self, v): v_valid = False @@ -1601,7 +1591,7 @@ def validate_coerce(self, v): e for e in v if ColorValidator.perform_validate_coerce(e) is None ] - if len(invalid_els) == 0: + if not invalid_els: v_valid = True # Convert to list of lists colorscale @@ -1621,7 +1611,7 @@ def validate_coerce(self, v): ) ] - if len(invalid_els) == 0: + if not invalid_els: v_valid = True # Convert to list of lists @@ -1641,7 +1631,7 @@ def present(self, v): elif isinstance(v, string_types): return v else: - return tuple([tuple(e) for e in v]) + return tuple(tuple(e) for e in v) class AngleValidator(BaseValidator): @@ -1661,7 +1651,7 @@ def __init__(self, plotly_name, parent_name, **kwargs): ) def description(self): - desc = """\ + return """\ The '{plotly_name}' property is a angle (in degrees) that may be specified as a number between -180 and 180. Numeric values outside this range are converted to the equivalent value @@ -1670,8 +1660,6 @@ def description(self): plotly_name=self.plotly_name ) - return desc - def validate_coerce(self, v): if v is None: # Pass None through @@ -1720,7 +1708,7 @@ def __init__(self, plotly_name, parent_name, dflt=None, regex=None, **kwargs): def description(self): - desc = """\ + return """\ The '{plotly_name}' property is an identifier of a particular subplot, of type '{base}', that may be specified as the string '{base}' optionally followed by an integer >= 1 @@ -1728,7 +1716,6 @@ def description(self): """.format( plotly_name=self.plotly_name, base=self.base ) - return desc def validate_coerce(self, v): if v is None: @@ -1833,10 +1820,10 @@ def vc_scalar(self, v): split_vals = [e.strip() for e in re.split("[,+]", v)] # Are all flags valid names? - all_flags_valid = all([f in self.all_flags for f in split_vals]) + all_flags_valid = all(f in self.all_flags for f in split_vals) # Are any 'extras' flags present? - has_extras = any([f in self.extras for f in split_vals]) + has_extras = any(f in self.extras for f in split_vals) # For flaglist to be valid all flags must be valid, and if we have # any extras present, there must be only one flag (the single extras @@ -1899,12 +1886,11 @@ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwar def description(self): - desc = """\ + return """\ The '{plotly_name}' property accepts values of any type """.format( plotly_name=self.plotly_name ) - return desc def validate_coerce(self, v): if v is None: @@ -1946,7 +1932,7 @@ def __init__( ) self.items = items - self.dimensions = dimensions if dimensions else 1 + self.dimensions = dimensions or 1 self.free_length = free_length # Instantiate validators for each info array element @@ -2329,7 +2315,7 @@ def __init__(self, plotly_name, parent_name, **kwargs): def description(self): - desc = """\ + return """\ The '{plotly_name}' property is an image URI that may be specified as: - A remote image URI string (e.g. 'http://www.somewhere.com/image.png') @@ -2341,7 +2327,6 @@ def description(self): """.format( plotly_name=self.plotly_name ) - return desc def validate_coerce(self, v): if v is None: @@ -2423,7 +2408,7 @@ def data_class(self): def description(self): - desc = ( + return ( """\ The '{plotly_name}' property is an instance of {class_str} that may be specified as: @@ -2440,8 +2425,6 @@ def description(self): constructor_params_str=self.data_docs, ) - return desc - def validate_coerce(self, v, skip_invalid=False, _validate=True): if v is None: v = self.data_class() @@ -2500,7 +2483,7 @@ def __init__(self, plotly_name, parent_name, data_class_str, data_docs, **kwargs def description(self): - desc = ( + return ( """\ The '{plotly_name}' property is a tuple of instances of {class_str} that may be specified as: @@ -2517,8 +2500,6 @@ def description(self): constructor_params_str=self.data_docs, ) - return desc - @property def data_class(self): if self._data_class is None: @@ -2529,10 +2510,12 @@ def data_class(self): def validate_coerce(self, v, skip_invalid=False): - if v is None: + if not isinstance(v, (list, tuple)) and skip_invalid or v is None: v = [] + elif not isinstance(v, (list, tuple)): + self.raise_invalid_val(v) - elif isinstance(v, (list, tuple)): + else: res = [] invalid_els = [] for v_el in v: @@ -2551,12 +2534,6 @@ def validate_coerce(self, v, skip_invalid=False): self.raise_invalid_elements(invalid_els) v = to_scalar_or_list(res) - else: - if skip_invalid: - v = [] - else: - self.raise_invalid_val(v) - return v def present(self, v): @@ -2589,7 +2566,7 @@ def description(self): ) ) - desc = ( + return ( """\ The '{plotly_name}' property is a tuple of trace instances that may be specified as: @@ -2607,8 +2584,6 @@ def description(self): (e.g. [{{'type': 'scatter', ...}}, {{'type': 'bar, ...}}])""" ).format(plotly_name=self.plotly_name, trace_types=trace_types_wrapped) - return desc - def get_trace_class(self, trace_name): # Import trace classes if trace_name not in self._class_map: diff --git a/.venv/Lib/site-packages/_plotly_utils/colors/__init__.py b/.venv/Lib/site-packages/_plotly_utils/colors/__init__.py index b7669ce4..f6be15d0 100644 --- a/.venv/Lib/site-packages/_plotly_utils/colors/__init__.py +++ b/.venv/Lib/site-packages/_plotly_utils/colors/__init__.py @@ -300,12 +300,10 @@ def color_parser(colors, function): if hasattr(colors, "__iter__"): if isinstance(colors, tuple): - new_color_tuple = tuple(function(item) for item in colors) - return new_color_tuple + return tuple(function(item) for item in colors) else: - new_color_list = [function(item) for item in colors] - return new_color_list + return [function(item) for item in colors] def validate_colors(colors, colortype="tuple"): @@ -317,27 +315,29 @@ def validate_colors(colors, colortype="tuple"): if colors is None: colors = DEFAULT_PLOTLY_COLORS - if isinstance(colors, str): - if colors in PLOTLY_SCALES: - colors_list = colorscale_to_colors(PLOTLY_SCALES[colors]) - # TODO: fix _gantt.py/_scatter.py so that they can accept the - # actual colorscale and not just a list of the first and last - # color in the plotly colorscale. In resolving this issue we - # will be removing the immediate line below - colors = [colors_list[0]] + [colors_list[-1]] - elif "rgb" in colors or "#" in colors: - colors = [colors] - else: - raise exceptions.PlotlyError( - "If your colors variable is a string, it must be a " - "Plotly scale, an rgb color or a hex color." - ) + if isinstance(colors, str) and colors in PLOTLY_SCALES: + colors_list = colorscale_to_colors(PLOTLY_SCALES[colors]) + # TODO: fix _gantt.py/_scatter.py so that they can accept the + # actual colorscale and not just a list of the first and last + # color in the plotly colorscale. In resolving this issue we + # will be removing the immediate line below + colors = [colors_list[0]] + [colors_list[-1]] + elif ( + isinstance(colors, str) + and ("rgb" in colors or "#" in colors) + or not isinstance(colors, str) + and isinstance(colors, tuple) + and isinstance(colors[0], Number) + ): + colors = [colors] + elif isinstance(colors, str): + raise exceptions.PlotlyError( + "If your colors variable is a string, it must be a " + "Plotly scale, an rgb color or a hex color." + ) elif isinstance(colors, tuple): - if isinstance(colors[0], Number): - colors = [colors] - else: - colors = list(colors) + colors = list(colors) # convert color elements in list to tuple color for j, each_color in enumerate(colors): @@ -451,11 +451,7 @@ def convert_colors_to_same_type( colors_list = [colors] elif isinstance(colors, tuple): - if isinstance(colors[0], Number): - colors_list = [colors] - else: - colors_list = list(colors) - + colors_list = [colors] if isinstance(colors[0], Number) else list(colors) elif isinstance(colors, list): colors_list = colors @@ -545,7 +541,7 @@ def validate_scale_values(scale): "respectively." ) - if not all(x < y for x, y in zip(scale, scale[1:])): + if any(x >= y for x, y in zip(scale, scale[1:])): raise exceptions.PlotlyError( "'scale' must be a list that contains a strictly increasing " "sequence of numbers." @@ -728,17 +724,17 @@ def unlabel_rgb(colors): for index in range(len(colors)): try: float(colors[index]) - str_vals = str_vals + colors[index] + str_vals += colors[index] except ValueError: - if colors[index] == "," or colors[index] == ".": - str_vals = str_vals + colors[index] + if colors[index] in [",", "."]: + str_vals += colors[index] - str_vals = str_vals + "," + str_vals += "," numbers = [] str_num = "" for char in str_vals: if char != ",": - str_num = str_num + char + str_num += char else: numbers.append(float(str_num)) str_num = "" @@ -766,20 +762,14 @@ def colorscale_to_colors(colorscale): """ Extracts the colors from colorscale as a list """ - color_list = [] - for item in colorscale: - color_list.append(item[1]) - return color_list + return [item[1] for item in colorscale] def colorscale_to_scale(colorscale): """ Extracts the interpolation scale values from colorscale as a list """ - scale_list = [] - for item in colorscale: - scale_list.append(item[0]) - return scale_list + return [item[0] for item in colorscale] def convert_colorscale_to_rgb(colorscale): diff --git a/.venv/Lib/site-packages/_plotly_utils/data_utils.py b/.venv/Lib/site-packages/_plotly_utils/data_utils.py index 5fb05b03..cf02d59d 100644 --- a/.venv/Lib/site-packages/_plotly_utils/data_utils.py +++ b/.venv/Lib/site-packages/_plotly_utils/data_utils.py @@ -63,7 +63,7 @@ def image_array_to_data_uri(img, backend="pil", compression=4, ext="png"): "install pillow or use `backend='pypng'." ) pil_img = Image.fromarray(img) - if ext == "jpg" or ext == "jpeg": + if ext in ["jpg", "jpeg"]: prefix = "data:image/jpeg;base64," ext = "jpeg" else: diff --git a/.venv/Lib/site-packages/_plotly_utils/png.py b/.venv/Lib/site-packages/_plotly_utils/png.py index 55013903..5390a61c 100644 --- a/.venv/Lib/site-packages/_plotly_utils/png.py +++ b/.venv/Lib/site-packages/_plotly_utils/png.py @@ -811,18 +811,12 @@ def write_preamble(self, outfile): # http://www.w3.org/TR/PNG/#11tRNS if self.transparent is not None: - if self.greyscale: - fmt = "!1H" - else: - fmt = "!3H" + fmt = "!1H" if self.greyscale else "!3H" write_chunk(outfile, b"tRNS", struct.pack(fmt, *self.transparent)) # http://www.w3.org/TR/PNG/#11bKGD if self.background is not None: - if self.greyscale: - fmt = "!1H" - else: - fmt = "!3H" + fmt = "!1H" if self.greyscale else "!3H" write_chunk(outfile, b"bKGD", struct.pack(fmt, *self.background)) # http://www.w3.org/TR/PNG/#11pHYs @@ -859,7 +853,7 @@ def array_scanlines(self, pixels): # Values per row vpr = self.width * self.planes stop = 0 - for y in range(self.height): + for _ in range(self.height): start = stop stop = start + vpr yield pixels[start:stop] @@ -944,7 +938,7 @@ def rescale_rows(rows, rescale): fs = [float(2 ** s[1] - 1) / float(2 ** s[0] - 1) for s in rescale] # Assume all target_bitdepths are the same - target_bitdepths = set(s[1] for s in rescale) + target_bitdepths = {s[1] for s in rescale} assert len(target_bitdepths) == 1 (target_bitdepth,) = target_bitdepths typecode = "BH"[target_bitdepth > 8] @@ -1171,15 +1165,13 @@ def from_array(a, mode=None, info={}): bitdepth = int(bitdepth) # Colour format. - if "greyscale" in info: - if bool(info["greyscale"]) != ("L" in mode): - raise ProtocolError("info['greyscale'] should match mode.") + if "greyscale" in info and bool(info["greyscale"]) != ("L" in mode): + raise ProtocolError("info['greyscale'] should match mode.") info["greyscale"] = "L" in mode alpha = "A" in mode - if "alpha" in info: - if bool(info["alpha"]) != alpha: - raise ProtocolError("info['alpha'] should match mode.") + if "alpha" in info and bool(info["alpha"]) != alpha: + raise ProtocolError("info['alpha'] should match mode.") info["alpha"] = alpha # Get bitdepth from *mode* if possible. @@ -1206,9 +1198,8 @@ def from_array(a, mode=None, info={}): raise ProtocolError("len(a) does not work, supply info['height'] instead.") planes = len(mode) - if "planes" in info: - if info["planes"] != planes: - raise Error("info['planes'] should match mode.") + if "planes" in info and info["planes"] != planes: + raise Error("info['planes'] should match mode.") # In order to work out whether we the array is 2D or 3D we need its # first row, which requires that we take a copy of its iterator. @@ -1237,10 +1228,7 @@ def from_array(a, mode=None, info={}): else: # If we got here without exception, # we now assume that the array is a numpy array. - if dtype.kind == "b": - bitdepth = 1 - else: - bitdepth = 8 * dtype.itemsize + bitdepth = 1 if dtype.kind == "b" else 8 * dtype.itemsize info["bitdepth"] = bitdepth for thing in ["width", "height", "bitdepth", "greyscale", "alpha"]: @@ -1483,10 +1471,7 @@ def _deinterlace(self, raw): # Interleaving writes to the output array randomly # (well, not quite), so the entire output array must be in memory. # Make a result array, and make it big enough. - if self.bitdepth > 8: - a = array("H", [0] * vpi) - else: - a = bytearray([0] * vpi) + a = array("H", [0] * vpi) if self.bitdepth > 8 else bytearray([0] * vpi) source_offset = 0 for lines in adam7_generate(self.width, self.height): @@ -1802,10 +1787,12 @@ def iteridat(): """Iterator that yields all the ``IDAT`` chunks as strings.""" while True: type, data = self.chunk(lenient=lenient) - if type == b"IEND": + if type == b"IDAT": + pass + elif type == b"IEND": # http://www.w3.org/TR/PNG/#11IEND break - if type != b"IDAT": + else: continue # type == b'IDAT' # http://www.w3.org/TR/PNG/#11IDAT @@ -2229,15 +2216,13 @@ def is_natural(x): def undo_filter_sub(filter_unit, scanline, previous, result): """Undo sub filter.""" - ai = 0 # Loops starts at index fu. Observe that the initial part # of the result is already filled in correctly with # scanline. - for i in range(filter_unit, len(result)): + for ai, i in enumerate(range(filter_unit, len(result))): x = scanline[i] a = result[ai] result[i] = (x + a) & 0xFF - ai += 1 def undo_filter_up(filter_unit, scanline, previous, result): @@ -2255,10 +2240,7 @@ def undo_filter_average(filter_unit, scanline, previous, result): ai = -filter_unit for i in range(len(result)): x = scanline[i] - if ai < 0: - a = 0 - else: - a = result[ai] + a = 0 if ai < 0 else result[ai] b = previous[i] result[i] = (x + ((a + b) >> 1)) & 0xFF ai += 1 diff --git a/.venv/Lib/site-packages/_plotly_utils/utils.py b/.venv/Lib/site-packages/_plotly_utils/utils.py index 00351e1c..23cf1978 100644 --- a/.venv/Lib/site-packages/_plotly_utils/utils.py +++ b/.venv/Lib/site-packages/_plotly_utils/utils.py @@ -61,7 +61,7 @@ def encode(self, o): # We catch false positive cases (e.g. strings such as titles, labels etc.) # but this is ok since the intention is to skip the decoding / reencoding # step when it's completely safe - if not ("NaN" in encoded_o or "Infinity" in encoded_o): + if "NaN" not in encoded_o and "Infinity" not in encoded_o: return encoded_o # now: # 1. `loads` to switch Infinity, -Infinity, NaN to None @@ -246,9 +246,8 @@ def iso_to_plotly_time_string(iso_string): def template_doc(**names): def _decorator(func): - if not sys.version_info[:2] == (3, 2): - if func.__doc__ is not None: - func.__doc__ = func.__doc__.format(**names) + if sys.version_info[:2] != (3, 2) and func.__doc__ is not None: + func.__doc__ = func.__doc__.format(**names) return func return _decorator @@ -270,11 +269,7 @@ def key(v): def _get_int_type(): np = get_module("numpy", should_load=False) - if np: - int_type = (int, np.integer) - else: - int_type = (int,) - return int_type + return (int, np.integer) if np else (int, ) def split_multichar(ss, chars): diff --git a/.venv/Lib/site-packages/pip/_internal/build_env.py b/.venv/Lib/site-packages/pip/_internal/build_env.py index 28d1ad68..b4969236 100644 --- a/.venv/Lib/site-packages/pip/_internal/build_env.py +++ b/.venv/Lib/site-packages/pip/_internal/build_env.py @@ -39,10 +39,7 @@ def __init__(self, path): # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) - if purelib == platlib: - self.lib_dirs = [purelib] - else: - self.lib_dirs = [purelib, platlib] + self.lib_dirs = [purelib] if purelib == platlib else [purelib, platlib] class BuildEnvironment(object): diff --git a/.venv/Lib/site-packages/pip/_internal/cli/autocompletion.py b/.venv/Lib/site-packages/pip/_internal/cli/autocompletion.py index 329de602..e812e647 100644 --- a/.venv/Lib/site-packages/pip/_internal/cli/autocompletion.py +++ b/.venv/Lib/site-packages/pip/_internal/cli/autocompletion.py @@ -125,11 +125,14 @@ def get_path_completion_type(cwords, cword, opts): if opt.help == optparse.SUPPRESS_HELP: continue for o in str(opt).split('/'): - if cwords[cword - 2].split('=')[0] == o: - if not opt.metavar or any( - x in ('path', 'file', 'dir') - for x in opt.metavar.split('/')): - return opt.metavar + if cwords[cword - 2].split('=')[0] == o and ( + not opt.metavar + or any( + x in ('path', 'file', 'dir') + for x in opt.metavar.split('/') + ) + ): + return opt.metavar return None diff --git a/.venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py b/.venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py index ed42c5f5..cd6d987f 100644 --- a/.venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py +++ b/.venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py @@ -119,12 +119,11 @@ def check_dist_restriction(options, check_target=False): ":none:)." ) - if check_target: - if dist_restriction_set and not options.target_dir: - raise CommandError( - "Can not use any platform or abi specific options unless " - "installing via '--target'" - ) + if check_target and dist_restriction_set and not options.target_dir: + raise CommandError( + "Can not use any platform or abi specific options unless " + "installing via '--target'" + ) def _path_option_check(option, opt, value): diff --git a/.venv/Lib/site-packages/pip/_internal/cli/parser.py b/.venv/Lib/site-packages/pip/_internal/cli/parser.py index 04e00b72..d0d17442 100644 --- a/.venv/Lib/site-packages/pip/_internal/cli/parser.py +++ b/.venv/Lib/site-packages/pip/_internal/cli/parser.py @@ -66,27 +66,22 @@ def format_usage(self, usage): Ensure there is only one newline between usage and the first heading if there is no description. """ - msg = '\nUsage: {}\n'.format( + return '\nUsage: {}\n'.format( self.indent_lines(textwrap.dedent(usage), " ")) - return msg def format_description(self, description): # leave full control over description to us - if description: - if hasattr(self.parser, 'main'): - label = 'Commands' - else: - label = 'Description' - # some doc strings have initial newlines, some don't - description = description.lstrip('\n') - # some doc strings have final newlines and spaces, some don't - description = description.rstrip() - # dedent, then reindent - description = self.indent_lines(textwrap.dedent(description), " ") - description = '{}:\n{}\n'.format(label, description) - return description - else: + if not description: return '' + label = 'Commands' if hasattr(self.parser, 'main') else 'Description' + # some doc strings have initial newlines, some don't + description = description.lstrip('\n') + # some doc strings have final newlines and spaces, some don't + description = description.rstrip() + # dedent, then reindent + description = self.indent_lines(textwrap.dedent(description), " ") + description = '{}:\n{}\n'.format(label, description) + return description def format_epilog(self, epilog): # leave full control over epilog to us @@ -175,8 +170,7 @@ def _get_ordered_configuration_items(self): # Yield each group in their override order for section in override_order: - for key, val in section_items[section]: - yield key, val + yield from section_items[section] def _update_defaults(self, defaults): """Updates the given defaults with values from the config files and diff --git a/.venv/Lib/site-packages/pip/_internal/commands/__init__.py b/.venv/Lib/site-packages/pip/_internal/commands/__init__.py index 6825fa6e..fdec5bb2 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/__init__.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/__init__.py @@ -103,9 +103,7 @@ def create_command(name, **kwargs): module_path, class_name, summary = commands_dict[name] module = importlib.import_module(module_path) command_class = getattr(module, class_name) - command = command_class(name=name, summary=summary, **kwargs) - - return command + return command_class(name=name, summary=summary, **kwargs) def get_similar_commands(name): diff --git a/.venv/Lib/site-packages/pip/_internal/commands/cache.py b/.venv/Lib/site-packages/pip/_internal/commands/cache.py index 747277f6..8d7f9966 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/cache.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/cache.py @@ -110,11 +110,7 @@ def list_cache_items(self, options, args): if len(args) > 1: raise CommandError('Too many arguments') - if args: - pattern = args[0] - else: - pattern = '*' - + pattern = args[0] if args else '*' files = self._find_wheels(options, pattern) if not files: diff --git a/.venv/Lib/site-packages/pip/_internal/commands/check.py b/.venv/Lib/site-packages/pip/_internal/commands/check.py index b557ca64..46faa3eb 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/check.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/check.py @@ -46,6 +46,5 @@ def run(self, options, args): if missing or conflicting or parsing_probs: return ERROR - else: - write_output("No broken requirements found.") - return SUCCESS + write_output("No broken requirements found.") + return SUCCESS diff --git a/.venv/Lib/site-packages/pip/_internal/commands/completion.py b/.venv/Lib/site-packages/pip/_internal/commands/completion.py index 9b99f51f..568db9c2 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/completion.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/completion.py @@ -90,9 +90,9 @@ def run(self, options, args): prog=get_prog()) ) print(BASE_COMPLETION.format(script=script, shell=options.shell)) - return SUCCESS else: sys.stderr.write( 'ERROR: You must pass {}\n' .format(' or '.join(shell_options)) ) - return SUCCESS + + return SUCCESS diff --git a/.venv/Lib/site-packages/pip/_internal/commands/debug.py b/.venv/Lib/site-packages/pip/_internal/commands/debug.py index ff369d7d..2959be62 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/debug.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/debug.py @@ -163,10 +163,7 @@ def show_tags(options): def ca_bundle_info(config): # type: (Configuration) -> str - levels = set() - for key, _ in config.items(): - levels.add(key.split('.')[0]) - + levels = {key.split('.')[0] for key, _ in config.items()} if not levels: return "Not specified" diff --git a/.venv/Lib/site-packages/pip/_internal/commands/list.py b/.venv/Lib/site-packages/pip/_internal/commands/list.py index 20e9bff2..581507d3 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/list.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/list.py @@ -216,10 +216,7 @@ def latest_info(dist): return None remote_version = best_candidate.version - if best_candidate.link.is_wheel: - typ = 'wheel' - else: - typ = 'sdist' + typ = 'wheel' if best_candidate.link.is_wheel else 'sdist' # This is dirty but makes the rest of the code much cleaner dist.latest_version = remote_version dist.latest_filetype = typ diff --git a/.venv/Lib/site-packages/pip/_internal/commands/search.py b/.venv/Lib/site-packages/pip/_internal/commands/search.py index ff094720..e8ffc0e2 100644 --- a/.venv/Lib/site-packages/pip/_internal/commands/search.py +++ b/.venv/Lib/site-packages/pip/_internal/commands/search.py @@ -77,8 +77,7 @@ def search(self, query, options): transport = PipXmlrpcTransport(index_url, session) pypi = xmlrpc_client.ServerProxy(index_url, transport) - hits = pypi.search({'name': query, 'summary': query}, 'or') - return hits + return pypi.search({'name': query, 'summary': query}, 'or') def transform_hits(hits): @@ -115,10 +114,15 @@ def print_results(hits, name_column_width=None, terminal_width=None): if not hits: return if name_column_width is None: - name_column_width = max([ - len(hit['name']) + len(highest_version(hit.get('versions', ['-']))) - for hit in hits - ]) + 4 + name_column_width = ( + max( + len(hit['name']) + + len(highest_version(hit.get('versions', ['-']))) + for hit in hits + ) + + 4 + ) + installed_packages = [p.project_name for p in pkg_resources.working_set] for hit in hits: diff --git a/.venv/Lib/site-packages/pip/_internal/index/collector.py b/.venv/Lib/site-packages/pip/_internal/index/collector.py index 6c35fc66..7e0cebdc 100644 --- a/.venv/Lib/site-packages/pip/_internal/index/collector.py +++ b/.venv/Lib/site-packages/pip/_internal/index/collector.py @@ -84,10 +84,7 @@ def _is_url_like_archive(url): """Return whether the URL looks like an archive. """ filename = Link(url).filename - for bad_ext in ARCHIVE_EXTENSIONS: - if filename.endswith(bad_ext): - return True - return False + return any(filename.endswith(bad_ext) for bad_ext in ARCHIVE_EXTENSIONS) class _NotHTML(Exception): @@ -244,11 +241,7 @@ def _clean_url_path(path, is_local_path): """ Clean the path portion of a URL. """ - if is_local_path: - clean_func = _clean_file_url_path - else: - clean_func = _clean_url_path_part - + clean_func = _clean_file_url_path if is_local_path else _clean_url_path_part # Split on the reserved characters prior to cleaning so that # revision strings in VCS URLs are properly preserved. parts = _reserved_chars_re.split(path) @@ -300,15 +293,13 @@ def _create_link_from_element( # This is a unicode string in Python 2 (and 3). yanked_reason = unescape(yanked_reason) - link = Link( + return Link( url, comes_from=page_url, requires_python=pyrequire, yanked_reason=yanked_reason, ) - return link - class CacheablePageContent(object): def __init__(self, page): @@ -625,10 +616,9 @@ def create(cls, session, options, suppress_no_index=False): search_scope = SearchScope.create( find_links=find_links, index_urls=index_urls, ) - link_collector = LinkCollector( + return LinkCollector( session=session, search_scope=search_scope, ) - return link_collector @property def find_links(self): diff --git a/.venv/Lib/site-packages/pip/_internal/index/package_finder.py b/.venv/Lib/site-packages/pip/_internal/index/package_finder.py index 84115783..43312b5f 100644 --- a/.venv/Lib/site-packages/pip/_internal/index/package_finder.py +++ b/.venv/Lib/site-packages/pip/_internal/index/package_finder.py @@ -289,12 +289,7 @@ def filter_unallowed_hashes( matches_or_no_digest.append(candidate) - if match_count: - filtered = matches_or_no_digest - else: - # Make sure we're not returning back the given value. - filtered = list(candidates) - + filtered = matches_or_no_digest if match_count else list(candidates) if len(filtered) == len(candidates): discard_message = 'discarding no candidates' else: @@ -517,7 +512,6 @@ def _sort_key(self, candidate): with the same version, would have to be considered equal """ valid_tags = self._supported_tags - support_num = len(valid_tags) build_tag = () # type: BuildTag binary_preference = 0 link = candidate.link @@ -537,6 +531,7 @@ def _sort_key(self, candidate): build_tag_groups = match.groups() build_tag = (int(build_tag_groups[0]), build_tag_groups[1]) else: # sdist + support_num = len(valid_tags) pri = -(support_num) has_allowed_hash = int(link.is_hash_allowed(self._hashes)) yank_value = -1 * int(link.is_yanked) # -1 for yanked. @@ -556,8 +551,7 @@ def sort_best_candidate( """ if not candidates: return None - best_candidate = max(candidates, key=self._sort_key) - return best_candidate + return max(candidates, key=self._sort_key) def compute_best_candidate( self, @@ -835,12 +829,12 @@ def find_all_candidates(self, project_name): file_versions.sort(reverse=True) logger.debug( 'Local files found: %s', - ', '.join([ - url_to_path(candidate.link.url) - for candidate in file_versions - ]) + ', '.join( + url_to_path(candidate.link.url) for candidate in file_versions + ), ) + # This is an intentional priority ordering return file_versions + find_links_versions + page_versions diff --git a/.venv/Lib/site-packages/pip/_internal/locations.py b/.venv/Lib/site-packages/pip/_internal/locations.py index 0c123548..40948f3b 100644 --- a/.venv/Lib/site-packages/pip/_internal/locations.py +++ b/.venv/Lib/site-packages/pip/_internal/locations.py @@ -124,10 +124,7 @@ def distutils_scheme( i.root = root or i.root i.finalize_options() - scheme = {} - for key in SCHEME_KEYS: - scheme[key] = getattr(i, 'install_' + key) - + scheme = {key: getattr(i, 'install_' + key) for key in SCHEME_KEYS} # install_lib specified in setup.cfg should install *everything* # into there (i.e. it takes precedence over both purelib and # platlib). Note, i.install_lib is *always* set after diff --git a/.venv/Lib/site-packages/pip/_internal/models/direct_url.py b/.venv/Lib/site-packages/pip/_internal/models/direct_url.py index 87bd9fe4..9991d428 100644 --- a/.venv/Lib/site-packages/pip/_internal/models/direct_url.py +++ b/.venv/Lib/site-packages/pip/_internal/models/direct_url.py @@ -202,10 +202,9 @@ def redacted_url(self): """ purl = urllib_parse.urlsplit(self.url) netloc = self._remove_auth_from_netloc(purl.netloc) - surl = urllib_parse.urlunsplit( + return urllib_parse.urlunsplit( (purl.scheme, netloc, purl.path, purl.query, purl.fragment) ) - return surl def validate(self): # type: () -> None diff --git a/.venv/Lib/site-packages/pip/_internal/models/format_control.py b/.venv/Lib/site-packages/pip/_internal/models/format_control.py index c6275e72..4abc84ab 100644 --- a/.venv/Lib/site-packages/pip/_internal/models/format_control.py +++ b/.venv/Lib/site-packages/pip/_internal/models/format_control.py @@ -75,13 +75,13 @@ def handle_mutual_excludes(value, target, other): def get_allowed_formats(self, canonical_name): # type: (str) -> FrozenSet[str] result = {"binary", "source"} - if canonical_name in self.only_binary: + if ( + canonical_name in self.only_binary + or canonical_name not in self.no_binary + and ':all:' in self.only_binary + ): result.discard('source') - elif canonical_name in self.no_binary: - result.discard('binary') - elif ':all:' in self.only_binary: - result.discard('source') - elif ':all:' in self.no_binary: + elif canonical_name in self.no_binary or ':all:' in self.no_binary: result.discard('binary') return frozenset(result) diff --git a/.venv/Lib/site-packages/pip/_internal/models/link.py b/.venv/Lib/site-packages/pip/_internal/models/link.py index c0d278ad..877b7dab 100644 --- a/.venv/Lib/site-packages/pip/_internal/models/link.py +++ b/.venv/Lib/site-packages/pip/_internal/models/link.py @@ -73,7 +73,7 @@ def __init__( self._url = url self.comes_from = comes_from - self.requires_python = requires_python if requires_python else None + self.requires_python = requires_python or None self.yanked_reason = yanked_reason super(Link, self).__init__(key=url, defining_class=Link) diff --git a/.venv/Lib/site-packages/pip/_internal/models/search_scope.py b/.venv/Lib/site-packages/pip/_internal/models/search_scope.py index d732504e..6c908e99 100644 --- a/.venv/Lib/site-packages/pip/_internal/models/search_scope.py +++ b/.venv/Lib/site-packages/pip/_internal/models/search_scope.py @@ -79,8 +79,8 @@ def __init__( def get_formatted_locations(self): # type: () -> str lines = [] - redacted_index_urls = [] if self.index_urls and self.index_urls != [PyPI.simple_url]: + redacted_index_urls = [] for url in self.index_urls: redacted_index_url = redact_auth_from_url(url) diff --git a/.venv/Lib/site-packages/pip/_internal/network/session.py b/.venv/Lib/site-packages/pip/_internal/network/session.py index 39a4a546..7ab95bf6 100644 --- a/.venv/Lib/site-packages/pip/_internal/network/session.py +++ b/.venv/Lib/site-packages/pip/_internal/network/session.py @@ -115,9 +115,7 @@ def user_agent(): pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info - data["implementation"]["version"] = ".".join( - [str(x) for x in pypy_version_info] - ) + data["implementation"]["version"] = ".".join(str(x) for x in pypy_version_info) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() @@ -336,8 +334,7 @@ def add_trusted_host(self, host, source=None, suppress_logging=False): def iter_secure_origins(self): # type: () -> Iterator[SecureOrigin] - for secure_origin in SECURE_ORIGINS: - yield secure_origin + yield from SECURE_ORIGINS for host, port in self.pip_trusted_origins: yield ('*', host, '*' if port is None else port) diff --git a/.venv/Lib/site-packages/pip/_internal/network/utils.py b/.venv/Lib/site-packages/pip/_internal/network/utils.py index 907b3fed..a5e0969d 100644 --- a/.venv/Lib/site-packages/pip/_internal/network/utils.py +++ b/.venv/Lib/site-packages/pip/_internal/network/utils.py @@ -61,7 +61,7 @@ def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE): """ try: # Special case for urllib3. - for chunk in response.raw.stream( + yield from response.raw.stream( chunk_size, # We use decode_content=False here because we don't # want urllib3 to mess with the raw bytes we get @@ -86,8 +86,7 @@ def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE): # By setting this not to decode automatically we # hope to eliminate problems with the second case. decode_content=False, - ): - yield chunk + ) except AttributeError: # Standard file-like object. while True: diff --git a/.venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py b/.venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py index 37dc876a..de15d29b 100644 --- a/.venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py +++ b/.venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py @@ -105,11 +105,10 @@ def build_wheel_legacy( return None names = os.listdir(tempd) - wheel_path = get_legacy_build_wheel_path( + return get_legacy_build_wheel_path( names=names, temp_dir=tempd, name=name, command_args=wheel_args, command_output=output, ) - return wheel_path diff --git a/.venv/Lib/site-packages/pip/_internal/req/constructors.py b/.venv/Lib/site-packages/pip/_internal/req/constructors.py index 7a4641ef..3453d569 100644 --- a/.venv/Lib/site-packages/pip/_internal/req/constructors.py +++ b/.venv/Lib/site-packages/pip/_internal/req/constructors.py @@ -50,9 +50,7 @@ def is_archive_file(name): # type: (str) -> bool """Return True if `name` is a considered as an archive file.""" ext = splitext(name)[1].lower() - if ext in ARCHIVE_EXTENSIONS: - return True - return False + return ext in ARCHIVE_EXTENSIONS def _strip_extras(path): @@ -135,7 +133,7 @@ def parse_editable(editable_req): vc_type = url.split('+', 1)[0].lower() if not vcs.get_backend(vc_type): - backends = ", ".join([bends.name + '+URL' for bends in vcs.backends]) + backends = ", ".join(bends.name + '+URL' for bends in vcs.backends) error_message = "For --editable={}, " \ "only {} are currently supported".format( editable_req, backends) @@ -259,9 +257,7 @@ def _looks_like_path(name): return True if os.path.altsep is not None and os.path.altsep in name: return True - if name.startswith("."): - return True - return False + return bool(name.startswith(".")) def _get_url_from_path(path, name): @@ -463,7 +459,7 @@ def install_req_from_parsed_requirement( ): # type: (...) -> InstallRequirement if parsed_req.is_editable: - req = install_req_from_editable( + return install_req_from_editable( parsed_req.requirement, comes_from=parsed_req.comes_from, use_pep517=use_pep517, @@ -473,7 +469,7 @@ def install_req_from_parsed_requirement( ) else: - req = install_req_from_line( + return install_req_from_line( parsed_req.requirement, comes_from=parsed_req.comes_from, use_pep517=use_pep517, @@ -483,4 +479,3 @@ def install_req_from_parsed_requirement( line_source=parsed_req.line_source, user_supplied=user_supplied, ) - return req diff --git a/.venv/Lib/site-packages/pip/_internal/req/req_file.py b/.venv/Lib/site-packages/pip/_internal/req/req_file.py index 10505822..724adeba 100644 --- a/.venv/Lib/site-packages/pip/_internal/req/req_file.py +++ b/.venv/Lib/site-packages/pip/_internal/req/req_file.py @@ -193,26 +193,26 @@ def handle_requirement_line( comes_from=line_comes_from, constraint=line.constraint, ) - else: - if options: - # Disable wheels if the user has specified build options - cmdoptions.check_install_build_global(options, line.opts) + if options: + # Disable wheels if the user has specified build options + cmdoptions.check_install_build_global(options, line.opts) # get the options that apply to requirements - req_options = {} - for dest in SUPPORTED_OPTIONS_REQ_DEST: - if dest in line.opts.__dict__ and line.opts.__dict__[dest]: - req_options[dest] = line.opts.__dict__[dest] - - line_source = 'line {} of {}'.format(line.lineno, line.filename) - return ParsedRequirement( - requirement=line.requirement, - is_editable=line.is_editable, - comes_from=line_comes_from, - constraint=line.constraint, - options=req_options, - line_source=line_source, - ) + req_options = { + dest: line.opts.__dict__[dest] + for dest in SUPPORTED_OPTIONS_REQ_DEST + if dest in line.opts.__dict__ and line.opts.__dict__[dest] + } + + line_source = 'line {} of {}'.format(line.lineno, line.filename) + return ParsedRequirement( + requirement=line.requirement, + is_editable=line.is_editable, + comes_from=line_comes_from, + constraint=line.constraint, + options=req_options, + line_source=line_source, + ) def handle_option_line( @@ -305,18 +305,16 @@ def handle_line( """ if line.is_requirement: - parsed_req = handle_requirement_line(line, options) - return parsed_req - else: - handle_option_line( - line.opts, - line.filename, - line.lineno, - finder, - options, - session, - ) - return None + return handle_requirement_line(line, options) + handle_option_line( + line.opts, + line.filename, + line.lineno, + finder, + options, + session, + ) + return None class RequirementsFileParser(object): @@ -335,8 +333,7 @@ def parse(self, filename, constraint): # type: (str, bool) -> Iterator[ParsedLine] """Parse a given file, yielding parsed lines. """ - for line in self._parse_and_recurse(filename, constraint): - yield line + yield from self._parse_and_recurse(filename, constraint) def _parse_and_recurse(self, filename, constraint): # type: (str, bool) -> Iterator[ParsedLine] @@ -364,10 +361,9 @@ def _parse_and_recurse(self, filename, constraint): os.path.dirname(filename), req_path, ) - for inner_line in self._parse_and_recurse( + yield from self._parse_and_recurse( req_path, nested_constraint, - ): - yield inner_line + ) else: yield line @@ -436,9 +432,8 @@ def break_args_options(line): for token in tokens: if token.startswith('-') or token.startswith('--'): break - else: - args.append(token) - options.pop(0) + args.append(token) + options.pop(0) return ' '.join(args), ' '.join(options) # type: ignore diff --git a/.venv/Lib/site-packages/pip/_internal/req/req_install.py b/.venv/Lib/site-packages/pip/_internal/req/req_install.py index f25cec96..a54fedb3 100644 --- a/.venv/Lib/site-packages/pip/_internal/req/req_install.py +++ b/.venv/Lib/site-packages/pip/_internal/req/req_install.py @@ -170,9 +170,9 @@ def __init__( # Set to True after successful installation self.install_succeeded = None # type: Optional[bool] # Supplied options - self.install_options = install_options if install_options else [] - self.global_options = global_options if global_options else [] - self.hash_options = hash_options if hash_options else {} + self.install_options = install_options or [] + self.global_options = global_options or [] + self.hash_options = hash_options or {} # Set to True after successful preparation of this requirement self.prepared = False # User supplied requirement are explicitly requested for installation @@ -437,18 +437,25 @@ def check_if_exists(self, use_user_site): existing_version = existing_dist.parsed_version if not self.req.specifier.contains(existing_version, prereleases=True): self.satisfied_by = None - if use_user_site: - if dist_in_usersite(existing_dist): - self.should_reinstall = True - elif (running_under_virtualenv() and - dist_in_site_packages(existing_dist)): - raise InstallationError( - "Will not install to the user site because it will " - "lack sys.path precedence to {} in {}".format( - existing_dist.project_name, existing_dist.location) - ) - else: + if ( + use_user_site + and dist_in_usersite(existing_dist) + or not use_user_site + ): self.should_reinstall = True + elif ( + use_user_site + and not dist_in_usersite(existing_dist) + and ( + running_under_virtualenv() + and dist_in_site_packages(existing_dist) + ) + ): + raise InstallationError( + "Will not install to the user site because it will " + "lack sys.path precedence to {} in {}".format( + existing_dist.project_name, existing_dist.location) + ) else: if self.editable: self.should_reinstall = True diff --git a/.venv/Lib/site-packages/pip/_internal/req/req_uninstall.py b/.venv/Lib/site-packages/pip/_internal/req/req_uninstall.py index 69719d33..c5f6195c 100644 --- a/.venv/Lib/site-packages/pip/_internal/req/req_uninstall.py +++ b/.venv/Lib/site-packages/pip/_internal/req/req_uninstall.py @@ -42,10 +42,7 @@ def _script_names(dist, script_name, is_gui): {console,gui}_scripts for the given ``dist``. Returns the list of file names """ - if dist_in_usersite(dist): - bin_dir = bin_user - else: - bin_dir = bin_py + bin_dir = bin_user if dist_in_usersite(dist) else bin_py exe_name = os.path.join(bin_dir, script_name) paths_to_remove = [exe_name] if WINDOWS: @@ -558,10 +555,7 @@ def from_dist(cls, dist): # find distutils scripts= scripts if dist.has_metadata('scripts') and dist.metadata_isdir('scripts'): for script in dist.metadata_listdir('scripts'): - if dist_in_usersite(dist): - bin_dir = bin_user - else: - bin_dir = bin_py + bin_dir = bin_user if dist_in_usersite(dist) else bin_py paths_to_remove.add(os.path.join(bin_dir, script)) if WINDOWS: paths_to_remove.add(os.path.join(bin_dir, script) + '.bat') @@ -619,10 +613,7 @@ def remove(self): # windows uses '\r\n' with py3k, but uses '\n' with py2.x lines = fh.readlines() self._saved_lines = lines - if any(b'\r\n' in line for line in lines): - endline = '\r\n' - else: - endline = '\n' + endline = '\r\n' if any(b'\r\n' in line for line in lines) else '\n' # handle missing trailing newline if lines and not lines[-1].endswith(endline.encode("utf-8")): lines[-1] = lines[-1] + endline.encode("utf-8") diff --git a/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py b/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py index 46cc7e7a..028bd108 100644 --- a/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +++ b/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py @@ -48,10 +48,7 @@ def make_install_req_from_link(link, template): # type: (Link, InstallRequirement) -> InstallRequirement assert not template.editable, "template is editable" - if template.req: - line = str(template.req) - else: - line = link.url + line = str(template.req) if template.req else link.url ireq = install_req_from_line( line, user_supplied=template.user_supplied, diff --git a/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py b/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py index bc1061f4..657ef985 100644 --- a/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py +++ b/.venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py @@ -75,7 +75,7 @@ def format_for_error(self): # risking a change in meaning. (Hopefully! Not all edge cases have # been checked) parts = [s.strip() for s in str(self).split(",")] - if len(parts) == 0: + if not parts: return "" elif len(parts) == 1: return parts[0] diff --git a/.venv/Lib/site-packages/pip/_internal/self_outdated_check.py b/.venv/Lib/site-packages/pip/_internal/self_outdated_check.py index fbd9dfd4..7e604d0e 100644 --- a/.venv/Lib/site-packages/pip/_internal/self_outdated_check.py +++ b/.venv/Lib/site-packages/pip/_internal/self_outdated_check.py @@ -42,8 +42,7 @@ def _get_statefile_name(key): # type: (Union[str, Text]) -> str key_bytes = ensure_binary(key) - name = hashlib.sha224(key_bytes).hexdigest() - return name + return hashlib.sha224(key_bytes).hexdigest() class SelfCheckState(object): diff --git a/.venv/Lib/site-packages/pip/_internal/utils/compat.py b/.venv/Lib/site-packages/pip/_internal/utils/compat.py index 89c5169a..2f68e08b 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/compat.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/compat.py @@ -222,10 +222,9 @@ def samefile(file1, file2): """Provide an alternative for os.path.samefile on Windows/Python2""" if hasattr(os.path, 'samefile'): return os.path.samefile(file1, file2) - else: - path1 = os.path.normcase(os.path.abspath(file1)) - path2 = os.path.normcase(os.path.abspath(file2)) - return path1 == path2 + path1 = os.path.normcase(os.path.abspath(file1)) + path2 = os.path.normcase(os.path.abspath(file2)) + return path1 == path2 if hasattr(shutil, 'get_terminal_size'): diff --git a/.venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py b/.venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py index 4f21874e..85a7e589 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py @@ -37,7 +37,7 @@ def _mac_platforms(arch): if match: name, major, minor, actual_arch = match.groups() mac_version = (int(major), int(minor)) - arches = [ + return [ # Since we have always only checked that the platform starts # with "macosx", for backwards-compatibility we extract the # actual prefix provided by the user in case they provided @@ -48,8 +48,7 @@ def _mac_platforms(arch): ] else: # arch pattern didn't match (?!) - arches = [arch] - return arches + return [arch] def _custom_manylinux_platforms(arch): @@ -78,12 +77,11 @@ def _get_custom_platforms(arch): # type: (str) -> List[str] arch_prefix, arch_sep, arch_suffix = arch.partition('_') if arch.startswith('macosx'): - arches = _mac_platforms(arch) + return _mac_platforms(arch) elif arch_prefix in ['manylinux2014', 'manylinux2010']: - arches = _custom_manylinux_platforms(arch) + return _custom_manylinux_platforms(arch) else: - arches = [arch] - return arches + return [arch] def _get_python_version(version): diff --git a/.venv/Lib/site-packages/pip/_internal/utils/deprecation.py b/.venv/Lib/site-packages/pip/_internal/utils/deprecation.py index 2f20cfd4..3c7d105d 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/deprecation.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/deprecation.py @@ -31,20 +31,20 @@ class PipDeprecationWarning(Warning): # Warnings <-> Logging Integration def _showwarning(message, category, filename, lineno, file=None, line=None): - if file is not None: - if _original_showwarning is not None: - _original_showwarning( - message, category, filename, lineno, file, line, - ) - elif issubclass(category, PipDeprecationWarning): + if ( + file is not None + and _original_showwarning is not None + or file is None + and not issubclass(category, PipDeprecationWarning) + ): + _original_showwarning( + message, category, filename, lineno, file, line, + ) + elif file is None: # We use a specially named logger which will handle all of the # deprecation messages for pip. logger = logging.getLogger("pip._internal.deprecations") logger.warning(message) - else: - _original_showwarning( - message, category, filename, lineno, file, line, - ) def install_warning_logger(): diff --git a/.venv/Lib/site-packages/pip/_internal/utils/filesystem.py b/.venv/Lib/site-packages/pip/_internal/utils/filesystem.py index 303243fd..17e98443 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/filesystem.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/filesystem.py @@ -41,16 +41,15 @@ def check_path_owner(path): while path != previous: if os.path.lexists(path): # Check if path is writable by current user. - if os.geteuid() == 0: - # Special handling for root user in order to handle properly - # cases where users use sudo without -H flag. - try: - path_uid = get_path_uid(path) - except OSError: - return False - return path_uid == 0 - else: + if os.geteuid() != 0: return os.access(path, os.W_OK) + # Special handling for root user in order to handle properly + # cases where users use sudo without -H flag. + try: + path_uid = get_path_uid(path) + except OSError: + return False + return path_uid == 0 else: previous, path = path, os.path.dirname(path) return False # assume we don't own the path diff --git a/.venv/Lib/site-packages/pip/_internal/utils/logging.py b/.venv/Lib/site-packages/pip/_internal/utils/logging.py index 9a017cf7..730898f1 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/logging.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/logging.py @@ -159,10 +159,7 @@ def format(self, record): t = self.formatTime(record, "%Y-%m-%dT%H:%M:%S") prefix = '{t},{record.msecs:03.0f} '.format(**locals()) prefix += " " * get_indentation() - formatted = "".join([ - prefix + line - for line in formatted.splitlines(True) - ]) + formatted = "".join(prefix + line for line in formatted.splitlines(True)) return formatted diff --git a/.venv/Lib/site-packages/pip/_internal/utils/misc.py b/.venv/Lib/site-packages/pip/_internal/utils/misc.py index 5629c60c..e038c9b9 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/misc.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/misc.py @@ -114,7 +114,7 @@ def ensure_dir(path): os.makedirs(path) except OSError as e: # Windows can raise spurious ENOTEMPTY errors. See #6426. - if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY: + if e.errno not in [errno.EEXIST, errno.ENOTEMPTY]: raise @@ -303,9 +303,7 @@ def is_installable_dir(path): if os.path.isfile(setup_py): return True pyproject_toml = os.path.join(path, 'pyproject.toml') - if os.path.isfile(pyproject_toml): - return True - return False + return bool(os.path.isfile(pyproject_toml)) def read_chunks(file, size=io.DEFAULT_BUFFER_SIZE): @@ -324,10 +322,7 @@ def normalize_path(path, resolve_symlinks=True): """ path = expanduser(path) - if resolve_symlinks: - path = os.path.realpath(path) - else: - path = os.path.abspath(path) + path = os.path.realpath(path) if resolve_symlinks else os.path.abspath(path) return os.path.normcase(path) diff --git a/.venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py b/.venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py index 2a664b00..9151f72b 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py @@ -168,11 +168,7 @@ def make_setuptools_install_args( if use_user_site: args += ["--user", "--prefix="] - if pycompile: - args += ["--compile"] - else: - args += ["--no-compile"] - + args += ["--compile"] if pycompile else ["--no-compile"] if header_dir: args += ["--install-headers", header_dir] diff --git a/.venv/Lib/site-packages/pip/_internal/utils/subprocess.py b/.venv/Lib/site-packages/pip/_internal/utils/subprocess.py index d398e68d..4bcb9933 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/subprocess.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/subprocess.py @@ -91,7 +91,7 @@ def make_subprocess_output_error( # We know the joined output value ends in a newline. output = ''.join(lines) - msg = ( + return ( # Use a unicode string to avoid "UnicodeEncodeError: 'ascii' # codec can't encode character ..." in Python 2 when a format # argument (e.g. `output`) has a non-ascii character. @@ -107,7 +107,6 @@ def make_subprocess_output_error( output=output, divider=LOG_DIVIDER, ) - return msg def call_subprocess( @@ -247,9 +246,7 @@ def call_subprocess( proc.returncode, cwd, ) - elif on_returncode == 'ignore': - pass - else: + elif on_returncode != 'ignore': raise ValueError('Invalid value: on_returncode={!r}'.format( on_returncode)) return ''.join(all_output) diff --git a/.venv/Lib/site-packages/pip/_internal/utils/urls.py b/.venv/Lib/site-packages/pip/_internal/utils/urls.py index f37bc8f9..b1a163ec 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/urls.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/urls.py @@ -24,8 +24,7 @@ def path_to_url(path): quoted path parts. """ path = os.path.normpath(os.path.abspath(path)) - url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) - return url + return urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) def url_to_path(url): diff --git a/.venv/Lib/site-packages/pip/_internal/utils/wheel.py b/.venv/Lib/site-packages/pip/_internal/utils/wheel.py index 9ce371c7..e1167eec 100644 --- a/.venv/Lib/site-packages/pip/_internal/utils/wheel.py +++ b/.venv/Lib/site-packages/pip/_internal/utils/wheel.py @@ -121,7 +121,7 @@ def wheel_dist_info_dir(source, name): it doesn't match the provided name. """ # Zip file path separators must be / - subdirs = set(p.split("/", 1)[0] for p in source.namelist()) + subdirs = {p.split("/", 1)[0] for p in source.namelist()} info_dirs = [s for s in subdirs if s.endswith('.dist-info')] diff --git a/.venv/Lib/site-packages/pip/_internal/vcs/mercurial.py b/.venv/Lib/site-packages/pip/_internal/vcs/mercurial.py index 69763fea..3e919f1f 100644 --- a/.venv/Lib/site-packages/pip/_internal/vcs/mercurial.py +++ b/.venv/Lib/site-packages/pip/_internal/vcs/mercurial.py @@ -102,9 +102,8 @@ def get_revision(cls, location): """ Return the repository-local changeset revision number, as an integer. """ - current_revision = cls.run_command( + return cls.run_command( ['parents', '--template={rev}'], cwd=location).strip() - return current_revision @classmethod def get_requirement_revision(cls, location): @@ -112,10 +111,9 @@ def get_requirement_revision(cls, location): Return the changeset identification hash, as a 40-character hexadecimal string """ - current_rev_hash = cls.run_command( + return cls.run_command( ['parents', '--template={node}'], cwd=location).strip() - return current_rev_hash @classmethod def is_commit_id_equal(cls, dest, name): diff --git a/.venv/Lib/site-packages/pip/_internal/vcs/subversion.py b/.venv/Lib/site-packages/pip/_internal/vcs/subversion.py index ab134970..7087347b 100644 --- a/.venv/Lib/site-packages/pip/_internal/vcs/subversion.py +++ b/.venv/Lib/site-packages/pip/_internal/vcs/subversion.py @@ -173,11 +173,7 @@ def _get_svn_url_rev(cls, location): except SubProcessError: url, revs = None, [] - if revs: - rev = max(revs) - else: - rev = 0 - + rev = max(revs) if revs else 0 return url, rev @classmethod diff --git a/.venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py b/.venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py index 96f830f9..60340170 100644 --- a/.venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +++ b/.venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py @@ -106,9 +106,6 @@ def call_subprocess( if extra_environ: env.update(extra_environ) - # Whether the subprocess will be visible in the console. - showing_subprocess = True - command_desc = format_command_args(cmd) try: proc = subprocess.Popen( @@ -149,6 +146,9 @@ def call_subprocess( proc.returncode and proc.returncode not in extra_ok_returncodes ) if proc_had_error: + # Whether the subprocess will be visible in the console. + showing_subprocess = True + if not showing_subprocess and log_failed_cmd: # Then the subprocess streams haven't been logged to the # console yet. @@ -428,11 +428,9 @@ def get_src_requirement(cls, repo_dir, project_name): revision = cls.get_requirement_revision(repo_dir) subdir = cls.get_subdirectory(repo_dir) - req = make_vcs_requirement_url(repo_url, revision, project_name, + return make_vcs_requirement_url(repo_url, revision, project_name, subdir=subdir) - return req - @staticmethod def get_base_rev_args(rev): # type: (str) -> List[str] diff --git a/.venv/Lib/site-packages/pip/_internal/wheel_builder.py b/.venv/Lib/site-packages/pip/_internal/wheel_builder.py index fa08016b..093725a5 100644 --- a/.venv/Lib/site-packages/pip/_internal/wheel_builder.py +++ b/.venv/Lib/site-packages/pip/_internal/wheel_builder.py @@ -151,10 +151,9 @@ def _get_cache_dir( cache_available = bool(wheel_cache.cache_dir) assert req.link if cache_available and _should_cache(req): - cache_dir = wheel_cache.get_path_for_link(req.link) + return wheel_cache.get_path_for_link(req.link) else: - cache_dir = wheel_cache.get_ephem_path_for_link(req.link) - return cache_dir + return wheel_cache.get_ephem_path_for_link(req.link) def _always_true(_): @@ -297,12 +296,10 @@ def build( if build_successes: logger.info( 'Successfully built %s', - ' '.join([req.name for req in build_successes]), # type: ignore + ' '.join(req.name for req in build_successes), ) + if build_failures: - logger.info( - 'Failed to build %s', - ' '.join([req.name for req in build_failures]), # type: ignore - ) + logger.info('Failed to build %s', ' '.join(req.name for req in build_failures)) # Return a list of requirements that failed to build return build_successes, build_failures diff --git a/.venv/Lib/site-packages/pip/_vendor/appdirs.py b/.venv/Lib/site-packages/pip/_vendor/appdirs.py index 33a3b774..b83a5517 100644 --- a/.venv/Lib/site-packages/pip/_vendor/appdirs.py +++ b/.venv/Lib/site-packages/pip/_vendor/appdirs.py @@ -132,7 +132,11 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): WARNING: Do not use this on Windows. See the Vista-Fail note above for why. """ - if system == "win32": + if system == 'darwin': + path = os.path.expanduser('/Library/Application Support') + if appname: + path = os.path.join(path, appname) + elif system == "win32": if appauthor is None: appauthor = appname path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA")) @@ -141,10 +145,6 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): path = os.path.join(path, appauthor, appname) else: path = os.path.join(path, appname) - elif system == 'darwin': - path = os.path.expanduser('/Library/Application Support') - if appname: - path = os.path.join(path, appname) else: # XDG default for $XDG_DATA_DIRS # only first, if multipath is False @@ -156,10 +156,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): appname = os.path.join(appname, version) pathlist = [os.path.join(x, appname) for x in pathlist] - if multipath: - path = os.pathsep.join(pathlist) - else: - path = pathlist[0] + path = os.pathsep.join(pathlist) if multipath else pathlist[0] return path if appname and version: @@ -254,10 +251,7 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False) appname = os.path.join(appname, version) pathlist = [os.path.join(x, appname) for x in pathlist] - if multipath: - path = os.pathsep.join(pathlist) - else: - path = pathlist[0] + path = os.pathsep.join(pathlist) if multipath else pathlist[0] return path diff --git a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py index 815650e8..4c1cd535 100644 --- a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py +++ b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py @@ -50,9 +50,7 @@ def send(self, request, cacheable_methods=None, **kw): # check for etags and add headers if appropriate request.headers.update(self.controller.conditional_headers(request)) - resp = super(CacheControlAdapter, self).send(request, **kw) - - return resp + return super(CacheControlAdapter, self).send(request, **kw) def build_response( self, request, response, from_cache=False, cacheable_methods=None diff --git a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py index dafe55ca..97d1c59b 100644 --- a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py +++ b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py @@ -55,9 +55,7 @@ def _urlnorm(cls, uri): # Could do syntax based normalization of the URI before # computing the digest. See Section 6.2.2 of Std 66. request_uri = query and "?".join([path, query]) or path - defrag_uri = scheme + "://" + authority + request_uri - - return defrag_uri + return scheme + "://" + authority + request_uri @classmethod def cache_url(cls, uri): @@ -359,13 +357,8 @@ def update_cached_response(self, request, response): # typical assumptions. excluded_headers = ["content-length"] - cached_response.headers.update( - dict( - (k, v) - for k, v in response.headers.items() - if k.lower() not in excluded_headers - ) - ) + cached_response.headers.update({k: v for k, v in response.headers.items() + if k.lower() not in excluded_headers}) # we want a 200 b/c we have content via the cache cached_response.status = 200 diff --git a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py index 3b6ec2de..2575b77f 100644 --- a/.venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py +++ b/.venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py @@ -161,15 +161,17 @@ def _loads_v2(self, request, data): # We need to decode the items that we've base64 encoded cached["response"]["body"] = _b64_decode_bytes(cached["response"]["body"]) - cached["response"]["headers"] = dict( - (_b64_decode_str(k), _b64_decode_str(v)) + cached["response"]["headers"] = { + _b64_decode_str(k): _b64_decode_str(v) for k, v in cached["response"]["headers"].items() - ) + } + cached["response"]["reason"] = _b64_decode_str(cached["response"]["reason"]) - cached["vary"] = dict( - (_b64_decode_str(k), _b64_decode_str(v) if v is not None else v) + cached["vary"] = { + _b64_decode_str(k): _b64_decode_str(v) if v is not None else v for k, v in cached["vary"].items() - ) + } + return self.prepare_response(request, cached) diff --git a/.venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py b/.venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py index 8b3738ef..3d715ba6 100644 --- a/.venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py +++ b/.venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py @@ -50,16 +50,16 @@ def reset(self): def charset_name(self): if not self._best_guess_prober: self.get_confidence() - if not self._best_guess_prober: - return None + if not self._best_guess_prober: + return None return self._best_guess_prober.charset_name @property def language(self): if not self._best_guess_prober: self.get_confidence() - if not self._best_guess_prober: - return None + if not self._best_guess_prober: + return None return self._best_guess_prober.language def feed(self, byte_str): diff --git a/.venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py b/.venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py index 20ce8f7d..14875c97 100644 --- a/.venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py +++ b/.venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py @@ -79,10 +79,11 @@ def feed(self, byte_str): self._last_char[0] = byte_str[-1] - if self.state == ProbingState.DETECTING: - if (self.context_analyzer.got_enough_data() and - (self.get_confidence() > self.SHORTCUT_THRESHOLD)): - self._state = ProbingState.FOUND_IT + if self.state == ProbingState.DETECTING and ( + self.context_analyzer.got_enough_data() + and (self.get_confidence() > self.SHORTCUT_THRESHOLD) + ): + self._state = ProbingState.FOUND_IT return self.state diff --git a/.venv/Lib/site-packages/pip/_vendor/distro.py b/.venv/Lib/site-packages/pip/_vendor/distro.py index 0611b62a..5edc05dd 100644 --- a/.venv/Lib/site-packages/pip/_vendor/distro.py +++ b/.venv/Lib/site-packages/pip/_vendor/distro.py @@ -747,16 +747,15 @@ def version(self, pretty=False, best=False): self.uname_attr('release') ] version = '' - if best: # This algorithm uses the last version in priority order that has # the best precision. If the versions are not in conflict, that # does not matter; otherwise, using the last one instead of the # first one might be considered a surprise. - for v in versions: + for v in versions: + if best: if v.count(".") > version.count(".") or version == '': version = v - else: - for v in versions: + else: if v != '': version = v break diff --git a/.venv/Lib/site-packages/pip/_vendor/ipaddress.py b/.venv/Lib/site-packages/pip/_vendor/ipaddress.py index 3e6f9e49..4b192e2e 100644 --- a/.venv/Lib/site-packages/pip/_vendor/ipaddress.py +++ b/.venv/Lib/site-packages/pip/_vendor/ipaddress.py @@ -896,7 +896,7 @@ def address_exclude(self, other): ValueError: If other is not completely contained by self. """ - if not self._version == other._version: + if self._version != other._version: raise TypeError("%s and %s are not of the same version" % ( self, other)) @@ -1337,9 +1337,7 @@ def _is_hostmask(self, ip_str): return False if len(parts) != len(bits): return False - if parts[0] < parts[-1]: - return True - return False + return parts[0] < parts[-1] def _reverse_pointer(self): """Return the reverse DNS pointer name for the IPv4 address. @@ -1488,11 +1486,7 @@ def __init__(self, address): if isinstance(address, tuple): IPv4Address.__init__(self, address[0]) - if len(address) > 1: - self._prefixlen = int(address[1]) - else: - self._prefixlen = self._max_prefixlen - + self._prefixlen = int(address[1]) if len(address) > 1 else self._max_prefixlen self.network = IPv4Network(address, strict=False) self.netmask = self.network.netmask self.hostmask = self.network.hostmask @@ -1669,9 +1663,10 @@ def is_global(self): iana-ipv4-special-registry. """ - return (not (self.network_address in IPv4Network('100.64.0.0/10') and - self.broadcast_address in IPv4Network('100.64.0.0/10')) and - not self.is_private) + return ( + self.network_address not in IPv4Network('100.64.0.0/10') + or self.broadcast_address not in IPv4Network('100.64.0.0/10') + ) and not self.is_private class _IPv4Constants(object): @@ -2184,10 +2179,7 @@ def __init__(self, address): return if isinstance(address, tuple): IPv6Address.__init__(self, address[0]) - if len(address) > 1: - self._prefixlen = int(address[1]) - else: - self._prefixlen = self._max_prefixlen + self._prefixlen = int(address[1]) if len(address) > 1 else self._max_prefixlen self.network = IPv6Network(address, strict=False) self.netmask = self.network.netmask self.hostmask = self.network.hostmask @@ -2319,10 +2311,7 @@ def __init__(self, address, strict=True): return if isinstance(address, tuple): - if len(address) > 1: - arg = address[1] - else: - arg = self._max_prefixlen + arg = address[1] if len(address) > 1 else self._max_prefixlen self.netmask, self._prefixlen = self._make_netmask(arg) self.network_address = IPv6Address(address[0]) packed = int(self.network_address) @@ -2340,16 +2329,14 @@ def __init__(self, address, strict=True): self.network_address = IPv6Address(self._ip_int_from_string(addr[0])) - if len(addr) == 2: - arg = addr[1] - else: - arg = self._max_prefixlen + arg = addr[1] if len(addr) == 2 else self._max_prefixlen self.netmask, self._prefixlen = self._make_netmask(arg) - if strict: - if (IPv6Address(int(self.network_address) & int(self.netmask)) != - self.network_address): - raise ValueError('%s has host bits set' % self) + if strict and ( + IPv6Address(int(self.network_address) & int(self.netmask)) + != self.network_address + ): + raise ValueError('%s has host bits set' % self) self.network_address = IPv6Address(int(self.network_address) & int(self.netmask)) diff --git a/.venv/Lib/site-packages/pip/_vendor/pyparsing.py b/.venv/Lib/site-packages/pip/_vendor/pyparsing.py index 7ebc7eb9..c26d3952 100644 --- a/.venv/Lib/site-packages/pip/_vendor/pyparsing.py +++ b/.venv/Lib/site-packages/pip/_vendor/pyparsing.py @@ -265,7 +265,7 @@ def _ustr(obj): except AttributeError: continue -_generatorType = type((y for y in range(1))) +_generatorType = type(iter(range(1))) def _xml_escape(data): """Escape &, <, >, ", ', etc. in a string of data.""" @@ -567,7 +567,7 @@ def __init__(self, toklist=None, name=None, asList=True, modal=True, isinstance= self.__toklist = list(toklist) else: self.__toklist = [toklist] - self.__tokdict = dict() + self.__tokdict = {} if name is not None and name: if not modal: @@ -742,16 +742,13 @@ def remove_LABEL(tokens): args = (args[0], v) else: raise TypeError("pop() got an unexpected keyword argument '%s'" % k) - if (isinstance(args[0], int) - or len(args) == 1 - or args[0] in self): - index = args[0] - ret = self[index] - del self[index] - return ret - else: - defaultvalue = args[1] - return defaultvalue + if not isinstance(args[0], int) and len(args) != 1 and args[0] not in self: + return args[1] + + index = args[0] + ret = self[index] + del self[index] + return ret def get(self, key, defaultValue=None): """ @@ -960,8 +957,7 @@ def asXML(self, doctag=None, namedItemsOnly=False, indent="", formatted=True): """ nl = "\n" out = [] - namedItems = dict((v[1], k) for (k, vlist) in self.__tokdict.items() - for v in vlist) + namedItems = {v[1]: k for (k, vlist) in self.__tokdict.items() for v in vlist} nextLevelIndent = indent + " " # collapse out indents if formatting is not desired @@ -999,9 +995,7 @@ def asXML(self, doctag=None, namedItemsOnly=False, indent="", formatted=True): formatted)] else: # individual token, see if there is a name for it - resTag = None - if i in namedItems: - resTag = namedItems[i] + resTag = namedItems.get(i, None) if not resTag: if namedItemsOnly: continue @@ -1084,7 +1078,6 @@ def dump(self, indent='', full=True, include_list=True, _depth=0): - year: 12 """ out = [] - NL = '\n' if include_list: out.append(indent + _ustr(self.asList())) else: @@ -1093,6 +1086,7 @@ def dump(self, indent='', full=True, include_list=True, _depth=0): if full: if self.haskeys(): items = sorted((str(k), v) for k, v in self.items()) + NL = '\n' for k, v in items: if out: out.append(NL) @@ -1167,10 +1161,7 @@ def __setstate__(self, state): self.__tokdict, par, inAccumNames, self.__name = state[1] self.__accumNames = {} self.__accumNames.update(inAccumNames) - if par is not None: - self.__parent = wkref(par) - else: - self.__parent = None + self.__parent = wkref(par) if par is not None else None def __getnewargs__(self): return self.__toklist, self.__name, self.__asList, self.__modal @@ -1313,9 +1304,8 @@ def extract_tb(tb, limit=0): def wrapper(*args): while 1: try: - ret = func(*args[limit[0]:]) foundArity[0] = True - return ret + return func(*args[limit[0]:]) except TypeError: # re-raise TypeErrors if they did not come from our arity testing if foundArity[0]: @@ -1323,7 +1313,7 @@ def wrapper(*args): else: try: tb = sys.exc_info()[-1] - if not extract_tb(tb, limit=2)[-1][:2] == pa_call_line_synth: + if extract_tb(tb, limit=2)[-1][:2] != pa_call_line_synth: raise finally: try: @@ -1398,7 +1388,7 @@ def _trim_traceback(cls, tb): return tb def __init__(self, savelist=False): - self.parseAction = list() + self.parseAction = [] self.failAction = None # ~ self.name = "" # don't define self.name, let subclasses try/except upcall self.strRepr = None @@ -1409,7 +1399,7 @@ def __init__(self, savelist=False): self.copyDefaultWhiteChars = True self.mayReturnEmpty = False # used when checking for left-recursion self.keepTabs = False - self.ignoreExprs = list() + self.ignoreExprs = [] self.debug = False self.streamlined = False self.mayIndexError = True # used to optimize exception handling for subclasses that don't advance parse index @@ -1618,9 +1608,9 @@ def _skipIgnorables(self, instring, loc): exprsFound = False for e in self.ignoreExprs: try: + exprsFound = True while 1: loc, dummy = e._parse(instring, loc) - exprsFound = True except ParseException: pass return loc @@ -1833,12 +1823,12 @@ def cache_len(self): # this method gets repeatedly called during backtracking with the same arguments - # we can cache these arguments and save ourselves the trouble of re-parsing the contained expression def _parseCache(self, instring, loc, doActions=True, callPreParse=True): - HIT, MISS = 0, 1 lookup = (self, instring, loc, callPreParse, doActions) with ParserElement.packrat_cache_lock: cache = ParserElement.packrat_cache value = cache.get(lookup) if value is cache.not_in_cache: + HIT, MISS = 0, 1 ParserElement.packrat_cache_stats[MISS] += 1 try: value = self._parseNoCache(instring, loc, doActions, callPreParse) @@ -1948,11 +1938,10 @@ def parseString(self, instring, parseAll=False): except ParseBaseException as exc: if ParserElement.verbose_stacktrace: raise - else: - # catch and re-raise exception from here, clearing out pyparsing internal stack trace - if getattr(exc, '__traceback__', None) is not None: - exc.__traceback__ = self._trim_traceback(exc.__traceback__) - raise exc + # catch and re-raise exception from here, clearing out pyparsing internal stack trace + if getattr(exc, '__traceback__', None) is not None: + exc.__traceback__ = self._trim_traceback(exc.__traceback__) + raise exc else: return tokens @@ -2024,11 +2013,10 @@ def scanString(self, instring, maxMatches=_MAX_INT, overlap=False): except ParseBaseException as exc: if ParserElement.verbose_stacktrace: raise - else: - # catch and re-raise exception from here, clearing out pyparsing internal stack trace - if getattr(exc, '__traceback__', None) is not None: - exc.__traceback__ = self._trim_traceback(exc.__traceback__) - raise exc + # catch and re-raise exception from here, clearing out pyparsing internal stack trace + if getattr(exc, '__traceback__', None) is not None: + exc.__traceback__ = self._trim_traceback(exc.__traceback__) + raise exc def transformString(self, instring): """ @@ -2072,11 +2060,10 @@ def transformString(self, instring): except ParseBaseException as exc: if ParserElement.verbose_stacktrace: raise - else: - # catch and re-raise exception from here, clearing out pyparsing internal stack trace - if getattr(exc, '__traceback__', None) is not None: - exc.__traceback__ = self._trim_traceback(exc.__traceback__) - raise exc + # catch and re-raise exception from here, clearing out pyparsing internal stack trace + if getattr(exc, '__traceback__', None) is not None: + exc.__traceback__ = self._trim_traceback(exc.__traceback__) + raise exc def searchString(self, instring, maxMatches=_MAX_INT): """ @@ -2104,11 +2091,10 @@ def searchString(self, instring, maxMatches=_MAX_INT): except ParseBaseException as exc: if ParserElement.verbose_stacktrace: raise - else: - # catch and re-raise exception from here, clearing out pyparsing internal stack trace - if getattr(exc, '__traceback__', None) is not None: - exc.__traceback__ = self._trim_traceback(exc.__traceback__) - raise exc + # catch and re-raise exception from here, clearing out pyparsing internal stack trace + if getattr(exc, '__traceback__', None) is not None: + exc.__traceback__ = self._trim_traceback(exc.__traceback__) + raise exc def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False): """ @@ -2578,11 +2564,10 @@ def parseFile(self, file_or_filename, parseAll=False): except ParseBaseException as exc: if ParserElement.verbose_stacktrace: raise - else: - # catch and re-raise exception from here, clearing out pyparsing internal stack trace - if getattr(exc, '__traceback__', None) is not None: - exc.__traceback__ = self._trim_traceback(exc.__traceback__) - raise exc + # catch and re-raise exception from here, clearing out pyparsing internal stack trace + if getattr(exc, '__traceback__', None) is not None: + exc.__traceback__ = self._trim_traceback(exc.__traceback__) + raise exc def __eq__(self, other): if self is other: @@ -2603,7 +2588,7 @@ def __req__(self, other): return self == other def __rne__(self, other): - return not (self == other) + return self != other def matches(self, testString, parseAll=True): """ diff --git a/.venv/Lib/site-packages/pip/_vendor/retrying.py b/.venv/Lib/site-packages/pip/_vendor/retrying.py index 6d1e627a..80d39f7f 100644 --- a/.venv/Lib/site-packages/pip/_vendor/retrying.py +++ b/.venv/Lib/site-packages/pip/_vendor/retrying.py @@ -164,17 +164,14 @@ def incrementing_sleep(self, previous_attempt_number, delay_since_first_attempt_ wait_incrementing_start and incrementing by wait_incrementing_increment """ result = self._wait_incrementing_start + (self._wait_incrementing_increment * (previous_attempt_number - 1)) - if result < 0: - result = 0 + result = max(result, 0) return result def exponential_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): exp = 2 ** previous_attempt_number result = self._wait_exponential_multiplier * exp - if result > self._wait_exponential_max: - result = self._wait_exponential_max - if result < 0: - result = 0 + result = min(result, self._wait_exponential_max) + result = max(result, 0) return result def never_reject(self, result): diff --git a/.venv/Lib/site-packages/pip/_vendor/six.py b/.venv/Lib/site-packages/pip/_vendor/six.py index 83f69783..965baa5d 100644 --- a/.venv/Lib/site-packages/pip/_vendor/six.py +++ b/.venv/Lib/site-packages/pip/_vendor/six.py @@ -145,10 +145,7 @@ def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): new_mod = name self.mod = new_mod if new_attr is None: - if old_attr is None: - new_attr = name - else: - new_attr = old_attr + new_attr = name if old_attr is None else old_attr self.attr = new_attr else: self.mod = old_mod diff --git a/.venv/Lib/site-packages/retrying.py b/.venv/Lib/site-packages/retrying.py index 3ed312da..bf932bab 100644 --- a/.venv/Lib/site-packages/retrying.py +++ b/.venv/Lib/site-packages/retrying.py @@ -164,17 +164,14 @@ def incrementing_sleep(self, previous_attempt_number, delay_since_first_attempt_ wait_incrementing_start and incrementing by wait_incrementing_increment """ result = self._wait_incrementing_start + (self._wait_incrementing_increment * (previous_attempt_number - 1)) - if result < 0: - result = 0 + result = max(result, 0) return result def exponential_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): exp = 2 ** previous_attempt_number result = self._wait_exponential_multiplier * exp - if result > self._wait_exponential_max: - result = self._wait_exponential_max - if result < 0: - result = 0 + result = min(result, self._wait_exponential_max) + result = max(result, 0) return result def never_reject(self, result): diff --git a/.venv/Lib/site-packages/six.py b/.venv/Lib/site-packages/six.py index 83f69783..965baa5d 100644 --- a/.venv/Lib/site-packages/six.py +++ b/.venv/Lib/site-packages/six.py @@ -145,10 +145,7 @@ def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): new_mod = name self.mod = new_mod if new_attr is None: - if old_attr is None: - new_attr = name - else: - new_attr = old_attr + new_attr = name if old_attr is None else old_attr self.attr = new_attr else: self.mod = old_mod